1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
6 %# <jesse@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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 %# CONTRIBUTION SUBMISSION POLICY:
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
45 %# END BPS TAGGED BLOCK }}}
46 <& /Admin/Elements/Header, Title => $title &>
47 <& /Admin/Elements/UserTabs,
50 current_tab => $current_tab,
53 <& /Elements/ListActions, actions => \@results &>
55 <FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
57 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
59 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
61 <TABLE WIDTH=100% BORDER=0>
64 <TD VALIGN=TOP class="boxcontainer">
65 <& /Elements/TitleBoxStart, title => loc('Identity') &>
68 <TR><TD ALIGN="RIGHT">
71 <input name="Name" value="<%$UserObj->Name%>"> <b><&|/l&>(required)</&></b>
73 <TR><TD ALIGN="RIGHT">
76 <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
78 <TR><TD ALIGN="RIGHT">
81 <input name="RealName" value="<%$UserObj->RealName%>">
83 <TR><TD ALIGN="RIGHT">
86 <input name="NickName" value="<%$UserObj->NickName%>">
88 <TR><TD ALIGN="RIGHT">
89 <&|/l&>Unix login</&>:
91 <input name="Gecos" value="<%$UserObj->Gecos%>">
93 <TR><TD ALIGN="RIGHT">
96 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
98 <TR><TD ALIGN="RIGHT">
99 <&|/l&>Extra info</&>:
101 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
104 <& /Elements/TitleBoxEnd &>
106 <& /Elements/TitleBoxStart, title => loc('Access control') &>
107 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
108 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
109 <&|/l&>Let this user access RT</&><BR>
112 <INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
113 <INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> <&|/l&>Let this user be granted rights</&><BR>
115 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
119 <&|/l&>New Password</&>:
122 <input type=password name="Pass1">
126 <&|/l&>Retype Password</&>:
129 <input type=password name="Pass2">
134 <& /Elements/TitleBoxEnd &>
137 <TD VALIGN=TOP class="boxcontainer">
138 <& /Elements/TitleBoxStart, title => loc('Location') &>
140 <TR><TD ALIGN="RIGHT">
141 <&|/l&>Organization</&>:
143 <input name="Organization" value="<%$UserObj->Organization%>">
145 <TR><TD ALIGN="RIGHT">
148 <input name="Address1" value="<%$UserObj->Address1%>">
150 <TR><TD ALIGN="RIGHT">
153 <input name="Address2" value="<%$UserObj->Address2%>">
155 <TR><TD ALIGN="RIGHT">
158 <input name="City" value="<%$UserObj->City%>" size=14>
161 <TR><TD ALIGN="RIGHT">
164 <input name="State" value="<%$UserObj->State%>" size=3>
167 <TR><TD ALIGN="RIGHT">
170 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
172 <TR><TD ALIGN="RIGHT">
175 <input name="Country" value="<%$UserObj->Country%>">
178 <& /Elements/TitleBoxEnd &>
180 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
182 <TR><TD ALIGN="RIGHT">
183 <&|/l&>Residence</&>:
185 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
187 <TR><TD ALIGN="RIGHT">
190 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
192 <TR><TD ALIGN="RIGHT">
195 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
197 <TR><TD ALIGN="RIGHT">
200 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
201 <& /Elements/TitleBoxEnd &>
208 <& /Elements/TitleBoxStart, title => loc('Custom Fields') &>
210 % my $CFs = $UserObj->CustomFields;
211 % while (my $CF = $CFs->Next) {
212 <TR VALIGN="TOP"><TD ALIGN="RIGHT">
215 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
221 <& /Elements/TitleBoxEnd &>
224 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
225 <TEXTAREA class="comments" name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%></TEXTAREA>
226 <& /Elements/TitleBoxEnd &>
227 %if ($UserObj->Privileged) {
229 <& /Elements/TitleBoxStart, title => loc('Signature') &>
230 <TEXTAREA class="signature" COLS=80 ROWS=5 name="Signature" WRAP=HARD><%$UserObj->Signature%></TEXTAREA>
231 <& /Elements/TitleBoxEnd &>
238 <& /Elements/Submit, Label => loc('Save Changes') &>
244 my $UserObj = new RT::User($session{'CurrentUser'});
245 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
250 $current_tab = 'Admin/Users/Modify.html?Create=1';
251 $title = loc("Create a new user");
255 $current_tab = 'Admin/Users/Modify.html?id='.$id;
257 ( $val, $msg ) = $UserObj->Create(
259 EmailAddress => $ARGS{'EmailAddress'},
260 Name => $ARGS{'Name'},
261 Comments => $ARGS{'Comments'},
262 Signature => $ARGS{'Signature'},
263 EmailAddress => $ARGS{'EmailAddress'},
264 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
265 Organization => $ARGS{'Organization'},
266 RealName => $ARGS{'RealName'},
267 NickName => $ARGS{'NickName'},
268 Lang => $ARGS{'Lang'},
269 EmailEncoding => $ARGS{'EmailEncoding'},
270 WebEncoding => $ARGS{'WebEncoding'},
271 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
272 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
273 Gecos => $ARGS{'Gecos'},
274 ExternalAuthId => $ARGS{'ExternalAuthId'},
275 AuthSystem => $ARGS{'AuthSystem'},
276 HomePhone => $ARGS{'HomePhone'},
277 WorkPhone => $ARGS{'WorkPhone'},
278 MobilePhone => $ARGS{'MobilePhone'},
279 PagerPhone => $ARGS{'PagerPhone'},
280 Address1 => $ARGS{'Address1'},
281 Address2 => $ARGS{'Address2'},
282 City => $ARGS{'City'},
283 State => $ARGS{'State'},
285 Country => $ARGS{'Country'},
286 Privileged => $ARGS{'Privileged'},
287 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
293 push @results, loc('User could not be created: [_1]', $msg);
296 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
297 $val = $UserObj->Id();
301 $title = loc("Modify the user [_1]", $UserObj->Name);
304 # If the create failed
306 $title = loc("Create a new user");
314 # If we have a user to modify, lets try.
315 if ($UserObj->Id && $id ne 'new') {
317 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
318 Organization RealName NickName Lang EmailEncoding WebEncoding
319 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
320 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
321 Address2 City State Zip Country
324 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
327 push (@results,@fieldresults);
328 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
331 # {{{ Deal with special fields: Privileged, Enabled
332 if ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
333 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
334 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
337 #we're asking about enabled on the web page but really care about disabled.
338 $Disabled = $Enabled ? 0 : 1;
340 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
341 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
342 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
349 if ( $UserObj->Id ) {
350 my $password_not_set;
351 # Deal with Password field
352 if ( !$Pass1 and !$Pass2 ) {
353 $password_not_set = 1;
354 } elsif ( $Pass1 ne $Pass2 ) {
355 $password_not_set = 1;
356 push @results, loc("Passwords do not match.");
357 } elsif ( $Pass1 eq $Pass2 and !$UserObj->IsPassword($Pass1) ) {
358 my ($code, $msg) = $UserObj->SetPassword($Pass1);
359 push @results, loc_fuzzy($msg);
360 $password_not_set = 1 unless $code;
362 if ($id eq 'new' and $password_not_set) {
363 push @results, loc("A password was not set, so user won't be able to login.");
368 # {{{ Do some setup for the ui
369 unless ($UserObj->Disabled()) {
370 $EnabledChecked ="CHECKED";
373 if ($UserObj->Privileged()) {
374 $PrivilegedChecked = "CHECKED";
379 # set the id, so the the menu will have the right info, this needs to
380 # be done here to avoid creating and then modifying a user
391 $EmailAddress => undef
392 $FreeformContactInfo => undef
393 $Organization => undef
397 $SetPrivileged => undef
401 $EmailEncoding => undef
402 $WebEncoding => undef
403 $ExternalContactInfoId => undef
404 $ContactInfoSystem => undef
406 $ExternalAuthId => undef
410 $MobilePhone => undef