rt 4.2.16
[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-2019 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 <& /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" name="<% $Create ? 'UserCreate': 'UserModify' %>">
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'), class => 'user-info-identity' &>
64
65 <table>
66 <tr><td align="right">
67 <&|/l&>Username</&>:
68 </td><td>
69 <input name="Name" value="<%$UserObj->Name//$ARGS{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//$ARGS{EmailAddress}//''%>" />
75 </td></tr>
76 <tr><td align="right">
77 <&|/l&>Real Name</&>:
78 </td><td>
79 <input name="RealName" value="<%$UserObj->RealName//$ARGS{RealName}//''%>" />
80 </td></tr>
81 <tr><td align="right">
82 <&|/l&>Nickname</&>:
83 </td><td>
84 <input name="NickName" value="<%$UserObj->NickName//$ARGS{NickName}//''%>" />
85 </td></tr>
86 <tr><td align="right">
87 <&|/l&>Unix login</&>:
88 </td><td>
89 <input name="Gecos" value="<%$UserObj->Gecos//$ARGS{Gecos}//''%>" />
90 </td></tr>
91 <tr><td align="right">
92 <&|/l&>Language</&>:
93 </td><td>
94 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang//$ARGS{Lang} &>
95 </td></tr>
96 <tr><td align="right"><&|/l&>Timezone</&>:
97 </td><td>
98 <& /Elements/SelectTimezone, Name => 'Timezone', Default => $UserObj->Timezone &>
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//$ARGS{FreeformContactInfo}//''%></textarea>
104 </td></tr>
105 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Identity', InTable => 1 &>
106 </table>
107 </&>
108
109 <br />
110
111 <&| /Widgets/TitleBox, title => loc('Customers') &>
112 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
113 </&>
114 <br />
115
116 <&| /Widgets/TitleBox, title => loc('Access control'), class => 'user-info-access-control' &>
117 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
118 <input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <% ($UserObj->Id && $UserObj->Disabled) ? '' : 'checked="checked"' |n%> />
119 <label for="Enabled"><&|/l&>Let this user access RT</&></label><br />
120
121
122 % my $PrivilegedChecked = ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $ARGS{Privileged})) ? 'checked="checked"' : '';
123 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
124 <input type="checkbox" class="checkbox" id="Privileged" name="Privileged" value="1" <%$PrivilegedChecked|n%> />
125 <label for="Privileged"><&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)</label><br />
126
127 <& /Elements/EditPassword,
128     User => $UserObj,
129     Name => [qw(CurrentPass Pass1 Pass2)],
130 &>
131
132 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
133
134 </&>
135 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
136 </td>
137
138 <td valign="top" class="boxcontainer">
139 <&| /Widgets/TitleBox, title => loc('Location'), class => 'user-info-location' &>
140 <table>
141 <tr><td align="right">
142 <&|/l&>Organization</&>:
143 </td><td>
144 <input name="Organization" value="<%$UserObj->Organization//$ARGS{Organization}//''%>" />
145 </td></tr>
146 <tr><td align="right">
147 <&|/l&>Address1</&>:
148 </td><td>
149 <input name="Address1" value="<%$UserObj->Address1//$ARGS{Address1}//''%>" />
150 </td></tr>
151 <tr><td align="right">
152 <&|/l&>Address2</&>:
153 </td><td>
154 <input name="Address2" value="<%$UserObj->Address2//$ARGS{Address2}//''%>" />
155 </td></tr>
156 <tr><td align="right">
157 <&|/l&>City</&>:
158 </td><td>
159 <input name="City" value="<%$UserObj->City//$ARGS{City}//''%>" size="14" />
160
161 </td></tr>
162 <tr><td align="right">
163 <&|/l&>State</&>:
164 </td><td>
165 <input name="State" value="<%$UserObj->State//$ARGS{State}//''%>" size="3" />
166
167 </td></tr>
168 <tr><td align="right">
169 <&|/l&>Zip</&>:
170 </td><td>
171 <input name="Zip" value="<%$UserObj->Zip//$ARGS{Zip}//''%>" size="9" />
172 </td></tr>
173 <tr><td align="right">
174 <&|/l&>Country</&>:
175 </td><td>
176 <input name="Country" value="<%$UserObj->Country//$ARGS{Country}//''%>" />
177 </td></tr>
178
179 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
180
181 </table>
182 </&>
183 <br />
184 <&| /Widgets/TitleBox, title => loc('Phone numbers'), class => 'user-info-phones' &>
185 <table>
186 <tr><td align="right">
187 <&|/l&>Residence</&>:
188 </td><td>
189 <input name="HomePhone" value="<%$UserObj->HomePhone//$ARGS{HomePhone}//''%>" size="13" /><br />
190 </td></tr>
191 <tr><td align="right">
192 <&|/l&>Work</&>:
193 </td><td>
194 <input name="WorkPhone" value="<%$UserObj->WorkPhone//$ARGS{WorkPhone}//''%>" size="13" /><br />
195 </td></tr>
196 <tr><td align="right">
197 <&|/l&>Mobile</&>:
198 </td><td>
199 <input name="MobilePhone" value="<%$UserObj->MobilePhone//$ARGS{MobilePhone}//''%>" size="13" /><br />
200 </td></tr>
201 <tr><td align="right">
202 <&|/l&>Pager</&>:
203 </td><td>
204 <input name="PagerPhone" value="<%$UserObj->PagerPhone//$ARGS{PagerPhone}//''%>" size="13" /><br />
205 </td>
206 </tr>
207
208 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
209
210 </table>
211 </&>
212 <br />
213
214 <& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
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'), class => 'user-info-comments' &>
221 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments//$ARGS{Comments}//''%></textarea>
222 </&>
223 %if (!$Create && $UserObj->Privileged) {
224 <br />
225 <&| /Widgets/TitleBox, title => loc('Signature'), class => 'user-info-signature' &>
226 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature//$ARGS{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 $UserObj = RT::User->new($session{'CurrentUser'});
244 +my ($title, @results);
245
246 my ($val, $msg);
247
248 $ARGS{Privileged} = $ARGS{Privileged} ? 1 : 0;
249 delete $ARGS{Privileged} unless $ARGS{SetPrivileged};
250
251 $ARGS{Disabled} = $ARGS{Enabled} ? 0 : 1;
252 delete $ARGS{Disabled} unless $ARGS{SetEnabled};
253
254 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
255                 Organization RealName NickName Lang EmailEncoding WebEncoding
256                 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
257                 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
258                 Address2 City State Zip Country Timezone
259                );
260
261 if ($Create) {
262     $title = loc("Create a new user");
263 } elsif ( defined $id && $id eq 'new') {
264     ( $val, $msg ) = $UserObj->Create(
265         (map {($_ => $ARGS{$_})} @fields),
266         Privileged => $ARGS{'Privileged'},
267         Disabled   => $ARGS{'Disabled'},
268     );
269
270     if ($val) {
271         push @results, $msg;
272         push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
273         $title = loc("Modify the user [_1]", $UserObj->Name);
274     } else {
275         push @results, loc('User could not be created: [_1]', $msg);
276         $title = loc("Create a new user");
277         $Create = 1;
278     }
279 } else {
280     $UserObj->Load($id) || $UserObj->Load($ARGS{Name})
281         || Abort("Couldn't load user '" . ( $ARGS{Name} || '') . "'");
282
283     $title = loc("Modify the user [_1]", $UserObj->Name);
284
285     $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
286
287     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
288                                             Object => $UserObj,
289                                             ARGSRef => \%ARGS );
290     push (@results,@fieldresults);
291     push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
292
293     #deal with freeside customer links
294     push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
295
296     if ( defined $ARGS{Privileged} and $ARGS{Privileged} != ($UserObj->Privileged || 0) ) {
297         my ($code, $msg) = $UserObj->SetPrivileged($ARGS{Privileged});
298         push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
299     }
300
301     if ( defined $ARGS{Disabled} and $ARGS{Disabled} != $UserObj->Disabled ) {
302         my ($code, $msg) = $UserObj->SetDisabled($ARGS{Disabled});
303         push @results, $msg;
304     }
305 }
306
307 if ( $UserObj->Id ) {
308     # Deal with Password field
309     my ($status, $msg) = $UserObj->SafeSetPassword(
310         Current      => $CurrentPass,
311         New          => $Pass1,
312         Confirmation => $Pass2,
313     );
314     push @results, $msg;
315
316     if ( $id eq 'new' && !$status ) {
317         push @results, loc("A password was not set, so user won't be able to login.");
318     }
319 }
320
321 # This code does automatic redirection if any updates happen.
322 MaybeRedirectForResults(
323     Actions   => \@results,
324     Arguments => { id => $UserObj->Id },
325 ) if $UserObj->Id;
326
327 </%INIT>
328
329
330 <%ARGS>
331 $id => undef
332 $CurrentPass => undef
333 $Pass1 => undef
334 $Pass2 => undef
335 $Create=> undef
336 $OnlySearchForCustomers => undef
337 $OnlySearchForServices => undef
338 $CustomerString => undef
339 $ServiceString => undef
340 </%ARGS>