1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2016 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">
97 <&|/l&>Extra info</&>:
99 <textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo//$ARGS{FreeformContactInfo}//''%></textarea>
101 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Identity', InTable => 1 &>
107 <&| /Widgets/TitleBox, title => loc('Customers') &>
108 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
112 <&| /Widgets/TitleBox, title => loc('Access control'), class => 'user-info-access-control' &>
113 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
114 <input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <% ($UserObj->Id && $UserObj->Disabled) ? '' : 'checked="checked"' |n%> />
115 <label for="Enabled"><&|/l&>Let this user access RT</&></label><br />
118 % my $PrivilegedChecked = ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $ARGS{Privileged})) ? 'checked="checked"' : '';
119 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
120 <input type="checkbox" class="checkbox" id="Privileged" name="Privileged" value="1" <%$PrivilegedChecked|n%> />
121 <label for="Privileged"><&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)</label><br />
123 <& /Elements/EditPassword,
125 Name => [qw(CurrentPass Pass1 Pass2)],
128 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
131 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
134 <td valign="top" class="boxcontainer">
135 <&| /Widgets/TitleBox, title => loc('Location'), class => 'user-info-location' &>
137 <tr><td align="right">
138 <&|/l&>Organization</&>:
140 <input name="Organization" value="<%$UserObj->Organization//$ARGS{Organization}//''%>" />
142 <tr><td align="right">
145 <input name="Address1" value="<%$UserObj->Address1//$ARGS{Address1}//''%>" />
147 <tr><td align="right">
150 <input name="Address2" value="<%$UserObj->Address2//$ARGS{Address2}//''%>" />
152 <tr><td align="right">
155 <input name="City" value="<%$UserObj->City//$ARGS{City}//''%>" size="14" />
158 <tr><td align="right">
161 <input name="State" value="<%$UserObj->State//$ARGS{State}//''%>" size="3" />
164 <tr><td align="right">
167 <input name="Zip" value="<%$UserObj->Zip//$ARGS{Zip}//''%>" size="9" />
169 <tr><td align="right">
172 <input name="Country" value="<%$UserObj->Country//$ARGS{Country}//''%>" />
175 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
180 <&| /Widgets/TitleBox, title => loc('Phone numbers'), class => 'user-info-phones' &>
182 <tr><td align="right">
183 <&|/l&>Residence</&>:
185 <input name="HomePhone" value="<%$UserObj->HomePhone//$ARGS{HomePhone}//''%>" size="13" /><br />
187 <tr><td align="right">
190 <input name="WorkPhone" value="<%$UserObj->WorkPhone//$ARGS{WorkPhone}//''%>" size="13" /><br />
192 <tr><td align="right">
195 <input name="MobilePhone" value="<%$UserObj->MobilePhone//$ARGS{MobilePhone}//''%>" size="13" /><br />
197 <tr><td align="right">
200 <input name="PagerPhone" value="<%$UserObj->PagerPhone//$ARGS{PagerPhone}//''%>" size="13" /><br />
204 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
210 <& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
212 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
216 <&| /Widgets/TitleBox, title => loc('Comments about this user'), class => 'user-info-comments' &>
217 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments//$ARGS{Comments}//''%></textarea>
219 %if (!$Create && $UserObj->Privileged) {
221 <&| /Widgets/TitleBox, title => loc('Signature'), class => 'user-info-signature' &>
222 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature//$ARGS{Signature}//''%></textarea>
231 <& /Elements/Submit, Label => loc('Create') &>
233 <& /Elements/Submit, Label => loc('Save Changes') &>
239 my $UserObj = RT::User->new($session{'CurrentUser'});
240 +my ($title, @results);
244 $ARGS{Privileged} = $ARGS{Privileged} ? 1 : 0;
245 delete $ARGS{Privileged} unless $ARGS{SetPrivileged};
247 $ARGS{Disabled} = $ARGS{Enabled} ? 0 : 1;
248 delete $ARGS{Disabled} unless $ARGS{SetEnabled};
250 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
251 Organization RealName NickName Lang EmailEncoding WebEncoding
252 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
253 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
254 Address2 City State Zip Country
258 $title = loc("Create a new user");
259 } elsif ( defined $id && $id eq 'new') {
260 ( $val, $msg ) = $UserObj->Create(
261 (map {($_ => $ARGS{$_})} @fields),
262 Privileged => $ARGS{'Privileged'},
263 Disabled => $ARGS{'Disabled'},
268 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
269 $title = loc("Modify the user [_1]", $UserObj->Name);
271 push @results, loc('User could not be created: [_1]', $msg);
272 $title = loc("Create a new user");
276 $UserObj->Load($id) || $UserObj->Load($ARGS{Name})
277 || Abort("Couldn't load user '" . ( $ARGS{Name} || '') . "'");
279 $title = loc("Modify the user [_1]", $UserObj->Name);
281 $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
283 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
286 push (@results,@fieldresults);
287 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
289 #deal with freeside customer links
290 push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
292 if ( defined $ARGS{Privileged} and $ARGS{Privileged} != ($UserObj->Privileged || 0) ) {
293 my ($code, $msg) = $UserObj->SetPrivileged($ARGS{Privileged});
294 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
297 if ( defined $ARGS{Disabled} and $ARGS{Disabled} != $UserObj->Disabled ) {
298 my ($code, $msg) = $UserObj->SetDisabled($ARGS{Disabled});
303 if ( $UserObj->Id ) {
304 # Deal with Password field
305 my ($status, $msg) = $UserObj->SafeSetPassword(
306 Current => $CurrentPass,
308 Confirmation => $Pass2,
312 if ( $id eq 'new' && !$status ) {
313 push @results, loc("A password was not set, so user won't be able to login.");
317 # This code does automatic redirection if any updates happen.
318 MaybeRedirectForResults(
319 Actions => \@results,
320 Arguments => { id => $UserObj->Id },
328 $CurrentPass => undef
332 $OnlySearchForCustomers => undef
333 $OnlySearchForServices => undef
334 $CustomerString => undef
335 $ServiceString => undef