import rt 3.0.12
[freeside.git] / rt / html / Admin / Users / Modify.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
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
10 %# from www.gnu.org.
11 %# 
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.
16 %# 
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.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <& /Admin/Elements/Header, Title => $title  &>
25 <& /Admin/Elements/UserTabs, 
26     id => $id, 
27     UserObj => $UserObj,
28     current_tab => $current_tab, 
29     Title => $title &>
30
31 <& /Elements/ListActions, actions => \@results &>
32
33 <FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST>
34 %if ($Create) {
35 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
36 % } else {
37 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
38 % }
39 <TABLE WIDTH=100% BORDER=0>
40 <TR>
41
42 <TD VALIGN=TOP ROWSPAN=2>
43 <& /Elements/TitleBoxStart, title => loc('Identity') &>
44
45 <TABLE>
46 <TR><TD ALIGN="RIGHT">
47 <&|/l&>Username</&>:
48 </TD><TD>
49 <input name="Name" value="<%$UserObj->Name%>"> <b><&|/l&>(required)</&></b>
50 </TD></TR>
51 <TR><TD ALIGN="RIGHT">
52 <&|/l&>Email</&>:
53 </TD><TD>
54 <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
55 </TD></TR>
56 <TR><TD ALIGN="RIGHT">
57 <&|/l&>Real Name</&>: 
58 </TD><TD>
59 <input name="RealName" value="<%$UserObj->RealName%>">
60 </TD></TR>
61 <TR><TD ALIGN="RIGHT">
62 <&|/l&>Nickname</&>: 
63 </TD><TD>
64 <input name="NickName" value="<%$UserObj->NickName%>">
65 </TD></TR>
66 <TR><TD ALIGN="RIGHT">
67 <&|/l&>Unix login</&>: 
68 </TD><TD>
69 <input name="Gecos" value="<%$UserObj->Gecos%>">
70 </TD></TR>
71 <TR><TD ALIGN="RIGHT">
72 <&|/l&>Extra info</&>: 
73 </TD><TD>
74 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
75 </TD></TR>
76 </TABLE>
77 <& /Elements/TitleBoxEnd &>
78 <br>
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>
83
84
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>
87                     
88 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
89 <TABLE>
90 <TR>
91 <TD ALIGN=RIGHT>
92 <&|/l&>New Password</&>:
93 </TD>
94 <TD ALIGN=LEFT>
95 <input type=password name="Pass1">
96 </TD>
97 </TR>
98 <TR><TD ALIGN=RIGHT>
99 <&|/l&>Retype Password</&>:
100 </TD>
101 <TD>
102 <input type=password name="Pass2">
103 </TD>
104 </TR>
105 </TABLE>
106 % }
107 <& /Elements/TitleBoxEnd &>
108 </TD>
109 </TR>
110 <TR>
111
112 <TD VALIGN=TOP>
113 <& /Elements/TitleBoxStart, title => loc('Location') &>
114 <TABLE>
115 <TR><TD ALIGN="RIGHT">
116 <&|/l&>Organization</&>: 
117 </TD><TD>
118 <input name="Organization" value="<%$UserObj->Organization%>">
119 </TD></TR>
120 <TR><TD ALIGN="RIGHT">
121 <&|/l&>Address1</&>: 
122 </TD><TD>
123 <input name="Address1" value="<%$UserObj->Address1%>">
124 </TD></TR>
125 <TR><TD ALIGN="RIGHT">
126 <&|/l&>Address2</&>: 
127 </TD><TD>
128 <input name="Address2" value="<%$UserObj->Address2%>">
129 </TD></TR>
130 <TR><TD ALIGN="RIGHT">
131 <&|/l&>City</&>: 
132 </TD><TD>
133 <input name="City" value="<%$UserObj->City%>" size=14>
134
135 </TD></TR>
136 <TR><TD ALIGN="RIGHT">
137 <&|/l&>State</&>: 
138 </TD><TD>
139 <input name="State" value="<%$UserObj->State%>" size=3>
140
141 </TD></TR>
142 <TR><TD ALIGN="RIGHT">
143 <&|/l&>Zip</&>: 
144 </TD><TD>
145 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
146 </TD></TR>
147 <TR><TD ALIGN="RIGHT">
148 <&|/l&>Country</&>: 
149 </TD><TD>
150 <input name="Country" value="<%$UserObj->Country%>">
151 </TD></TR>
152 </TABLE>
153 <& /Elements/TitleBoxEnd &>
154 <br>
155 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
156 <TABLE>
157 <TR><TD ALIGN="RIGHT">
158 <&|/l&>Residence</&>: 
159 </TD><TD>
160 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
161 </TD></TR>
162 <TR><TD ALIGN="RIGHT">
163 <&|/l&>Work</&>: 
164 </TD><TD>
165 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
166 </TD></TR>
167 <TR><TD ALIGN="RIGHT">
168 <&|/l&>Mobile</&>: 
169 </TD><TD>
170 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
171 </TD></TR>
172 <TR><TD ALIGN="RIGHT">
173 <&|/l&>Pager</&>: 
174 </TD><TD>
175 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
176 <& /Elements/TitleBoxEnd &>
177 </TD>
178
179 <TR>
180 </TR>
181 </TABLE>
182 <TR>
183 <TD colspan="2">
184 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
185 <TEXTAREA name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%>
186 </TEXTAREA>
187 <& /Elements/TitleBoxEnd &>
188 %if ($UserObj->Privileged) {
189 <BR>
190 <& /Elements/TitleBoxStart, title => loc('Signature') &>
191 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
192 <%$UserObj->Signature%></TEXTAREA>
193 <& /Elements/TitleBoxEnd &>
194 % }
195
196 </TD>
197 </TR>
198 </TABLE>
199
200 <& /Elements/Submit, Label => loc('Save Changes') &>
201 </form>
202
203 <%INIT>
204
205 my $current_tab;
206 my $UserObj = new RT::User($session{'CurrentUser'});
207 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
208
209 my ($val, $msg);
210
211 if ($Create) {
212     $current_tab = 'Admin/Users/Modify.html?Create=1';
213     $title = loc("Create a new user");
214
215 else {
216
217     $current_tab = 'Admin/Users/Modify.html?id='.$id;
218     if ($id eq 'new') {
219         ($val, $msg) = $UserObj->Create( Name => $Name,
220                                          EmailAddress => $ARGS{'EmailAddress'}
221                                        );
222         if ($val) {
223                 push @results, $msg;
224         } else {
225                 push @results, loc('User could not be created: [_1]', $msg);
226         }       
227
228         # set the id, so the the menu will have the right info
229         $id = $UserObj->Id;     
230
231     } else {
232         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
233         $val = $UserObj->Id();
234     }
235
236     if ($val) {
237         $title = loc("Modify the user [_1]", $UserObj->Name);
238     }   
239
240     # If the create failed
241     else {
242         $title = loc("Create a new user");
243         $Create = 1;
244     }    
245
246 }
247
248
249
250
251 # If we have a user to modify, lets try. 
252 if ($UserObj->Id) {
253     
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 
259                    );
260     
261     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
262                                             Object => $UserObj,
263                                             ARGSRef => \%ARGS );
264     push (@results,@fieldresults);
265
266
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));
271 }
272
273 #we're asking about enabled on the web page but really care about disabled.
274 if ($Enabled == 1) {
275     $Disabled = 0;
276 }       
277 else {
278     $Disabled = 1;
279 }
280 if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
281     my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
282     push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
283 }
284
285
286 #TODO: make this report errors properly
287 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
288     my ($code, $msg);
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.");
293 }
294
295 # }}}
296 }
297
298
299 # {{{ Do some setup for the ui
300 unless ($UserObj->Disabled()) {
301     $EnabledChecked ="CHECKED";
302 }
303
304 if ($UserObj->Privileged()) {  
305     $PrivilegedChecked = "CHECKED";
306 }
307
308 # }}}
309 </%INIT>
310
311
312 <%ARGS>
313 $id => undef
314 $Name  => undef
315 $Comments  => undef
316 $Signature  => undef
317 $EmailAddress  => undef
318 $FreeformContactInfo => undef
319 $Organization  => undef
320 $RealName  => undef
321 $NickName  => undef
322 $Privileged => undef
323 $SetPrivileged => undef
324 $Enabled => undef
325 $SetEnabled => undef
326 $Lang  => undef
327 $EmailEncoding  => undef
328 $WebEncoding => undef
329 $ExternalContactInfoId  => undef
330 $ContactInfoSystem  => undef
331 $Gecos => undef
332 $ExternalAuthId  => undef
333 $AuthSystem  => undef
334 $HomePhone => undef
335 $WorkPhone  => undef
336 $MobilePhone  => undef
337 $PagerPhone  => undef
338 $Address1 => undef
339 $Address2  => undef
340 $City  => undef
341 $State  => undef
342 $Zip  => undef
343 $Country => undef
344 $Pass1 => undef
345 $Pass2=> undef
346 $Create=> undef
347 </%ARGS>