import rt 3.8.9
[freeside.git] / rt / share / html / Admin / Users / Modify.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
6 %#                                          <sales@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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %#
29 %#
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %#
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %#
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %#
47 %# END BPS TAGGED BLOCK }}}
48 <& /Admin/Elements/Header, Title => $title  &>
49 <& /Admin/Elements/UserTabs, 
50     id => $id, 
51     UserObj => $UserObj,
52     current_tab => $current_tab, 
53     Title => $title &>
54
55 <& /Elements/ListActions, actions => \@results &>
56
57 <form action="<%RT->Config->Get('WebPath')%>/Admin/Users/Modify.html" method="post" enctype="multipart/form-data">
58 %if ($Create) {
59 <input type="hidden" class="hidden" name="id" value="new" />
60 % } else {
61 <input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
62 % }
63 <table width="100%" border="0">
64 <tr>
65
66 <td valign="top" class="boxcontainer">
67 <&| /Widgets/TitleBox, title => loc('Identity') &>
68
69 <table>
70 <tr><td align="right">
71 <&|/l&>Username</&>:
72 </td><td>
73 <input name="Name" value="<%$UserObj->Name||''%>" /> <strong><&|/l&>(required)</&></strong>
74 </td></tr>
75 <tr><td align="right">
76 <&|/l&>Email</&>:
77 </td><td>
78 <input name="EmailAddress" value="<%$UserObj->EmailAddress||''%>" />
79 </td></tr>
80 <tr><td align="right">
81 <&|/l&>Real Name</&>: 
82 </td><td>
83 <input name="RealName" value="<%$UserObj->RealName||''%>" />
84 </td></tr>
85 <tr><td align="right">
86 <&|/l&>Nickname</&>: 
87 </td><td>
88 <input name="NickName" value="<%$UserObj->NickName||''%>" />
89 </td></tr>
90 <tr><td align="right">
91 <&|/l&>Unix login</&>: 
92 </td><td>
93 <input name="Gecos" value="<%$UserObj->Gecos||''%>" />
94 </td></tr>
95 <tr><td align="right">
96 <&|/l&>Language</&>: 
97 </td><td>
98 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
99 </td></tr>
100 <tr><td align="right">
101 <&|/l&>Extra info</&>: 
102 </td><td>
103 <textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo||''%></textarea>
104 </td></tr>
105 </table>
106 </&>
107 <br />
108 <&| /Widgets/TitleBox, title => loc('Access control') &>
109 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
110 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
111 <&|/l&>Let this user access RT</&><br />
112
113
114 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
115 <input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked||''%> /> <&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)<br />
116
117 <& /Elements/EditPassword,
118     User => $UserObj,
119     Name => [qw(CurrentPass Pass1 Pass2)],
120 &>
121 </&>
122 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
123 </td>
124
125 <td valign="top" class="boxcontainer">
126 <&| /Widgets/TitleBox, title => loc('Location') &>
127 <table>
128 <tr><td align="right">
129 <&|/l&>Organization</&>: 
130 </td><td>
131 <input name="Organization" value="<%$UserObj->Organization||''%>" />
132 </td></tr>
133 <tr><td align="right">
134 <&|/l&>Address1</&>: 
135 </td><td>
136 <input name="Address1" value="<%$UserObj->Address1||''%>" />
137 </td></tr>
138 <tr><td align="right">
139 <&|/l&>Address2</&>: 
140 </td><td>
141 <input name="Address2" value="<%$UserObj->Address2||''%>" />
142 </td></tr>
143 <tr><td align="right">
144 <&|/l&>City</&>: 
145 </td><td>
146 <input name="City" value="<%$UserObj->City||''%>" size="14" />
147
148 </td></tr>
149 <tr><td align="right">
150 <&|/l&>State</&>: 
151 </td><td>
152 <input name="State" value="<%$UserObj->State||''%>" size="3" />
153
154 </td></tr>
155 <tr><td align="right">
156 <&|/l&>Zip</&>: 
157 </td><td>
158 <input name="Zip" value="<%$UserObj->Zip||''%>" size="9" />
159 </td></tr>
160 <tr><td align="right">
161 <&|/l&>Country</&>: 
162 </td><td>
163 <input name="Country" value="<%$UserObj->Country||''%>" />
164 </td></tr>
165 </table>
166 </&>
167 <br />
168 <&| /Widgets/TitleBox, title => loc('Phone numbers') &>
169 <table>
170 <tr><td align="right">
171 <&|/l&>Residence</&>: 
172 </td><td>
173 <input name="HomePhone" value="<%$UserObj->HomePhone||''%>" size="13" /><br />
174 </td></tr>
175 <tr><td align="right">
176 <&|/l&>Work</&>: 
177 </td><td>
178 <input name="WorkPhone" value="<%$UserObj->WorkPhone||''%>" size="13" /><br />
179 </td></tr>
180 <tr><td align="right">
181 <&|/l&>Mobile</&>: 
182 </td><td>
183 <input name="MobilePhone" value="<%$UserObj->MobilePhone||''%>" size="13" /><br />
184 </td></tr>
185 <tr><td align="right">
186 <&|/l&>Pager</&>: 
187 </td><td>
188 <input name="PagerPhone" value="<%$UserObj->PagerPhone||''%>" size="13" /><br />
189 </td>
190 </tr>
191 </table>
192 </&>
193 <br />
194 <&| /Widgets/TitleBox, title => loc('Custom Fields') &>
195 <table>
196 % my $CFs = $UserObj->CustomFields;
197 % while (my $CF = $CFs->Next) {
198 <tr valign="top"><td align="right">
199 <% loc($CF->Name) %>:
200 </td><td>
201 % if ($UserObj->id) {
202 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
203 % } else {
204 <& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User-new-CustomField-', CustomField => $CF &>
205 % }
206 </td></tr>
207 % }
208 </table>
209 </&>
210 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
211 </td></tr>
212 <tr>
213 <td colspan="2">
214 <&| /Widgets/TitleBox, title => loc('Comments about this user') &>
215 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments||''%></textarea>
216 </&>
217 %if (!$Create && $UserObj->Privileged) {
218 <br />
219 <&| /Widgets/TitleBox, title => loc('Signature') &>
220 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature||''%></textarea>
221 </&>
222 % }
223
224 </td>
225 </tr>
226 </table>
227
228 % if ( $Create ) {
229 <& /Elements/Submit, Label => loc('Create') &>
230 % } else {
231 <& /Elements/Submit, Label => loc('Save Changes') &>
232 % }
233 </form>
234
235 <%INIT>
236
237 my $current_tab;
238 my $UserObj = new RT::User($session{'CurrentUser'});
239 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
240
241 my ($val, $msg);
242
243 if ($Create) {
244     $current_tab = 'Admin/Users/Modify.html?Create=1';
245     $title = loc("Create a new user");
246
247 else {
248
249     $current_tab = 'Admin/Users/Modify.html?id='.$id if $id;
250
251     if ( defined $id && $id eq 'new') {
252         ( $val, $msg ) = $UserObj->Create(
253             Name                  => $Name,
254             EmailAddress          => $ARGS{'EmailAddress'},
255             Name                  => $ARGS{'Name'},
256             Comments              => $ARGS{'Comments'},
257             Signature             => $ARGS{'Signature'},
258             EmailAddress          => $ARGS{'EmailAddress'},
259             FreeformContactInfo   => $ARGS{'FreeformContactInfo'},
260             Organization          => $ARGS{'Organization'},
261             RealName              => $ARGS{'RealName'},
262             NickName              => $ARGS{'NickName'},
263             Lang                  => $ARGS{'Lang'},
264             EmailEncoding         => $ARGS{'EmailEncoding'},
265             WebEncoding           => $ARGS{'WebEncoding'},
266             ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
267             ContactInfoSystem     => $ARGS{'ContactInfoSystem'},
268             Gecos                 => $ARGS{'Gecos'},
269             ExternalAuthId        => $ARGS{'ExternalAuthId'},
270             AuthSystem            => $ARGS{'AuthSystem'},
271             HomePhone             => $ARGS{'HomePhone'},
272             WorkPhone             => $ARGS{'WorkPhone'},
273             MobilePhone           => $ARGS{'MobilePhone'},
274             PagerPhone            => $ARGS{'PagerPhone'},
275             Address1              => $ARGS{'Address1'},
276             Address2              => $ARGS{'Address2'},
277             City                  => $ARGS{'City'},
278             State                 => $ARGS{'State'},
279             Zip                   => $ARGS{'Zip'},
280             Country               => $ARGS{'Country'},
281             Privileged           => $ARGS{'Privileged'},
282             Disabled            => ($ARGS{'Enabled'} ? 0 : 1)
283         );
284
285         if ($val) {
286                 push @results, $msg;
287         foreach my $key ( keys %ARGS) {
288             # Convert custom fields on the "new" object to custom fields on the one we've just created
289             if ($key =~ /^Object-RT::User-new-CustomField-(.*)$/) {
290             $ARGS{'Object-RT::User-'.$val.'-CustomField-'.$1} = delete $ARGS{$key};
291             }
292         }
293         push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
294         } else {
295                 push @results, loc('User could not be created: [_1]', $msg);
296         }
297     } else {
298             $UserObj->Load($id) || $UserObj->Load($Name) 
299             || Abort("Couldn't load user '" . ( $Name || '') . "'");
300         $val = $UserObj->Id();
301     }
302
303     if ($val) {
304         $title = loc("Modify the user [_1]", $UserObj->Name);
305     }
306
307     # If the create failed
308     else {
309         $title = loc("Create a new user");
310         $Create = 1;
311     }
312 }
313
314
315
316
317 # If we have a user to modify, lets try. 
318 if ($UserObj->Id && $id ne 'new') {
319
320     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
321                     Organization RealName NickName Lang EmailEncoding WebEncoding 
322                     ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
323                     AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
324                     Address2 City State Zip Country 
325                    );
326
327     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
328                                             Object => $UserObj,
329                                             ARGSRef => \%ARGS );
330     push (@results,@fieldresults);
331     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
332
333
334     # {{{ Deal with special fields: Privileged, Enabled
335     if  ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
336          my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
337          push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
338     }
339
340     #we're asking about enabled on the web page but really care about disabled.
341     $Disabled = $Enabled ? 0 : 1;
342
343     if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
344         my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
345         push @results, $msg;
346     }
347
348
349     # }}}
350 }
351
352
353 my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
354 if ( $UserObj->Id ) {
355     # Deal with Password field
356     my ($status, $msg) = $UserObj->SafeSetPassword(
357         Current      => $CurrentPass,
358         New          => $Pass1,
359         Confirmation => $Pass2,
360     );
361     push @results, $msg;
362
363     if ( $id eq 'new' && !$status ) {
364         push @results, loc("A password was not set, so user won't be able to login.");
365     }
366 }
367
368
369 # Do some setup for the ui
370 unless ( $UserObj->id && $UserObj->Disabled ) {
371     $EnabledChecked = 'checked="checked"';
372 }
373
374 if (!$Create && $UserObj->Privileged()) {  
375     $PrivilegedChecked = 'checked="checked"';
376 }
377
378 # set the id, so the the menu will have the right info, this needs to
379 # be done here to avoid creating and then modifying a user
380 $id = $UserObj->Id;
381
382 </%INIT>
383
384
385 <%ARGS>
386 $id => undef
387 $Name  => undef
388 $Comments  => undef
389 $Signature  => undef
390 $EmailAddress  => undef
391 $FreeformContactInfo => undef
392 $Organization  => undef
393 $RealName  => undef
394 $NickName  => undef
395 $Privileged => undef
396 $SetPrivileged => undef
397 $Enabled => undef
398 $SetEnabled => undef
399 $Lang  => undef
400 $EmailEncoding  => undef
401 $WebEncoding => undef
402 $ExternalContactInfoId  => undef
403 $ContactInfoSystem  => undef
404 $Gecos => undef
405 $ExternalAuthId  => undef
406 $AuthSystem  => undef
407 $HomePhone => undef
408 $WorkPhone  => undef
409 $MobilePhone  => undef
410 $PagerPhone  => undef
411 $Address1 => undef
412 $Address2  => undef
413 $City  => undef
414 $State  => undef
415 $Zip  => undef
416 $Country => undef
417 $CurrentPass => undef
418 $Pass1 => undef
419 $Pass2 => undef
420 $Create=> undef
421 </%ARGS>