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