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_subtab => $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 &>
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");
253 # If we have a user to modify, lets try.
256 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
257 Organization RealName NickName Lang EmailEncoding WebEncoding
258 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
259 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
260 Address2 City State Zip Country
263 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
266 push (@results,@fieldresults);
269 # {{{ Deal with special fields: Privileged, Enabled and Password
270 if ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
271 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
272 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
275 #we're asking about enabled on the web page but really care about disabled.
282 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
283 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
284 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
288 #TODO: make this report errors properly
289 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
291 ($code, $msg) = $UserObj->SetPassword($Pass1);
292 push @results, loc('Password: [_1]', loc_fuzzy($msg));
293 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
294 push @results, loc("Passwords do not match.");
301 # {{{ Do some setup for the ui
302 unless ($UserObj->Disabled()) {
303 $EnabledChecked ="CHECKED";
306 if ($UserObj->Privileged()) {
307 $PrivilegedChecked = "CHECKED";
319 $EmailAddress => undef
320 $FreeformContactInfo => undef
321 $Organization => undef
325 $SetPrivileged => undef
329 $EmailEncoding => undef
330 $WebEncoding => undef
331 $ExternalContactInfoId => undef
332 $ContactInfoSystem => undef
334 $ExternalAuthId => undef
338 $MobilePhone => undef