This commit was generated by cvs2svn to compensate for changes in r11022,
[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
109 <&| /Widgets/TitleBox, title => loc('Customers') &>
110 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
111 </&>
112 <br />
113
114 <&| /Widgets/TitleBox, title => loc('Access control') &>
115 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
116 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
117 <&|/l&>Let this user access RT</&><br />
118
119
120 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
121 <input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked||''%> /> <&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)<br />
122
123 <& /Elements/EditPassword,
124     User => $UserObj,
125     Name => [qw(CurrentPass Pass1 Pass2)],
126 &>
127 </&>
128 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
129 </td>
130
131 <td valign="top" class="boxcontainer">
132 <&| /Widgets/TitleBox, title => loc('Location') &>
133 <table>
134 <tr><td align="right">
135 <&|/l&>Organization</&>: 
136 </td><td>
137 <input name="Organization" value="<%$UserObj->Organization||''%>" />
138 </td></tr>
139 <tr><td align="right">
140 <&|/l&>Address1</&>: 
141 </td><td>
142 <input name="Address1" value="<%$UserObj->Address1||''%>" />
143 </td></tr>
144 <tr><td align="right">
145 <&|/l&>Address2</&>: 
146 </td><td>
147 <input name="Address2" value="<%$UserObj->Address2||''%>" />
148 </td></tr>
149 <tr><td align="right">
150 <&|/l&>City</&>: 
151 </td><td>
152 <input name="City" value="<%$UserObj->City||''%>" size="14" />
153
154 </td></tr>
155 <tr><td align="right">
156 <&|/l&>State</&>: 
157 </td><td>
158 <input name="State" value="<%$UserObj->State||''%>" size="3" />
159
160 </td></tr>
161 <tr><td align="right">
162 <&|/l&>Zip</&>: 
163 </td><td>
164 <input name="Zip" value="<%$UserObj->Zip||''%>" size="9" />
165 </td></tr>
166 <tr><td align="right">
167 <&|/l&>Country</&>: 
168 </td><td>
169 <input name="Country" value="<%$UserObj->Country||''%>" />
170 </td></tr>
171 </table>
172 </&>
173 <br />
174 <&| /Widgets/TitleBox, title => loc('Phone numbers') &>
175 <table>
176 <tr><td align="right">
177 <&|/l&>Residence</&>: 
178 </td><td>
179 <input name="HomePhone" value="<%$UserObj->HomePhone||''%>" size="13" /><br />
180 </td></tr>
181 <tr><td align="right">
182 <&|/l&>Work</&>: 
183 </td><td>
184 <input name="WorkPhone" value="<%$UserObj->WorkPhone||''%>" size="13" /><br />
185 </td></tr>
186 <tr><td align="right">
187 <&|/l&>Mobile</&>: 
188 </td><td>
189 <input name="MobilePhone" value="<%$UserObj->MobilePhone||''%>" size="13" /><br />
190 </td></tr>
191 <tr><td align="right">
192 <&|/l&>Pager</&>: 
193 </td><td>
194 <input name="PagerPhone" value="<%$UserObj->PagerPhone||''%>" size="13" /><br />
195 </td>
196 </tr>
197 </table>
198 </&>
199 <br />
200 <&| /Widgets/TitleBox, title => loc('Custom Fields') &>
201 <table>
202 % my $CFs = $UserObj->CustomFields;
203 % while (my $CF = $CFs->Next) {
204 <tr valign="top"><td align="right">
205 <% loc($CF->Name) %>:
206 </td><td>
207 % if ($UserObj->id) {
208 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
209 % } else {
210 <& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User-new-CustomField-', CustomField => $CF &>
211 % }
212 </td></tr>
213 % }
214 </table>
215 </&>
216 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
217 </td></tr>
218 <tr>
219 <td colspan="2">
220 <&| /Widgets/TitleBox, title => loc('Comments about this user') &>
221 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments||''%></textarea>
222 </&>
223 %if (!$Create && $UserObj->Privileged) {
224 <br />
225 <&| /Widgets/TitleBox, title => loc('Signature') &>
226 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature||''%></textarea>
227 </&>
228 % }
229
230 </td>
231 </tr>
232 </table>
233
234 % if ( $Create ) {
235 <& /Elements/Submit, Label => loc('Create') &>
236 % } else {
237 <& /Elements/Submit, Label => loc('Save Changes') &>
238 % }
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 if $id;
256
257     if ( defined $id && $id eq 'new') {
258         ( $val, $msg ) = $UserObj->Create(
259             Name                  => $Name,
260             EmailAddress          => $ARGS{'EmailAddress'},
261             Name                  => $ARGS{'Name'},
262             Comments              => $ARGS{'Comments'},
263             Signature             => $ARGS{'Signature'},
264             EmailAddress          => $ARGS{'EmailAddress'},
265             FreeformContactInfo   => $ARGS{'FreeformContactInfo'},
266             Organization          => $ARGS{'Organization'},
267             RealName              => $ARGS{'RealName'},
268             NickName              => $ARGS{'NickName'},
269             Lang                  => $ARGS{'Lang'},
270             EmailEncoding         => $ARGS{'EmailEncoding'},
271             WebEncoding           => $ARGS{'WebEncoding'},
272             ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
273             ContactInfoSystem     => $ARGS{'ContactInfoSystem'},
274             Gecos                 => $ARGS{'Gecos'},
275             ExternalAuthId        => $ARGS{'ExternalAuthId'},
276             AuthSystem            => $ARGS{'AuthSystem'},
277             HomePhone             => $ARGS{'HomePhone'},
278             WorkPhone             => $ARGS{'WorkPhone'},
279             MobilePhone           => $ARGS{'MobilePhone'},
280             PagerPhone            => $ARGS{'PagerPhone'},
281             Address1              => $ARGS{'Address1'},
282             Address2              => $ARGS{'Address2'},
283             City                  => $ARGS{'City'},
284             State                 => $ARGS{'State'},
285             Zip                   => $ARGS{'Zip'},
286             Country               => $ARGS{'Country'},
287             Privileged           => $ARGS{'Privileged'},
288             Disabled            => ($ARGS{'Enabled'} ? 0 : 1)
289         );
290
291         if ($val) {
292                 push @results, $msg;
293         foreach my $key ( keys %ARGS) {
294             # Convert custom fields on the "new" object to custom fields on the one we've just created
295             if ($key =~ /^Object-RT::User-new-CustomField-(.*)$/) {
296             $ARGS{'Object-RT::User-'.$val.'-CustomField-'.$1} = delete $ARGS{$key};
297             }
298         }
299         push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
300         } else {
301                 push @results, loc('User could not be created: [_1]', $msg);
302         }
303     } else {
304             $UserObj->Load($id) || $UserObj->Load($Name) 
305             || Abort("Couldn't load user '" . ( $Name || '') . "'");
306         $val = $UserObj->Id();
307     }
308
309     if ($val) {
310         $title = loc("Modify the user [_1]", $UserObj->Name);
311     }
312
313     # If the create failed
314     else {
315         $title = loc("Create a new user");
316         $Create = 1;
317     }
318 }
319
320
321
322
323 # If we have a user to modify, lets try. 
324 if ($UserObj->Id && $id ne 'new') {
325
326     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
327                     Organization RealName NickName Lang EmailEncoding WebEncoding 
328                     ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
329                     AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
330                     Address2 City State Zip Country 
331                    );
332
333     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
334                                             Object => $UserObj,
335                                             ARGSRef => \%ARGS );
336     push (@results,@fieldresults);
337     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
338
339     #deal with freeside customer links
340     push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
341
342     # {{{ Deal with special fields: Privileged, Enabled
343     if  ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
344          my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
345          push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
346     }
347
348     #we're asking about enabled on the web page but really care about disabled.
349     $Disabled = $Enabled ? 0 : 1;
350
351     if  ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) { 
352         my  ($code, $msg) = $UserObj->SetDisabled($Disabled);
353         push @results, $msg;
354     }
355
356
357     # }}}
358 }
359
360
361 my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
362 if ( $UserObj->Id ) {
363     # Deal with Password field
364     my ($status, $msg) = $UserObj->SafeSetPassword(
365         Current      => $CurrentPass,
366         New          => $Pass1,
367         Confirmation => $Pass2,
368     );
369     push @results, $msg;
370
371     if ( $id eq 'new' && !$status ) {
372         push @results, loc("A password was not set, so user won't be able to login.");
373     }
374 }
375
376
377 # Do some setup for the ui
378 unless ( $UserObj->id && $UserObj->Disabled ) {
379     $EnabledChecked = 'checked="checked"';
380 }
381
382 if (!$Create && $UserObj->Privileged()) {  
383     $PrivilegedChecked = 'checked="checked"';
384 }
385
386 # set the id, so the the menu will have the right info, this needs to
387 # be done here to avoid creating and then modifying a user
388 $id = $UserObj->Id;
389
390 </%INIT>
391
392
393 <%ARGS>
394 $id => undef
395 $Name  => undef
396 $Comments  => undef
397 $Signature  => undef
398 $EmailAddress  => undef
399 $FreeformContactInfo => undef
400 $Organization  => undef
401 $RealName  => undef
402 $NickName  => undef
403 $Privileged => undef
404 $SetPrivileged => undef
405 $Enabled => undef
406 $SetEnabled => undef
407 $Lang  => undef
408 $EmailEncoding  => undef
409 $WebEncoding => undef
410 $ExternalContactInfoId  => undef
411 $ContactInfoSystem  => undef
412 $Gecos => undef
413 $ExternalAuthId  => undef
414 $AuthSystem  => undef
415 $HomePhone => undef
416 $WorkPhone  => undef
417 $MobilePhone  => undef
418 $PagerPhone  => undef
419 $Address1 => undef
420 $Address2  => undef
421 $City  => undef
422 $State  => undef
423 $Zip  => undef
424 $Country => undef
425 $CurrentPass => undef
426 $Pass1 => undef
427 $Pass2 => undef
428 $Create=> undef
429 $OnlySearchForCustomers => undef
430 $OnlySearchForServices => undef
431 $CustomerString => undef
432 $ServiceString => undef
433 </%ARGS>