import of rt 3.0.9
[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_subtab => $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 &>
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
252
253 # If we have a user to modify, lets try. 
254 if ($UserObj->Id) {
255     
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 
261                    );
262     
263     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
264                                             Object => $UserObj,
265                                             ARGSRef => \%ARGS );
266     push (@results,@fieldresults);
267
268
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));
273 }
274
275 #we're asking about enabled on the web page but really care about disabled.
276 if ($Enabled == 1) {
277     $Disabled = 0;
278 }       
279 else {
280     $Disabled = 1;
281 }
282 if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
283     my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
284     push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
285 }
286
287
288 #TODO: make this report errors properly
289 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
290     my ($code, $msg);
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.");
295 }
296
297 # }}}
298 }
299
300
301 # {{{ Do some setup for the ui
302 unless ($UserObj->Disabled()) {
303     $EnabledChecked ="CHECKED";
304 }
305
306 if ($UserObj->Privileged()) {  
307     $PrivilegedChecked = "CHECKED";
308 }
309
310 # }}}
311 </%INIT>
312
313
314 <%ARGS>
315 $id => undef
316 $Name  => undef
317 $Comments  => undef
318 $Signature  => undef
319 $EmailAddress  => undef
320 $FreeformContactInfo => undef
321 $Organization  => undef
322 $RealName  => undef
323 $NickName  => undef
324 $Privileged => undef
325 $SetPrivileged => undef
326 $Enabled => undef
327 $SetEnabled => undef
328 $Lang  => undef
329 $EmailEncoding  => undef
330 $WebEncoding => undef
331 $ExternalContactInfoId  => undef
332 $ContactInfoSystem  => undef
333 $Gecos => undef
334 $ExternalAuthId  => undef
335 $AuthSystem  => undef
336 $HomePhone => undef
337 $WorkPhone  => undef
338 $MobilePhone  => undef
339 $PagerPhone  => undef
340 $Address1 => undef
341 $Address2  => undef
342 $City  => undef
343 $State  => undef
344 $Zip  => undef
345 $Country => undef
346 $Pass1 => undef
347 $Pass2=> undef
348 $Create=> undef
349 </%ARGS>