Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / share / html / Admin / Users / Modify.html
CommitLineData
84fb5b46
MKG
1%# BEGIN BPS TAGGED BLOCK {{{
2%#
3%# COPYRIGHT:
4%#
403d7b0b 5%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
84fb5b46
MKG
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<& /Elements/Tabs &>
50
51<& /Elements/ListActions, actions => \@results &>
52
af59614d 53<form action="<%RT->Config->Get('WebPath')%>/Admin/Users/Modify.html" method="post" enctype="multipart/form-data" name="<% $Create ? 'UserCreate': 'UserModify' %>">
84fb5b46
MKG
54%if ($Create) {
55<input type="hidden" class="hidden" name="id" value="new" />
56% } else {
57<input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
58% }
59<table width="100%" border="0">
60<tr>
61
62<td valign="top" class="boxcontainer">
af59614d 63<&| /Widgets/TitleBox, title => loc('Identity'), class => 'user-info-identity' &>
84fb5b46
MKG
64
65<table>
66<tr><td align="right">
67<&|/l&>Username</&>:
68</td><td>
69<input name="Name" value="<%$UserObj->Name||$Name||''%>" /> <strong><&|/l&>(required)</&></strong>
70</td></tr>
71<tr><td align="right">
72<&|/l&>Email</&>:
73</td><td>
74<input name="EmailAddress" value="<%$UserObj->EmailAddress||$EmailAddress||''%>" />
75</td></tr>
76<tr><td align="right">
77<&|/l&>Real Name</&>:
78</td><td>
79<input name="RealName" value="<%$UserObj->RealName||$RealName||''%>" />
80</td></tr>
81<tr><td align="right">
82<&|/l&>Nickname</&>:
83</td><td>
84<input name="NickName" value="<%$UserObj->NickName||$NickName||''%>" />
85</td></tr>
86<tr><td align="right">
87<&|/l&>Unix login</&>:
88</td><td>
89<input name="Gecos" value="<%$UserObj->Gecos||$Gecos||''%>" />
90</td></tr>
91<tr><td align="right">
92<&|/l&>Language</&>:
93</td><td>
94<& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang||$Lang &>
95</td></tr>
96<tr><td align="right">
97<&|/l&>Extra info</&>:
98</td><td>
99<textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo||$FreeformContactInfo||''%></textarea>
100</td></tr>
af59614d 101<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Identity', InTable => 1 &>
84fb5b46
MKG
102</table>
103</&>
af59614d 104
84fb5b46 105<br />
af59614d 106<&| /Widgets/TitleBox, title => loc('Access control'), class => 'user-info-access-control' &>
84fb5b46 107<input type="hidden" class="hidden" name="SetEnabled" value="1" />
af59614d
MKG
108<input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <%$EnabledChecked%> />
109<label for="Enabled"><&|/l&>Let this user access RT</&></label><br />
84fb5b46
MKG
110
111
112<input type="hidden" class="hidden" name="SetPrivileged" value="1" />
af59614d
MKG
113<input type="checkbox" class="checkbox" id="Privileged" name="Privileged" value="1" <%$PrivilegedChecked||''%> />
114<label for="Privileged"><&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)</label><br />
84fb5b46
MKG
115
116<& /Elements/EditPassword,
117 User => $UserObj,
118 Name => [qw(CurrentPass Pass1 Pass2)],
119&>
af59614d
MKG
120
121<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
122
84fb5b46
MKG
123</&>
124% $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
125</td>
126
127<td valign="top" class="boxcontainer">
af59614d 128<&| /Widgets/TitleBox, title => loc('Location'), class => 'user-info-location' &>
84fb5b46
MKG
129<table>
130<tr><td align="right">
131<&|/l&>Organization</&>:
132</td><td>
133<input name="Organization" value="<%$UserObj->Organization||$Organization||''%>" />
134</td></tr>
135<tr><td align="right">
136<&|/l&>Address1</&>:
137</td><td>
138<input name="Address1" value="<%$UserObj->Address1||$Address1||''%>" />
139</td></tr>
140<tr><td align="right">
141<&|/l&>Address2</&>:
142</td><td>
143<input name="Address2" value="<%$UserObj->Address2||$Address2||''%>" />
144</td></tr>
145<tr><td align="right">
146<&|/l&>City</&>:
147</td><td>
148<input name="City" value="<%$UserObj->City||$City||''%>" size="14" />
149
150</td></tr>
151<tr><td align="right">
152<&|/l&>State</&>:
153</td><td>
154<input name="State" value="<%$UserObj->State||$State||''%>" size="3" />
155
156</td></tr>
157<tr><td align="right">
158<&|/l&>Zip</&>:
159</td><td>
160<input name="Zip" value="<%$UserObj->Zip||$Zip||''%>" size="9" />
161</td></tr>
162<tr><td align="right">
163<&|/l&>Country</&>:
164</td><td>
165<input name="Country" value="<%$UserObj->Country||$Country||''%>" />
166</td></tr>
af59614d
MKG
167
168<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
169
84fb5b46
MKG
170</table>
171</&>
172<br />
af59614d 173<&| /Widgets/TitleBox, title => loc('Phone numbers'), class => 'user-info-phones' &>
84fb5b46
MKG
174<table>
175<tr><td align="right">
176<&|/l&>Residence</&>:
177</td><td>
178<input name="HomePhone" value="<%$UserObj->HomePhone||$HomePhone||''%>" size="13" /><br />
179</td></tr>
180<tr><td align="right">
181<&|/l&>Work</&>:
182</td><td>
183<input name="WorkPhone" value="<%$UserObj->WorkPhone||$WorkPhone||''%>" size="13" /><br />
184</td></tr>
185<tr><td align="right">
186<&|/l&>Mobile</&>:
187</td><td>
188<input name="MobilePhone" value="<%$UserObj->MobilePhone||$MobilePhone||''%>" size="13" /><br />
189</td></tr>
190<tr><td align="right">
191<&|/l&>Pager</&>:
192</td><td>
193<input name="PagerPhone" value="<%$UserObj->PagerPhone||$PagerPhone||''%>" size="13" /><br />
194</td>
195</tr>
af59614d
MKG
196
197<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
198
84fb5b46
MKG
199</table>
200</&>
201<br />
af59614d
MKG
202
203<& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
204
84fb5b46
MKG
205% $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
206</td></tr>
207<tr>
208<td colspan="2">
209<&| /Widgets/TitleBox, title => loc('Comments about this user') &>
210<textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments||$Comments||''%></textarea>
211</&>
212%if (!$Create && $UserObj->Privileged) {
213<br />
214<&| /Widgets/TitleBox, title => loc('Signature') &>
215<textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature||$Signature||''%></textarea>
216</&>
217% }
218
219</td>
220</tr>
221</table>
222
223% if ( $Create ) {
224<& /Elements/Submit, Label => loc('Create') &>
225% } else {
226<& /Elements/Submit, Label => loc('Save Changes') &>
227% }
228</form>
229
230<%INIT>
231
232my $UserObj = RT::User->new($session{'CurrentUser'});
233my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
234
235my ($val, $msg);
236
237if ($Create) {
238 $title = loc("Create a new user");
239}
240else {
241
242 if ( defined $id && $id eq 'new') {
af59614d
MKG
243 ( $val, $msg ) = $UserObj->Create(
244 Name => $Name,
245 EmailAddress => $ARGS{'EmailAddress'},
246 Name => $ARGS{'Name'},
247 Comments => $ARGS{'Comments'},
248 Signature => $ARGS{'Signature'},
249 EmailAddress => $ARGS{'EmailAddress'},
250 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
251 Organization => $ARGS{'Organization'},
252 RealName => $ARGS{'RealName'},
253 NickName => $ARGS{'NickName'},
254 Lang => $ARGS{'Lang'},
255 EmailEncoding => $ARGS{'EmailEncoding'},
256 WebEncoding => $ARGS{'WebEncoding'},
257 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
258 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
259 Gecos => $ARGS{'Gecos'},
260 ExternalAuthId => $ARGS{'ExternalAuthId'},
261 AuthSystem => $ARGS{'AuthSystem'},
262 HomePhone => $ARGS{'HomePhone'},
263 WorkPhone => $ARGS{'WorkPhone'},
264 MobilePhone => $ARGS{'MobilePhone'},
265 PagerPhone => $ARGS{'PagerPhone'},
266 Address1 => $ARGS{'Address1'},
267 Address2 => $ARGS{'Address2'},
268 City => $ARGS{'City'},
269 State => $ARGS{'State'},
270 Zip => $ARGS{'Zip'},
271 Country => $ARGS{'Country'},
272 Privileged => $ARGS{'Privileged'},
273 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
274 );
275
276 if ($val) {
277 push @results, $msg;
84fb5b46 278 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
af59614d
MKG
279 } else {
280 push @results, loc('User could not be created: [_1]', $msg);
281 }
84fb5b46 282 } else {
af59614d 283 $UserObj->Load($id) || $UserObj->Load($Name)
84fb5b46
MKG
284 || Abort("Couldn't load user '" . ( $Name || '') . "'");
285 $val = $UserObj->Id();
286 }
287
288 if ($val) {
af59614d 289 $title = loc("Modify the user [_1]", $UserObj->Name);
84fb5b46
MKG
290 }
291
292 # If the create failed
293 else {
af59614d
MKG
294 $title = loc("Create a new user");
295 $Create = 1;
84fb5b46
MKG
296 }
297}
298
299
300$m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
301
302
303# If we have a user to modify, lets try.
304if ($UserObj->Id && $id ne 'new') {
305
306 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
af59614d
MKG
307 Organization RealName NickName Lang EmailEncoding WebEncoding
308 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
309 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
310 Address2 City State Zip Country
311 );
84fb5b46
MKG
312
313 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
af59614d
MKG
314 Object => $UserObj,
315 ARGSRef => \%ARGS );
84fb5b46
MKG
316 push (@results,@fieldresults);
317 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
318
319
320 # {{{ Deal with special fields: Privileged, Enabled
af59614d 321 if ( $SetPrivileged and $Privileged != ($UserObj->Privileged || 0) ) {
84fb5b46
MKG
322 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
323 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
324 }
325
326 #we're asking about enabled on the web page but really care about disabled.
327 $Disabled = $Enabled ? 0 : 1;
328
329 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
330 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
331 push @results, $msg;
332 }
333
334
335}
336
337
338my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
339if ( $UserObj->Id ) {
340 # Deal with Password field
341 my ($status, $msg) = $UserObj->SafeSetPassword(
342 Current => $CurrentPass,
343 New => $Pass1,
344 Confirmation => $Pass2,
345 );
346 push @results, $msg;
347
348 if ( $id eq 'new' && !$status ) {
349 push @results, loc("A password was not set, so user won't be able to login.");
350 }
351}
352
353
354# Do some setup for the ui
355unless ( $UserObj->id && $UserObj->Disabled ) {
356 $EnabledChecked = 'checked="checked"';
357}
358
359if ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $Privileged)) {
360 $PrivilegedChecked = 'checked="checked"';
361}
362
363# This code does automatic redirection if any updates happen.
364MaybeRedirectForResults(
365 Actions => \@results,
366 Arguments => { id => $UserObj->Id },
367) if $UserObj->Id;
368
369</%INIT>
370
371
372<%ARGS>
373$id => undef
374$Name => undef
375$Comments => undef
376$Signature => undef
377$EmailAddress => undef
378$FreeformContactInfo => undef
379$Organization => undef
380$RealName => undef
381$NickName => undef
af59614d 382$Privileged => 0
84fb5b46
MKG
383$SetPrivileged => undef
384$Enabled => undef
385$SetEnabled => undef
386$Lang => undef
387$EmailEncoding => undef
388$WebEncoding => undef
389$ExternalContactInfoId => undef
390$ContactInfoSystem => undef
391$Gecos => undef
392$ExternalAuthId => undef
393$AuthSystem => undef
394$HomePhone => undef
395$WorkPhone => undef
396$MobilePhone => undef
397$PagerPhone => undef
398$Address1 => undef
399$Address2 => undef
400$City => undef
401$State => undef
402$Zip => undef
403$Country => undef
404$CurrentPass => undef
405$Pass1 => undef
406$Pass2 => undef
407$Create=> undef
408</%ARGS>