import rt 3.2.2
[freeside.git] / rt / html / Admin / Users / Modify.html
1 %# {{{ BEGIN BPS TAGGED BLOCK
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2004 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>
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&>Extra info</&>: 
95 </TD><TD>
96 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
97 </TD></TR>
98 </TABLE>
99 <& /Elements/TitleBoxEnd &>
100 <br>
101 <& /Elements/TitleBoxStart, title => loc('Access control') &>
102 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
103 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
104 <&|/l&>Let this user access RT</&><BR>
105
106
107 <INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
108 <INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> <&|/l&>Let this user be granted rights</&><BR>
109                     
110 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
111 <TABLE>
112 <TR>
113 <TD ALIGN=RIGHT>
114 <&|/l&>New Password</&>:
115 </TD>
116 <TD ALIGN=LEFT>
117 <input type=password name="Pass1">
118 </TD>
119 </TR>
120 <TR><TD ALIGN=RIGHT>
121 <&|/l&>Retype Password</&>:
122 </TD>
123 <TD>
124 <input type=password name="Pass2">
125 </TD>
126 </TR>
127 </TABLE>
128 % }
129 <& /Elements/TitleBoxEnd &>
130 </TD>
131
132 <TD VALIGN=TOP class="boxcontainer">
133 <& /Elements/TitleBoxStart, title => loc('Location') &>
134 <TABLE>
135 <TR><TD ALIGN="RIGHT">
136 <&|/l&>Organization</&>: 
137 </TD><TD>
138 <input name="Organization" value="<%$UserObj->Organization%>">
139 </TD></TR>
140 <TR><TD ALIGN="RIGHT">
141 <&|/l&>Address1</&>: 
142 </TD><TD>
143 <input name="Address1" value="<%$UserObj->Address1%>">
144 </TD></TR>
145 <TR><TD ALIGN="RIGHT">
146 <&|/l&>Address2</&>: 
147 </TD><TD>
148 <input name="Address2" value="<%$UserObj->Address2%>">
149 </TD></TR>
150 <TR><TD ALIGN="RIGHT">
151 <&|/l&>City</&>: 
152 </TD><TD>
153 <input name="City" value="<%$UserObj->City%>" size=14>
154
155 </TD></TR>
156 <TR><TD ALIGN="RIGHT">
157 <&|/l&>State</&>: 
158 </TD><TD>
159 <input name="State" value="<%$UserObj->State%>" size=3>
160
161 </TD></TR>
162 <TR><TD ALIGN="RIGHT">
163 <&|/l&>Zip</&>: 
164 </TD><TD>
165 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
166 </TD></TR>
167 <TR><TD ALIGN="RIGHT">
168 <&|/l&>Country</&>: 
169 </TD><TD>
170 <input name="Country" value="<%$UserObj->Country%>">
171 </TD></TR>
172 </TABLE>
173 <& /Elements/TitleBoxEnd &>
174 <br>
175 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
176 <TABLE>
177 <TR><TD ALIGN="RIGHT">
178 <&|/l&>Residence</&>: 
179 </TD><TD>
180 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
181 </TD></TR>
182 <TR><TD ALIGN="RIGHT">
183 <&|/l&>Work</&>: 
184 </TD><TD>
185 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
186 </TD></TR>
187 <TR><TD ALIGN="RIGHT">
188 <&|/l&>Mobile</&>: 
189 </TD><TD>
190 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
191 </TD></TR>
192 <TR><TD ALIGN="RIGHT">
193 <&|/l&>Pager</&>: 
194 </TD><TD>
195 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
196 <& /Elements/TitleBoxEnd &>
197 </TD>
198
199 <TR>
200 </TR>
201 </TABLE>
202 <TR>
203 <TD colspan="2">
204 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
205 <TEXTAREA name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%>
206 </TEXTAREA>
207 <& /Elements/TitleBoxEnd &>
208 %if ($UserObj->Privileged) {
209 <BR>
210 <& /Elements/TitleBoxStart, title => loc('Signature') &>
211 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
212 <%$UserObj->Signature%></TEXTAREA>
213 <& /Elements/TitleBoxEnd &>
214 % }
215
216 </TD>
217 </TR>
218 </TABLE>
219
220 <& /Elements/Submit, Label => loc('Save Changes') &>
221 </form>
222
223 <%INIT>
224
225 my $current_tab;
226 my $UserObj = new RT::User($session{'CurrentUser'});
227 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
228
229 my ($val, $msg);
230
231 if ($Create) {
232     $current_tab = 'Admin/Users/Modify.html?Create=1';
233     $title = loc("Create a new user");
234
235 else {
236
237     $current_tab = 'Admin/Users/Modify.html?id='.$id;
238     if ($id eq 'new') {
239     ( $val, $msg ) = $UserObj->Create(
240         Name                  => $Name,
241         EmailAddress          => $ARGS{'EmailAddress'},
242         Name                  => $ARGS{'Name'},
243         Comments              => $ARGS{'Comments'},
244         Signature             => $ARGS{'Signature'},
245         EmailAddress          => $ARGS{'EmailAddress'},
246         FreeformContactInfo   => $ARGS{'FreeformContactInfo'},
247         Organization          => $ARGS{'Organization'},
248         RealName              => $ARGS{'RealName'},
249         NickName              => $ARGS{'NickName'},
250         Lang                  => $ARGS{'Lang'},
251         EmailEncoding         => $ARGS{'EmailEncoding'},
252         WebEncoding           => $ARGS{'WebEncoding'},
253         ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
254         ContactInfoSystem     => $ARGS{'ContactInfoSystem'},
255         Gecos                 => $ARGS{'Gecos'},
256         ExternalAuthId        => $ARGS{'ExternalAuthId'},
257         AuthSystem            => $ARGS{'AuthSystem'},
258         HomePhone             => $ARGS{'HomePhone'},
259         WorkPhone             => $ARGS{'WorkPhone'},
260         MobilePhone           => $ARGS{'MobilePhone'},
261         PagerPhone            => $ARGS{'PagerPhone'},
262         Address1              => $ARGS{'Address1'},
263         Address2              => $ARGS{'Address2'},
264         City                  => $ARGS{'City'},
265         State                 => $ARGS{'State'},
266         Zip                   => $ARGS{'Zip'},
267         Country               => $ARGS{'Country'},
268         Privileged           => $ARGS{'Privileged'},
269         Disabled            => ($ARGS{'Enabled'} ? 0 : 1) 
270                                        );
271         if ($val) {
272                 push @results, $msg;
273         } else {
274                 push @results, loc('User could not be created: [_1]', $msg);
275         }       
276
277         # set the id, so the the menu will have the right info
278         $id = $UserObj->Id;     
279     } else {
280         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
281         $val = $UserObj->Id();
282     }
283
284     if ($val) {
285         $title = loc("Modify the user [_1]", $UserObj->Name);
286     }   
287
288     # If the create failed
289     else {
290         $title = loc("Create a new user");
291         $Create = 1;
292     }    
293
294 }
295
296
297
298
299 # If we have a user to modify, lets try. 
300 if ($UserObj->Id && $id ne 'new') {
301     
302     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
303                     Organization RealName NickName Lang EmailEncoding WebEncoding 
304                     ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
305                     AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
306                 Address2 City State Zip Country 
307                    );
308     
309     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
310                                             Object => $UserObj,
311                                             ARGSRef => \%ARGS );
312     push (@results,@fieldresults);
313
314
315 # {{{ Deal with special fields: Privileged, Enabled and Password
316 if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
317 my  ($code, $msg) = $UserObj->SetPrivileged($Privileged);
318      push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
319 }
320
321 #we're asking about enabled on the web page but really care about disabled.
322 if ($Enabled == 1) {
323     $Disabled = 0;
324 }       
325 else {
326     $Disabled = 1;
327 }
328 if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
329     my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
330     push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
331 }
332
333
334 #TODO: make this report errors properly
335 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
336     my ($code, $msg);
337     ($code, $msg) = $UserObj->SetPassword($Pass1);
338     push @results, loc('Password: [_1]', loc_fuzzy($msg));
339 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
340     push @results, loc("Passwords do not match.");
341 }
342
343 # }}}
344 }
345
346
347 # {{{ Do some setup for the ui
348 unless ($UserObj->Disabled()) {
349     $EnabledChecked ="CHECKED";
350 }
351
352 if ($UserObj->Privileged()) {  
353     $PrivilegedChecked = "CHECKED";
354 }
355
356 # }}}
357 </%INIT>
358
359
360 <%ARGS>
361 $id => undef
362 $Name  => undef
363 $Comments  => undef
364 $Signature  => undef
365 $EmailAddress  => undef
366 $FreeformContactInfo => undef
367 $Organization  => undef
368 $RealName  => undef
369 $NickName  => undef
370 $Privileged => undef
371 $SetPrivileged => undef
372 $Enabled => undef
373 $SetEnabled => undef
374 $Lang  => undef
375 $EmailEncoding  => undef
376 $WebEncoding => undef
377 $ExternalContactInfoId  => undef
378 $ContactInfoSystem  => undef
379 $Gecos => undef
380 $ExternalAuthId  => undef
381 $AuthSystem  => undef
382 $HomePhone => undef
383 $WorkPhone  => undef
384 $MobilePhone  => undef
385 $PagerPhone  => undef
386 $Address1 => undef
387 $Address2  => undef
388 $City  => undef
389 $State  => undef
390 $Zip  => undef
391 $Country => undef
392 $Pass1 => undef
393 $Pass2=> undef
394 $Create=> undef
395 </%ARGS>