3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
24 <& /Admin/Elements/Header, Title => $title &>
25 <& /Admin/Elements/UserTabs,
28 current_tab => $current_tab,
31 <& /Elements/ListActions, actions => \@results &>
33 <FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST>
35 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
37 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
39 <TABLE WIDTH=100% BORDER=0>
42 <TD VALIGN=TOP ROWSPAN=2>
43 <& /Elements/TitleBoxStart, title => loc('Identity') &>
46 <TR><TD ALIGN="RIGHT">
49 <input name="Name" value="<%$UserObj->Name%>"> <b><&|/l&>(required)</&></b>
51 <TR><TD ALIGN="RIGHT">
54 <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
56 <TR><TD ALIGN="RIGHT">
59 <input name="RealName" value="<%$UserObj->RealName%>">
61 <TR><TD ALIGN="RIGHT">
64 <input name="NickName" value="<%$UserObj->NickName%>">
66 <TR><TD ALIGN="RIGHT">
67 <&|/l&>Unix login</&>:
69 <input name="Gecos" value="<%$UserObj->Gecos%>">
71 <TR><TD ALIGN="RIGHT">
72 <&|/l&>Extra info</&>:
74 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
77 <& /Elements/TitleBoxEnd &>
79 <& /Elements/TitleBoxStart, title => loc('Access control') &>
80 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
81 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
82 <&|/l&>Let this user access RT</&><BR>
85 <INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
86 <INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> <&|/l&>Let this user be granted rights</&><BR>
88 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
92 <&|/l&>New Password</&>:
95 <input type=password name="Pass1">
99 <&|/l&>Retype Password</&>:
102 <input type=password name="Pass2">
107 <& /Elements/TitleBoxEnd &>
113 <& /Elements/TitleBoxStart, title => loc('Location') &>
115 <TR><TD ALIGN="RIGHT">
116 <&|/l&>Organization</&>:
118 <input name="Organization" value="<%$UserObj->Organization%>">
120 <TR><TD ALIGN="RIGHT">
123 <input name="Address1" value="<%$UserObj->Address1%>">
125 <TR><TD ALIGN="RIGHT">
128 <input name="Address2" value="<%$UserObj->Address2%>">
130 <TR><TD ALIGN="RIGHT">
133 <input name="City" value="<%$UserObj->City%>" size=14>
136 <TR><TD ALIGN="RIGHT">
139 <input name="State" value="<%$UserObj->State%>" size=3>
142 <TR><TD ALIGN="RIGHT">
145 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
147 <TR><TD ALIGN="RIGHT">
150 <input name="Country" value="<%$UserObj->Country%>">
153 <& /Elements/TitleBoxEnd &>
155 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
157 <TR><TD ALIGN="RIGHT">
158 <&|/l&>Residence</&>:
160 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
162 <TR><TD ALIGN="RIGHT">
165 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
167 <TR><TD ALIGN="RIGHT">
170 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
172 <TR><TD ALIGN="RIGHT">
175 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
176 <& /Elements/TitleBoxEnd &>
184 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
185 <TEXTAREA name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%>
187 <& /Elements/TitleBoxEnd &>
188 %if ($UserObj->Privileged) {
190 <& /Elements/TitleBoxStart, title => loc('Signature') &>
191 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
192 <%$UserObj->Signature%></TEXTAREA>
193 <& /Elements/TitleBoxEnd &>
200 <& /Elements/Submit, Label => loc('Save Changes') &>
206 my $UserObj = new RT::User($session{'CurrentUser'});
207 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
212 $current_tab = 'Admin/Users/Modify.html?Create=1';
213 $title = loc("Create a new user");
217 $current_tab = 'Admin/Users/Modify.html?id='.$id;
219 ($val, $msg) = $UserObj->Create( Name => $Name,
220 EmailAddress => $ARGS{'EmailAddress'}
225 push @results, loc('User could not be created: [_1]', $msg);
228 # set the id, so the the menu will have the right info
232 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
233 $val = $UserObj->Id();
237 $title = loc("Modify the user [_1]", $UserObj->Name);
240 # If the create failed
242 $title = loc("Create a new user");
251 # If we have a user to modify, lets try.
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
261 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
264 push (@results,@fieldresults);
267 # {{{ Deal with special fields: Privileged, Enabled and Password
268 if ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
269 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
270 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
273 #we're asking about enabled on the web page but really care about disabled.
280 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
281 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
282 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
286 #TODO: make this report errors properly
287 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
289 ($code, $msg) = $UserObj->SetPassword($Pass1);
290 push @results, loc('Password: [_1]', loc_fuzzy($msg));
291 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
292 push @results, loc("Passwords do not match.");
299 # {{{ Do some setup for the ui
300 unless ($UserObj->Disabled()) {
301 $EnabledChecked ="CHECKED";
304 if ($UserObj->Privileged()) {
305 $PrivilegedChecked = "CHECKED";
317 $EmailAddress => undef
318 $FreeformContactInfo => undef
319 $Organization => undef
323 $SetPrivileged => undef
327 $EmailEncoding => undef
328 $WebEncoding => undef
329 $ExternalContactInfoId => undef
330 $ContactInfoSystem => undef
332 $ExternalAuthId => undef
336 $MobilePhone => undef