%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2025 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) %# %# %# LICENSE: %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org. %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# You should have received a copy of the GNU General Public License %# along with this program; if not, write to the Free Software %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA %# 02110-1301 or visit their web page on the internet at %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. %# %# %# CONTRIBUTION SUBMISSION POLICY: %# %# (The following paragraph is not intended to limit the rights granted %# to you to modify and distribute this software under the terms of %# the GNU General Public License and is only of importance to you if %# you choose to contribute your changes and enhancements to the %# community by submitting them to Best Practical Solutions, LLC.) %# %# By intentionally submitting any modifications, corrections or %# derivatives to this work, or any other work intended for use with %# Request Tracker, to Best Practical Solutions, LLC, you confirm that %# you are the copyright holder for those contributions and you grant %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, %# royalty-free, perpetual, license to use, copy, create derivative %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} <& /Admin/Elements/Header, Title => $title &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &>
%if ($Create) { % } else { % }
<&| /Widgets/TitleBox, title => loc('Identity'), class => 'user-info-identity' &> <&| /Elements/LabeledValue, Label => loc("Username") &> <&|/l&>(required) <&| /Elements/LabeledValue, Label => loc("Email") &> <&| /Elements/LabeledValue, Label => loc("Real Name") &> <&| /Elements/LabeledValue, Label => loc("Nickname") &> <&| /Elements/LabeledValue, Label => loc("Unix login") &> <&| /Elements/LabeledValue, Label => loc("Language") &> <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang//$ARGS{Lang} &> <&| /Elements/LabeledValue, Label => loc("Timezone") &> <& /Elements/SelectTimezone, Name => 'Timezone', Default => $UserObj->Timezone &> <&| /Elements/LabeledValue, Label => loc("Extra info") &> <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Identity' &> <&| /Widgets/TitleBox, title => loc('Access control'), class => 'user-info-access-control' &>
Id && $UserObj->Disabled) ? '' : 'checked="checked"' |n%> />
% my $PrivilegedChecked = ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $ARGS{Privileged})) ? 'checked="checked"' : '';
/>
<& /Elements/EditPassword, User => $UserObj, Name => [qw(CurrentPass Pass1 Pass2)], &> <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &> <&| /Widgets/TitleBox, title => loc('Comments about this user'), class => 'user-info-comments' &>
%if (!$Create && $UserObj->Privileged) { % my $sig = $UserObj->Signature//$ARGS{Signature}//''; % my $richtext = ''; <&| /Widgets/TitleBox, title => loc('Signature'), class => 'user-info-signature' &>
% if (RT->Config->Get('MessageBoxRichText', $UserObj )) { % # allow for a smooth transition from a plain text signature, with or without HTML content, to an HTML signature "/> % $richtext = ' richtext'; % }
% } % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
<&| /Widgets/TitleBox, title => loc('Location'), class => 'user-info-location' &> <&| /Elements/LabeledValue, Label => loc("Organization") &> <&| /Elements/LabeledValue, Label => loc("Address1") &> <&| /Elements/LabeledValue, Label => loc("Address2") &> <&| /Elements/LabeledValue, Label => loc("City") &> <&| /Elements/LabeledValue, Label => loc("State") &> <&| /Elements/LabeledValue, Label => loc("Zip") &> <&| /Elements/LabeledValue, Label => loc("Country") &> <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location' &> <&| /Widgets/TitleBox, title => loc('Phone numbers'), class => 'user-info-phones' &> <&| /Elements/LabeledValue, Label => loc("Residence") &> <&| /Elements/LabeledValue, Label => loc("Work") &> <&| /Elements/LabeledValue, Label => loc("Mobile") &> <&| /Elements/LabeledValue, Label => loc("Pager") &> <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones' &> <& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &> % unless ( $Create ) { <& /User/Elements/RelatedData, UserObj => $UserObj &> % } % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
% if ( $Create ) {
<& /Elements/Submit, Label => loc('Create') &>
% } else {
<& /Elements/Submit, Label => loc('Save Changes') &>
% }
% if ( $UserObj->Id ) { % } <%INIT> my $UserObj = RT::User->new($session{'CurrentUser'}); my ($title, @results); my $skip_update = 0; my ($val, $msg); if ( ($id && $id ne 'new') || ( $ARGS{Name} && not $id ) ) { if ( $id ) { ( $val, $msg ) = $UserObj->Load($id); } else { ( $val, $msg ) = $UserObj->Load($ARGS{Name}); } if ( not $val ) { RT->Logger->error("Unable to load user with id $id: $msg"); Abort(loc("Couldn't load user '[_1]'", ( $ARGS{Name} || ''))); } } # Handle case when Modify is called with no params if ( not $UserObj->Id and not $Create and $id ne 'new' ) { Abort(loc("Couldn't load user '[_1]'", ( $ARGS{Name} || ''))); } my $CustomFields = $UserObj->CustomFields; my ($status, @msg) = $m->comp( '/Elements/ValidateCustomFields', Object => $UserObj, CustomFields => $CustomFields, ARGSRef => \%ARGS, ); unless ($status) { push @results, @msg; $skip_update = 1; if ( $id && $id eq 'new' ) { $Create = 1; } } $ARGS{Privileged} = $ARGS{Privileged} ? 1 : 0; delete $ARGS{Privileged} unless $ARGS{SetPrivileged}; $ARGS{Disabled} = $ARGS{Enabled} ? 0 : 1; delete $ARGS{Disabled} unless $ARGS{SetEnabled}; my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo Organization RealName NickName Lang Gecos HomePhone WorkPhone MobilePhone PagerPhone Address1 Address2 City State Zip Country Timezone ); if ($Create) { $title = loc("Create a new user"); } elsif ( defined $id && $id eq 'new' && not $skip_update ) { $m->callback( CallbackName => 'BeforeCreate', ARGSRef => \%ARGS, Fields => \@fields, Results => \@results ); ( $val, $msg ) = $UserObj->Create( (map {($_ => $ARGS{$_})} @fields), Privileged => $ARGS{'Privileged'}, Disabled => $ARGS{'Disabled'}, ); if ($val) { push @results, $msg; _FilterUserCFValuesOnCreate( ARGSRef => \%ARGS, UserObj => $UserObj ); push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj ); $title = loc("Modify the user [_1]", $UserObj->Name); } else { push @results, loc('User could not be created: [_1]', $msg); $title = loc("Create a new user"); $Create = 1; } } elsif ( $UserObj->Id && not $skip_update ) { $title = loc("Modify the user [_1]", $UserObj->Name); $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results ); my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields, Object => $UserObj, ARGSRef => \%ARGS ); push (@results,@fieldresults); push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj ); if ( defined $ARGS{Privileged} and $ARGS{Privileged} != ($UserObj->Privileged || 0) ) { my ($code, $msg) = $UserObj->SetPrivileged($ARGS{Privileged}); push @results, loc('Privileged status: [_1]', loc_fuzzy($msg)); } if ( defined $ARGS{Disabled} and $ARGS{Disabled} != $UserObj->Disabled ) { my ($code, $msg) = $UserObj->SetDisabled($ARGS{Disabled}); push @results, $msg; } } if ( $ARGS{'Anonymize'} and $UserObj->Id && not $skip_update ) { my ($ret, $msg) = $UserObj->AnonymizeUser(ClearCustomFields => $ARGS{'clear_customfields'}); push @results, $msg; } if ( $UserObj->Id && not $skip_update ) { # Deal with Password field my ($status, $msg) = $UserObj->SafeSetPassword( Current => $CurrentPass, New => $Pass1, Confirmation => $Pass2, ); push @results, $msg; if ( $id eq 'new' && !$status ) { push @results, loc("A password was not set, so user won't be able to login."); } } # This code does automatic redirection if any updates happen. unless ( $skip_update ) { MaybeRedirectForResults( Actions => \@results, Arguments => { id => $UserObj->Id }, ) if $UserObj->Id; } <%ARGS> $id => undef $CurrentPass => undef $Pass1 => undef $Pass2 => undef $Create=> undef