1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %# <jesse@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 &>
49 <& /Admin/Elements/UserTabs,
52 current_tab => $current_tab,
55 <& /Elements/ListActions, actions => \@results &>
57 <form action="<%RT->Config->Get('WebPath')%>/Admin/Users/Modify.html" method="post" enctype="multipart/form-data">
59 <input type="hidden" class="hidden" name="id" value="new" />
61 <input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
63 <table width="100%" border="0">
66 <td valign="top" class="boxcontainer">
67 <&| /Widgets/TitleBox, title => loc('Identity') &>
70 <tr><td align="right">
73 <input name="Name" value="<%$UserObj->Name||''%>" /> <strong><&|/l&>(required)</&></strong>
75 <tr><td align="right">
78 <input name="EmailAddress" value="<%$UserObj->EmailAddress||''%>" />
80 <tr><td align="right">
83 <input name="RealName" value="<%$UserObj->RealName||''%>" />
85 <tr><td align="right">
88 <input name="NickName" value="<%$UserObj->NickName||''%>" />
90 <tr><td align="right">
91 <&|/l&>Unix login</&>:
93 <input name="Gecos" value="<%$UserObj->Gecos||''%>" />
95 <tr><td align="right">
98 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
100 <tr><td align="right">
101 <&|/l&>Extra info</&>:
103 <textarea name="FreeformContactInfo" cols="20" rows="5"><%$UserObj->FreeformContactInfo||''%></textarea>
108 <&| /Widgets/TitleBox, title => loc('Access control') &>
109 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
110 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
111 <&|/l&>Let this user access RT</&><br />
114 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
115 <input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked||''%> /> <&|/l&>Let this user be granted rights</&><br />
117 <& /Elements/EditPassword,
119 Name => [qw(CurrentPass Pass1 Pass2)],
122 % $m->callback( %ARGS, CallbackName => 'LeftColumnBottom', UserObj => $UserObj );
125 <td valign="top" class="boxcontainer">
126 <&| /Widgets/TitleBox, title => loc('Location') &>
128 <tr><td align="right">
129 <&|/l&>Organization</&>:
131 <input name="Organization" value="<%$UserObj->Organization||''%>" />
133 <tr><td align="right">
136 <input name="Address1" value="<%$UserObj->Address1||''%>" />
138 <tr><td align="right">
141 <input name="Address2" value="<%$UserObj->Address2||''%>" />
143 <tr><td align="right">
146 <input name="City" value="<%$UserObj->City||''%>" size="14" />
149 <tr><td align="right">
152 <input name="State" value="<%$UserObj->State||''%>" size="3" />
155 <tr><td align="right">
158 <input name="Zip" value="<%$UserObj->Zip||''%>" size="9" />
160 <tr><td align="right">
163 <input name="Country" value="<%$UserObj->Country||''%>" />
168 <&| /Widgets/TitleBox, title => loc('Phone numbers') &>
170 <tr><td align="right">
171 <&|/l&>Residence</&>:
173 <input name="HomePhone" value="<%$UserObj->HomePhone||''%>" size="13" /><br />
175 <tr><td align="right">
178 <input name="WorkPhone" value="<%$UserObj->WorkPhone||''%>" size="13" /><br />
180 <tr><td align="right">
183 <input name="MobilePhone" value="<%$UserObj->MobilePhone||''%>" size="13" /><br />
185 <tr><td align="right">
188 <input name="PagerPhone" value="<%$UserObj->PagerPhone||''%>" size="13" /><br />
194 <&| /Widgets/TitleBox, title => loc('Custom Fields') &>
196 % my $CFs = $UserObj->CustomFields;
197 % while (my $CF = $CFs->Next) {
198 <tr valign="top"><td align="right">
199 <% loc($CF->Name) %>:
201 % if ($UserObj->id) {
202 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
204 <& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User-new-CustomField-', CustomField => $CF &>
210 % $m->callback( %ARGS, CallbackName => 'RightColumnBottom', UserObj => $UserObj );
214 <&| /Widgets/TitleBox, title => loc('Comments about this user') &>
215 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments||''%></textarea>
217 %if (!$Create && $UserObj->Privileged) {
219 <&| /Widgets/TitleBox, title => loc('Signature') &>
220 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature||''%></textarea>
229 <& /Elements/Submit, Label => loc('Create') &>
231 <& /Elements/Submit, Label => loc('Save Changes') &>
238 my $UserObj = new RT::User($session{'CurrentUser'});
239 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
244 $current_tab = 'Admin/Users/Modify.html?Create=1';
245 $title = loc("Create a new user");
249 $current_tab = 'Admin/Users/Modify.html?id='.$id if $id;
251 if ( defined $id && $id eq 'new') {
252 ( $val, $msg ) = $UserObj->Create(
254 EmailAddress => $ARGS{'EmailAddress'},
255 Name => $ARGS{'Name'},
256 Comments => $ARGS{'Comments'},
257 Signature => $ARGS{'Signature'},
258 EmailAddress => $ARGS{'EmailAddress'},
259 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
260 Organization => $ARGS{'Organization'},
261 RealName => $ARGS{'RealName'},
262 NickName => $ARGS{'NickName'},
263 Lang => $ARGS{'Lang'},
264 EmailEncoding => $ARGS{'EmailEncoding'},
265 WebEncoding => $ARGS{'WebEncoding'},
266 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
267 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
268 Gecos => $ARGS{'Gecos'},
269 ExternalAuthId => $ARGS{'ExternalAuthId'},
270 AuthSystem => $ARGS{'AuthSystem'},
271 HomePhone => $ARGS{'HomePhone'},
272 WorkPhone => $ARGS{'WorkPhone'},
273 MobilePhone => $ARGS{'MobilePhone'},
274 PagerPhone => $ARGS{'PagerPhone'},
275 Address1 => $ARGS{'Address1'},
276 Address2 => $ARGS{'Address2'},
277 City => $ARGS{'City'},
278 State => $ARGS{'State'},
280 Country => $ARGS{'Country'},
281 Privileged => $ARGS{'Privileged'},
282 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
287 foreach my $key ( keys %ARGS) {
288 # Convert custom fields on the "new" object to custom fields on the one we've just created
289 if ($key =~ /^Object-RT::User-new-CustomField-(.*)$/) {
290 $ARGS{'Object-RT::User-'.$val.'-CustomField-'.$1} = delete $ARGS{$key};
293 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
295 push @results, loc('User could not be created: [_1]', $msg);
298 $UserObj->Load($id) || $UserObj->Load($Name)
299 || Abort("Couldn't load user '" . ( $Name || '') . "'");
300 $val = $UserObj->Id();
304 $title = loc("Modify the user [_1]", $UserObj->Name);
307 # If the create failed
309 $title = loc("Create a new user");
317 # If we have a user to modify, lets try.
318 if ($UserObj->Id && $id ne 'new') {
320 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
321 Organization RealName NickName Lang EmailEncoding WebEncoding
322 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
323 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
324 Address2 City State Zip Country
327 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
330 push (@results,@fieldresults);
331 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
334 # {{{ Deal with special fields: Privileged, Enabled
335 if ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
336 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
337 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
340 #we're asking about enabled on the web page but really care about disabled.
341 $Disabled = $Enabled ? 0 : 1;
343 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
344 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
353 my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
354 if ( $UserObj->Id ) {
355 # Deal with Password field
356 my ($status, $msg) = $UserObj->SafeSetPassword(
357 Current => $CurrentPass,
359 Confirmation => $Pass2,
363 if ( $id eq 'new' && !$status ) {
364 push @results, loc("A password was not set, so user won't be able to login.");
369 # Do some setup for the ui
370 unless ( $UserObj->id && $UserObj->Disabled ) {
371 $EnabledChecked = 'checked="checked"';
374 if (!$Create && $UserObj->Privileged()) {
375 $PrivilegedChecked = 'checked="checked"';
378 # set the id, so the the menu will have the right info, this needs to
379 # be done here to avoid creating and then modifying a user
390 $EmailAddress => undef
391 $FreeformContactInfo => undef
392 $Organization => undef
396 $SetPrivileged => undef
400 $EmailEncoding => undef
401 $WebEncoding => undef
402 $ExternalContactInfoId => undef
403 $ContactInfoSystem => undef
405 $ExternalAuthId => undef
409 $MobilePhone => undef
417 $CurrentPass => undef