1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Admin/Elements/Header, Title => $title &>
51 <& /Elements/ListActions, actions => \@results &>
53 <form action="<%RT->Config->Get('WebPath')%>/Admin/Users/Modify.html" method="post" enctype="multipart/form-data" name="<% $Create ? 'UserCreate': 'UserModify' %>">
55 <input type="hidden" class="hidden" name="id" value="new" />
57 <input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
59 <table width="100%" border="0">
62 <td valign="top" class="boxcontainer">
63 <&| /Widgets/TitleBox, title => loc('Identity'), class => 'user-info-identity' &>
66 <tr><td align="right">
69 <input name="Name" value="<%$UserObj->Name//$ARGS{Name}//''%>" /> <strong><&|/l&>(required)</&></strong>
71 <tr><td align="right">
74 <input name="EmailAddress" value="<%$UserObj->EmailAddress//$ARGS{EmailAddress}//''%>" />
76 <tr><td align="right">
79 <input name="RealName" value="<%$UserObj->RealName//$ARGS{RealName}//''%>" />
81 <tr><td align="right">
84 <input name="NickName" value="<%$UserObj->NickName//$ARGS{NickName}//''%>" />
86 <tr><td align="right">
87 <&|/l&>Unix login</&>:
89 <input name="Gecos" value="<%$UserObj->Gecos//$ARGS{Gecos}//''%>" />
91 <tr><td align="right">
94 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang//$ARGS{Lang} &>
96 <tr><td align="right"><&|/l&>Timezone</&>:
98 <& /Elements/SelectTimezone, Name => 'Timezone', Default => $UserObj->Timezone &>
100 <tr><td align="right">
101 <&|/l&>Extra info</&>:
103 <textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo//$ARGS{FreeformContactInfo}//''%></textarea>
105 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Identity', InTable => 1 &>
111 <&| /Widgets/TitleBox, title => loc('Customers') &>
112 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
116 <&| /Widgets/TitleBox, title => loc('Access control'), class => 'user-info-access-control' &>
117 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
118 <input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <% ($UserObj->Id && $UserObj->Disabled) ? '' : 'checked="checked"' |n%> />
119 <label for="Enabled"><&|/l&>Let this user access RT</&></label><br />
122 % my $PrivilegedChecked = ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $ARGS{Privileged})) ? 'checked="checked"' : '';
123 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
124 <input type="checkbox" class="checkbox" id="Privileged" name="Privileged" value="1" <%$PrivilegedChecked|n%> />
125 <label for="Privileged"><&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)</label><br />
127 <& /Elements/EditPassword,
129 Name => [qw(CurrentPass Pass1 Pass2)],
132 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
135 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
138 <td valign="top" class="boxcontainer">
139 <&| /Widgets/TitleBox, title => loc('Location'), class => 'user-info-location' &>
141 <tr><td align="right">
142 <&|/l&>Organization</&>:
144 <input name="Organization" value="<%$UserObj->Organization//$ARGS{Organization}//''%>" />
146 <tr><td align="right">
149 <input name="Address1" value="<%$UserObj->Address1//$ARGS{Address1}//''%>" />
151 <tr><td align="right">
154 <input name="Address2" value="<%$UserObj->Address2//$ARGS{Address2}//''%>" />
156 <tr><td align="right">
159 <input name="City" value="<%$UserObj->City//$ARGS{City}//''%>" size="14" />
162 <tr><td align="right">
165 <input name="State" value="<%$UserObj->State//$ARGS{State}//''%>" size="3" />
168 <tr><td align="right">
171 <input name="Zip" value="<%$UserObj->Zip//$ARGS{Zip}//''%>" size="9" />
173 <tr><td align="right">
176 <input name="Country" value="<%$UserObj->Country//$ARGS{Country}//''%>" />
179 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
184 <&| /Widgets/TitleBox, title => loc('Phone numbers'), class => 'user-info-phones' &>
186 <tr><td align="right">
187 <&|/l&>Residence</&>:
189 <input name="HomePhone" value="<%$UserObj->HomePhone//$ARGS{HomePhone}//''%>" size="13" /><br />
191 <tr><td align="right">
194 <input name="WorkPhone" value="<%$UserObj->WorkPhone//$ARGS{WorkPhone}//''%>" size="13" /><br />
196 <tr><td align="right">
199 <input name="MobilePhone" value="<%$UserObj->MobilePhone//$ARGS{MobilePhone}//''%>" size="13" /><br />
201 <tr><td align="right">
204 <input name="PagerPhone" value="<%$UserObj->PagerPhone//$ARGS{PagerPhone}//''%>" size="13" /><br />
208 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
214 <& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
216 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
220 <&| /Widgets/TitleBox, title => loc('Comments about this user'), class => 'user-info-comments' &>
221 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments//$ARGS{Comments}//''%></textarea>
223 %if (!$Create && $UserObj->Privileged) {
225 <&| /Widgets/TitleBox, title => loc('Signature'), class => 'user-info-signature' &>
226 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature//$ARGS{Signature}//''%></textarea>
235 <& /Elements/Submit, Label => loc('Create') &>
237 <& /Elements/Submit, Label => loc('Save Changes') &>
243 my $UserObj = RT::User->new($session{'CurrentUser'});
244 +my ($title, @results);
248 $ARGS{Privileged} = $ARGS{Privileged} ? 1 : 0;
249 delete $ARGS{Privileged} unless $ARGS{SetPrivileged};
251 $ARGS{Disabled} = $ARGS{Enabled} ? 0 : 1;
252 delete $ARGS{Disabled} unless $ARGS{SetEnabled};
254 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
255 Organization RealName NickName Lang EmailEncoding WebEncoding
256 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
257 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
258 Address2 City State Zip Country Timezone
262 $title = loc("Create a new user");
263 } elsif ( defined $id && $id eq 'new') {
264 ( $val, $msg ) = $UserObj->Create(
265 (map {($_ => $ARGS{$_})} @fields),
266 Privileged => $ARGS{'Privileged'},
267 Disabled => $ARGS{'Disabled'},
272 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
273 $title = loc("Modify the user [_1]", $UserObj->Name);
275 push @results, loc('User could not be created: [_1]', $msg);
276 $title = loc("Create a new user");
280 $UserObj->Load($id) || $UserObj->Load($ARGS{Name})
281 || Abort("Couldn't load user '" . ( $ARGS{Name} || '') . "'");
283 $title = loc("Modify the user [_1]", $UserObj->Name);
285 $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
287 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
290 push (@results,@fieldresults);
291 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
293 #deal with freeside customer links
294 push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
296 if ( defined $ARGS{Privileged} and $ARGS{Privileged} != ($UserObj->Privileged || 0) ) {
297 my ($code, $msg) = $UserObj->SetPrivileged($ARGS{Privileged});
298 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
301 if ( defined $ARGS{Disabled} and $ARGS{Disabled} != $UserObj->Disabled ) {
302 my ($code, $msg) = $UserObj->SetDisabled($ARGS{Disabled});
307 if ( $UserObj->Id ) {
308 # Deal with Password field
309 my ($status, $msg) = $UserObj->SafeSetPassword(
310 Current => $CurrentPass,
312 Confirmation => $Pass2,
316 if ( $id eq 'new' && !$status ) {
317 push @results, loc("A password was not set, so user won't be able to login.");
321 # This code does automatic redirection if any updates happen.
322 MaybeRedirectForResults(
323 Actions => \@results,
324 Arguments => { id => $UserObj->Id },
332 $CurrentPass => undef
336 $OnlySearchForCustomers => undef
337 $OnlySearchForServices => undef
338 $CustomerString => undef
339 $ServiceString => undef