1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Admin/Elements/Header, Title => $title &>
51 <& /Elements/ListActions, actions => \@results &>
53 <form action="<%RT->Config->Get('WebPath')%>/Admin/Users/Modify.html" method="post" enctype="multipart/form-data">
55 <input type="hidden" class="hidden" name="id" value="new" />
57 <input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
59 <table width="100%" border="0">
62 <td valign="top" class="boxcontainer">
63 <&| /Widgets/TitleBox, title => loc('Identity') &>
66 <tr><td align="right">
69 <input name="Name" value="<%$UserObj->Name||$Name||''%>" /> <strong><&|/l&>(required)</&></strong>
71 <tr><td align="right">
74 <input name="EmailAddress" value="<%$UserObj->EmailAddress||$EmailAddress||''%>" />
76 <tr><td align="right">
79 <input name="RealName" value="<%$UserObj->RealName||$RealName||''%>" />
81 <tr><td align="right">
84 <input name="NickName" value="<%$UserObj->NickName||$NickName||''%>" />
86 <tr><td align="right">
87 <&|/l&>Unix login</&>:
89 <input name="Gecos" value="<%$UserObj->Gecos||$Gecos||''%>" />
91 <tr><td align="right">
94 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang||$Lang &>
96 <tr><td align="right">
97 <&|/l&>Extra info</&>:
99 <textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo||$FreeformContactInfo||''%></textarea>
105 <&| /Widgets/TitleBox, title => loc('Customers') &>
106 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
110 <&| /Widgets/TitleBox, title => loc('Access control') &>
111 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
112 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
113 <&|/l&>Let this user access RT</&><br />
116 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
117 <input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked||''%> /> <&|/l&>Let this user be granted rights</&> (<&|/l&>Privileged</&>)<br />
119 <& /Elements/EditPassword,
121 Name => [qw(CurrentPass Pass1 Pass2)],
124 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
127 <td valign="top" class="boxcontainer">
128 <&| /Widgets/TitleBox, title => loc('Location') &>
130 <tr><td align="right">
131 <&|/l&>Organization</&>:
133 <input name="Organization" value="<%$UserObj->Organization||$Organization||''%>" />
135 <tr><td align="right">
138 <input name="Address1" value="<%$UserObj->Address1||$Address1||''%>" />
140 <tr><td align="right">
143 <input name="Address2" value="<%$UserObj->Address2||$Address2||''%>" />
145 <tr><td align="right">
148 <input name="City" value="<%$UserObj->City||$City||''%>" size="14" />
151 <tr><td align="right">
154 <input name="State" value="<%$UserObj->State||$State||''%>" size="3" />
157 <tr><td align="right">
160 <input name="Zip" value="<%$UserObj->Zip||$Zip||''%>" size="9" />
162 <tr><td align="right">
165 <input name="Country" value="<%$UserObj->Country||$Country||''%>" />
170 <&| /Widgets/TitleBox, title => loc('Phone numbers') &>
172 <tr><td align="right">
173 <&|/l&>Residence</&>:
175 <input name="HomePhone" value="<%$UserObj->HomePhone||$HomePhone||''%>" size="13" /><br />
177 <tr><td align="right">
180 <input name="WorkPhone" value="<%$UserObj->WorkPhone||$WorkPhone||''%>" size="13" /><br />
182 <tr><td align="right">
185 <input name="MobilePhone" value="<%$UserObj->MobilePhone||$MobilePhone||''%>" size="13" /><br />
187 <tr><td align="right">
190 <input name="PagerPhone" value="<%$UserObj->PagerPhone||$PagerPhone||''%>" size="13" /><br />
196 <&| /Widgets/TitleBox, title => loc('Custom Fields') &>
198 % my $CFs = $UserObj->CustomFields;
199 % while (my $CF = $CFs->Next) {
200 <tr valign="top"><td align="right">
201 <% loc($CF->Name) %>:
203 % if ($UserObj->id) {
204 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
206 <& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User--CustomField-', CustomField => $CF &>
212 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
216 <&| /Widgets/TitleBox, title => loc('Comments about this user') &>
217 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments||$Comments||''%></textarea>
219 %if (!$Create && $UserObj->Privileged) {
221 <&| /Widgets/TitleBox, title => loc('Signature') &>
222 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature||$Signature||''%></textarea>
231 <& /Elements/Submit, Label => loc('Create') &>
233 <& /Elements/Submit, Label => loc('Save Changes') &>
239 my $UserObj = RT::User->new($session{'CurrentUser'});
240 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
245 $title = loc("Create a new user");
249 if ( defined $id && $id eq 'new') {
250 ( $val, $msg ) = $UserObj->Create(
252 EmailAddress => $ARGS{'EmailAddress'},
253 Name => $ARGS{'Name'},
254 Comments => $ARGS{'Comments'},
255 Signature => $ARGS{'Signature'},
256 EmailAddress => $ARGS{'EmailAddress'},
257 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
258 Organization => $ARGS{'Organization'},
259 RealName => $ARGS{'RealName'},
260 NickName => $ARGS{'NickName'},
261 Lang => $ARGS{'Lang'},
262 EmailEncoding => $ARGS{'EmailEncoding'},
263 WebEncoding => $ARGS{'WebEncoding'},
264 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
265 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
266 Gecos => $ARGS{'Gecos'},
267 ExternalAuthId => $ARGS{'ExternalAuthId'},
268 AuthSystem => $ARGS{'AuthSystem'},
269 HomePhone => $ARGS{'HomePhone'},
270 WorkPhone => $ARGS{'WorkPhone'},
271 MobilePhone => $ARGS{'MobilePhone'},
272 PagerPhone => $ARGS{'PagerPhone'},
273 Address1 => $ARGS{'Address1'},
274 Address2 => $ARGS{'Address2'},
275 City => $ARGS{'City'},
276 State => $ARGS{'State'},
278 Country => $ARGS{'Country'},
279 Privileged => $ARGS{'Privileged'},
280 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
285 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
287 push @results, loc('User could not be created: [_1]', $msg);
290 $UserObj->Load($id) || $UserObj->Load($Name)
291 || Abort("Couldn't load user '" . ( $Name || '') . "'");
292 $val = $UserObj->Id();
296 $title = loc("Modify the user [_1]", $UserObj->Name);
299 # If the create failed
301 $title = loc("Create a new user");
307 $m->callback( %ARGS, CallbackName => 'BeforeUpdate', User => $UserObj, ARGSRef => \%ARGS, Results => \@results );
310 # If we have a user to modify, lets try.
311 if ($UserObj->Id && $id ne 'new') {
313 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
314 Organization RealName NickName Lang EmailEncoding WebEncoding
315 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
316 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
317 Address2 City State Zip Country
320 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
323 push (@results,@fieldresults);
324 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
326 #deal with freeside customer links
327 push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
329 # {{{ Deal with special fields: Privileged, Enabled
330 if ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
331 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
332 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
335 #we're asking about enabled on the web page but really care about disabled.
336 $Disabled = $Enabled ? 0 : 1;
338 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
339 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
347 my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
348 if ( $UserObj->Id ) {
349 # Deal with Password field
350 my ($status, $msg) = $UserObj->SafeSetPassword(
351 Current => $CurrentPass,
353 Confirmation => $Pass2,
357 if ( $id eq 'new' && !$status ) {
358 push @results, loc("A password was not set, so user won't be able to login.");
363 # Do some setup for the ui
364 unless ( $UserObj->id && $UserObj->Disabled ) {
365 $EnabledChecked = 'checked="checked"';
368 if ((!$Create && $UserObj->Privileged()) or (!$UserObj->Id and $Privileged)) {
369 $PrivilegedChecked = 'checked="checked"';
372 # This code does automatic redirection if any updates happen.
373 MaybeRedirectForResults(
374 Actions => \@results,
375 Arguments => { id => $UserObj->Id },
386 $EmailAddress => undef
387 $FreeformContactInfo => undef
388 $Organization => undef
392 $SetPrivileged => undef
396 $EmailEncoding => undef
397 $WebEncoding => undef
398 $ExternalContactInfoId => undef
399 $ContactInfoSystem => undef
401 $ExternalAuthId => undef
405 $MobilePhone => undef
413 $CurrentPass => undef
417 $OnlySearchForCustomers => undef
418 $OnlySearchForServices => undef
419 $CustomerString => undef
420 $ServiceString => undef