This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / rt / html / Admin / Users / Modify.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
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
16 %# from www.gnu.org.
17 %# 
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.
22 %# 
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.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
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.)
35 %# 
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.
44 %# 
45 %# END BPS TAGGED BLOCK }}}
46 <& /Admin/Elements/Header, Title => $title  &>
47 <& /Admin/Elements/UserTabs, 
48     id => $id, 
49     UserObj => $UserObj,
50     current_tab => $current_tab, 
51     Title => $title &>
52
53 <& /Elements/ListActions, actions => \@results &>
54
55 <FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
56 %if ($Create) {
57 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
58 % } else {
59 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
60 % }
61 <TABLE WIDTH=100% BORDER=0>
62 <TR>
63
64 <TD VALIGN=TOP class="boxcontainer">
65 <& /Elements/TitleBoxStart, title => loc('Identity') &>
66
67 <TABLE>
68 <TR><TD ALIGN="RIGHT">
69 <&|/l&>Username</&>:
70 </TD><TD>
71 <input name="Name" value="<%$UserObj->Name%>"> <b><&|/l&>(required)</&></b>
72 </TD></TR>
73 <TR><TD ALIGN="RIGHT">
74 <&|/l&>Email</&>:
75 </TD><TD>
76 <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
77 </TD></TR>
78 <TR><TD ALIGN="RIGHT">
79 <&|/l&>Real Name</&>: 
80 </TD><TD>
81 <input name="RealName" value="<%$UserObj->RealName%>">
82 </TD></TR>
83 <TR><TD ALIGN="RIGHT">
84 <&|/l&>Nickname</&>: 
85 </TD><TD>
86 <input name="NickName" value="<%$UserObj->NickName%>">
87 </TD></TR>
88 <TR><TD ALIGN="RIGHT">
89 <&|/l&>Unix login</&>: 
90 </TD><TD>
91 <input name="Gecos" value="<%$UserObj->Gecos%>">
92 </TD></TR>
93 <TR><TD ALIGN="RIGHT">
94 <&|/l&>Language</&>: 
95 </TD><TD>
96 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
97 </TD></TR>
98 <TR><TD ALIGN="RIGHT">
99 <&|/l&>Extra info</&>: 
100 </TD><TD>
101 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
102 </TD></TR>
103 </TABLE>
104 <& /Elements/TitleBoxEnd &>
105 <br>
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>
110
111
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>
114                     
115 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
116 <TABLE>
117 <TR>
118 <TD ALIGN=RIGHT>
119 <&|/l&>New Password</&>:
120 </TD>
121 <TD ALIGN=LEFT>
122 <input type=password name="Pass1">
123 </TD>
124 </TR>
125 <TR><TD ALIGN=RIGHT>
126 <&|/l&>Retype Password</&>:
127 </TD>
128 <TD>
129 <input type=password name="Pass2">
130 </TD>
131 </TR>
132 </TABLE>
133 % }
134 <& /Elements/TitleBoxEnd &>
135 </TD>
136
137 <TD VALIGN=TOP class="boxcontainer">
138 <& /Elements/TitleBoxStart, title => loc('Location') &>
139 <TABLE>
140 <TR><TD ALIGN="RIGHT">
141 <&|/l&>Organization</&>: 
142 </TD><TD>
143 <input name="Organization" value="<%$UserObj->Organization%>">
144 </TD></TR>
145 <TR><TD ALIGN="RIGHT">
146 <&|/l&>Address1</&>: 
147 </TD><TD>
148 <input name="Address1" value="<%$UserObj->Address1%>">
149 </TD></TR>
150 <TR><TD ALIGN="RIGHT">
151 <&|/l&>Address2</&>: 
152 </TD><TD>
153 <input name="Address2" value="<%$UserObj->Address2%>">
154 </TD></TR>
155 <TR><TD ALIGN="RIGHT">
156 <&|/l&>City</&>: 
157 </TD><TD>
158 <input name="City" value="<%$UserObj->City%>" size=14>
159
160 </TD></TR>
161 <TR><TD ALIGN="RIGHT">
162 <&|/l&>State</&>: 
163 </TD><TD>
164 <input name="State" value="<%$UserObj->State%>" size=3>
165
166 </TD></TR>
167 <TR><TD ALIGN="RIGHT">
168 <&|/l&>Zip</&>: 
169 </TD><TD>
170 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
171 </TD></TR>
172 <TR><TD ALIGN="RIGHT">
173 <&|/l&>Country</&>: 
174 </TD><TD>
175 <input name="Country" value="<%$UserObj->Country%>">
176 </TD></TR>
177 </TABLE>
178 <& /Elements/TitleBoxEnd &>
179 <br>
180 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
181 <TABLE>
182 <TR><TD ALIGN="RIGHT">
183 <&|/l&>Residence</&>: 
184 </TD><TD>
185 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
186 </TD></TR>
187 <TR><TD ALIGN="RIGHT">
188 <&|/l&>Work</&>: 
189 </TD><TD>
190 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
191 </TD></TR>
192 <TR><TD ALIGN="RIGHT">
193 <&|/l&>Mobile</&>: 
194 </TD><TD>
195 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
196 </TD></TR>
197 <TR><TD ALIGN="RIGHT">
198 <&|/l&>Pager</&>: 
199 </TD><TD>
200 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
201 <& /Elements/TitleBoxEnd &>
202 </TD>
203
204 <TR>
205 </TR>
206 </TABLE>
207 <BR>
208 <& /Elements/TitleBoxStart, title => loc('Custom Fields') &>
209 <TABLE>
210 % my $CFs = $UserObj->CustomFields;
211 % while (my $CF = $CFs->Next) {
212 <TR VALIGN="TOP"><TD ALIGN="RIGHT">
213 <% $CF->Name %>:
214 </TD><TD>
215 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
216 </TD></TR>
217 % }
218 <TR>
219 </TR>
220 </TABLE>
221 <& /Elements/TitleBoxEnd &>
222 <TR>
223 <TD colspan="2">
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) {
228 <BR>
229 <& /Elements/TitleBoxStart, title => loc('Signature') &>
230 <TEXTAREA class="signature" COLS=80 ROWS=5 name="Signature" WRAP=HARD><%$UserObj->Signature%></TEXTAREA>
231 <& /Elements/TitleBoxEnd &>
232 % }
233
234 </TD>
235 </TR>
236 </TABLE>
237
238 <& /Elements/Submit, Label => loc('Save Changes') &>
239 </form>
240
241 <%INIT>
242
243 my $current_tab;
244 my $UserObj = new RT::User($session{'CurrentUser'});
245 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
246
247 my ($val, $msg);
248
249 if ($Create) {
250     $current_tab = 'Admin/Users/Modify.html?Create=1';
251     $title = loc("Create a new user");
252
253 else {
254
255     $current_tab = 'Admin/Users/Modify.html?id='.$id;
256     if ($id eq 'new') {
257         ( $val, $msg ) = $UserObj->Create(
258             Name                  => $Name,
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'},
284             Zip                   => $ARGS{'Zip'},
285             Country               => $ARGS{'Country'},
286             Privileged           => $ARGS{'Privileged'},
287             Disabled            => ($ARGS{'Enabled'} ? 0 : 1)
288         );
289
290         if ($val) {
291                 push @results, $msg;
292         } else {
293                 push @results, loc('User could not be created: [_1]', $msg);
294         }
295     } else {
296         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
297         $val = $UserObj->Id();
298     }
299
300     if ($val) {
301         $title = loc("Modify the user [_1]", $UserObj->Name);
302     }
303
304     # If the create failed
305     else {
306         $title = loc("Create a new user");
307         $Create = 1;
308     }
309 }
310
311
312
313
314 # If we have a user to modify, lets try. 
315 if ($UserObj->Id && $id ne 'new') {
316
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 
322                    );
323
324     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
325                                             Object => $UserObj,
326                                             ARGSRef => \%ARGS );
327     push (@results,@fieldresults);
328     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
329
330
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));
335     }
336
337     #we're asking about enabled on the web page but really care about disabled.
338     $Disabled = $Enabled ? 0 : 1;
339
340     if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
341         my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
342         push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
343     }
344
345
346     # }}}
347 }
348
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;
361     }
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.");
364     } 
365 }
366
367
368 # {{{ Do some setup for the ui
369 unless ($UserObj->Disabled()) {
370     $EnabledChecked ="CHECKED";
371 }
372
373 if ($UserObj->Privileged()) {  
374     $PrivilegedChecked = "CHECKED";
375 }
376
377 # }}}
378
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
381 $id = $UserObj->Id;
382
383 </%INIT>
384
385
386 <%ARGS>
387 $id => undef
388 $Name  => undef
389 $Comments  => undef
390 $Signature  => undef
391 $EmailAddress  => undef
392 $FreeformContactInfo => undef
393 $Organization  => undef
394 $RealName  => undef
395 $NickName  => undef
396 $Privileged => undef
397 $SetPrivileged => undef
398 $Enabled => undef
399 $SetEnabled => undef
400 $Lang  => undef
401 $EmailEncoding  => undef
402 $WebEncoding => undef
403 $ExternalContactInfoId  => undef
404 $ContactInfoSystem  => undef
405 $Gecos => undef
406 $ExternalAuthId  => undef
407 $AuthSystem  => undef
408 $HomePhone => undef
409 $WorkPhone  => undef
410 $MobilePhone  => undef
411 $PagerPhone  => undef
412 $Address1 => undef
413 $Address2  => undef
414 $City  => undef
415 $State  => undef
416 $Zip  => undef
417 $Country => undef
418 $Pass1 => undef
419 $Pass2=> undef
420 $Create=> undef
421 </%ARGS>