1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2013 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">
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') &>
66 <tr><td align="right">
69 <input name="Name" value="<%$UserObj->Name||$Name||''%>" /> <strong><&|/l&>(required)</&></strong>
71 <tr><td align="right">
74 <input name="EmailAddress" value="<%$UserObj->EmailAddress||$EmailAddress||''%>" />
76 <tr><td align="right">
79 <input name="RealName" value="<%$UserObj->RealName||$RealName||''%>" />
81 <tr><td align="right">
84 <input name="NickName" value="<%$UserObj->NickName||$NickName||''%>" />
86 <tr><td align="right">
87 <&|/l&>Unix login</&>:
89 <input name="Gecos" value="<%$UserObj->Gecos||$Gecos||''%>" />
91 <tr><td align="right">
94 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang||$Lang &>
96 <tr><td align="right">
97 <&|/l&>Extra info</&>:
99 <textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo||$FreeformContactInfo||''%></textarea>
104 <&| /Widgets/TitleBox, title => loc('Access control') &>
105 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
106 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
107 <&|/l&>Let this user access RT</&><br />
110 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
111 <input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked||''%> /> <&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)<br />
113 <& /Elements/EditPassword,
115 Name => [qw(CurrentPass Pass1 Pass2)],
118 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
121 <td valign="top" class="boxcontainer">
122 <&| /Widgets/TitleBox, title => loc('Location') &>
124 <tr><td align="right">
125 <&|/l&>Organization</&>:
127 <input name="Organization" value="<%$UserObj->Organization||$Organization||''%>" />
129 <tr><td align="right">
132 <input name="Address1" value="<%$UserObj->Address1||$Address1||''%>" />
134 <tr><td align="right">
137 <input name="Address2" value="<%$UserObj->Address2||$Address2||''%>" />
139 <tr><td align="right">
142 <input name="City" value="<%$UserObj->City||$City||''%>" size="14" />
145 <tr><td align="right">
148 <input name="State" value="<%$UserObj->State||$State||''%>" size="3" />
151 <tr><td align="right">
154 <input name="Zip" value="<%$UserObj->Zip||$Zip||''%>" size="9" />
156 <tr><td align="right">
159 <input name="Country" value="<%$UserObj->Country||$Country||''%>" />
164 <&| /Widgets/TitleBox, title => loc('Phone numbers') &>
166 <tr><td align="right">
167 <&|/l&>Residence</&>:
169 <input name="HomePhone" value="<%$UserObj->HomePhone||$HomePhone||''%>" size="13" /><br />
171 <tr><td align="right">
174 <input name="WorkPhone" value="<%$UserObj->WorkPhone||$WorkPhone||''%>" size="13" /><br />
176 <tr><td align="right">
179 <input name="MobilePhone" value="<%$UserObj->MobilePhone||$MobilePhone||''%>" size="13" /><br />
181 <tr><td align="right">
184 <input name="PagerPhone" value="<%$UserObj->PagerPhone||$PagerPhone||''%>" size="13" /><br />
190 <&| /Widgets/TitleBox, title => loc('Custom Fields') &>
192 % my $CFs = $UserObj->CustomFields;
193 % while (my $CF = $CFs->Next) {
194 <tr valign="top"><td align="right">
195 <% loc($CF->Name) %>:
197 % if ($UserObj->id) {
198 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
200 <& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User--CustomField-', CustomField => $CF &>
206 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
210 <&| /Widgets/TitleBox, title => loc('Comments about this user') &>
211 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments||$Comments||''%></textarea>
213 %if (!$Create && $UserObj->Privileged) {
215 <&| /Widgets/TitleBox, title => loc('Signature') &>
216 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature||$Signature||''%></textarea>
225 <& /Elements/Submit, Label => loc('Create') &>
227 <& /Elements/Submit, Label => loc('Save Changes') &>
233 my $UserObj = RT::User->new($session{'CurrentUser'});
234 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
239 $title = loc("Create a new user");
243 if ( defined $id && $id eq 'new') {
244 ( $val, $msg ) = $UserObj->Create(
246 EmailAddress => $ARGS{'EmailAddress'},
247 Name => $ARGS{'Name'},
248 Comments => $ARGS{'Comments'},
249 Signature => $ARGS{'Signature'},
250 EmailAddress => $ARGS{'EmailAddress'},
251 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
252 Organization => $ARGS{'Organization'},
253 RealName => $ARGS{'RealName'},
254 NickName => $ARGS{'NickName'},
255 Lang => $ARGS{'Lang'},
256 EmailEncoding => $ARGS{'EmailEncoding'},
257 WebEncoding => $ARGS{'WebEncoding'},
258 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
259 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
260 Gecos => $ARGS{'Gecos'},
261 ExternalAuthId => $ARGS{'ExternalAuthId'},
262 AuthSystem => $ARGS{'AuthSystem'},
263 HomePhone => $ARGS{'HomePhone'},
264 WorkPhone => $ARGS{'WorkPhone'},
265 MobilePhone => $ARGS{'MobilePhone'},
266 PagerPhone => $ARGS{'PagerPhone'},
267 Address1 => $ARGS{'Address1'},
268 Address2 => $ARGS{'Address2'},
269 City => $ARGS{'City'},
270 State => $ARGS{'State'},
272 Country => $ARGS{'Country'},
273 Privileged => $ARGS{'Privileged'},
274 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
279 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
281 push @results, loc('User could not be created: [_1]', $msg);
284 $UserObj->Load($id) || $UserObj->Load($Name)
285 || Abort("Couldn't load user '" . ( $Name || '') . "'");
286 $val = $UserObj->Id();
290 $title = loc("Modify the user [_1]", $UserObj->Name);
293 # If the create failed
295 $title = loc("Create a new user");
301 $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
304 # If we have a user to modify, lets try.
305 if ($UserObj->Id && $id ne 'new') {
307 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
308 Organization RealName NickName Lang EmailEncoding WebEncoding
309 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
310 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
311 Address2 City State Zip Country
314 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
317 push (@results,@fieldresults);
318 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
321 # {{{ Deal with special fields: Privileged, Enabled
322 if ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
323 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
324 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
327 #we're asking about enabled on the web page but really care about disabled.
328 $Disabled = $Enabled ? 0 : 1;
330 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
331 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
339 my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
340 if ( $UserObj->Id ) {
341 # Deal with Password field
342 my ($status, $msg) = $UserObj->SafeSetPassword(
343 Current => $CurrentPass,
345 Confirmation => $Pass2,
349 if ( $id eq 'new' && !$status ) {
350 push @results, loc("A password was not set, so user won't be able to login.");
355 # Do some setup for the ui
356 unless ( $UserObj->id && $UserObj->Disabled ) {
357 $EnabledChecked = 'checked="checked"';
360 if ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $Privileged)) {
361 $PrivilegedChecked = 'checked="checked"';
364 # This code does automatic redirection if any updates happen.
365 MaybeRedirectForResults(
366 Actions => \@results,
367 Arguments => { id => $UserObj->Id },
378 $EmailAddress => undef
379 $FreeformContactInfo => undef
380 $Organization => undef
384 $SetPrivileged => undef
388 $EmailEncoding => undef
389 $WebEncoding => undef
390 $ExternalContactInfoId => undef
391 $ContactInfoSystem => undef
393 $ExternalAuthId => undef
397 $MobilePhone => undef
405 $CurrentPass => undef