1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2007 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/copyleft/gpl.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::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>
109 <&| /Widgets/TitleBox, title => loc('Customers') &>
110 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
114 <&| /Widgets/TitleBox, title => loc('Access control') &>
115 <input type="hidden" class="hidden" name="SetEnabled" value="1" />
116 <input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> />
117 <&|/l&>Let this user access RT</&><br />
120 <input type="hidden" class="hidden" name="SetPrivileged" value="1" />
121 <input type="checkbox" class="checkbox" name="Privileged" value="1" <%$PrivilegedChecked%> /> <&|/l&>Let this user be granted rights</&><br />
123 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
127 <&|/l&>New Password</&>:
130 <input type="password" name="Pass1" />
133 <tr><td align="right">
134 <&|/l&>Retype Password</&>:
137 <input type="password" name="Pass2" />
143 <& /Elements/Callback, _CallbackName => 'LeftColumnBottom', UserObj => $UserObj, %ARGS &>
146 <td valign="top" class="boxcontainer">
147 <&| /Widgets/TitleBox, title => loc('Location') &>
149 <tr><td align="right">
150 <&|/l&>Organization</&>:
152 <input name="Organization" value="<%$UserObj->Organization%>" />
154 <tr><td align="right">
157 <input name="Address1" value="<%$UserObj->Address1%>" />
159 <tr><td align="right">
162 <input name="Address2" value="<%$UserObj->Address2%>" />
164 <tr><td align="right">
167 <input name="City" value="<%$UserObj->City%>" size="14" />
170 <tr><td align="right">
173 <input name="State" value="<%$UserObj->State%>" size="3" />
176 <tr><td align="right">
179 <input name="Zip" value="<%$UserObj->Zip%>" size="9" />
181 <tr><td align="right">
184 <input name="Country" value="<%$UserObj->Country%>" />
189 <&| /Widgets/TitleBox, title => loc('Phone numbers') &>
191 <tr><td align="right">
192 <&|/l&>Residence</&>:
194 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size="13" /><br />
196 <tr><td align="right">
199 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size="13" /><br />
201 <tr><td align="right">
204 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size="13" /><br />
206 <tr><td align="right">
209 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size="13" /><br />
215 <&| /Widgets/TitleBox, title => loc('Custom Fields') &>
217 % my $CFs = $UserObj->CustomFields;
218 % while (my $CF = $CFs->Next) {
219 <tr valign="top"><td align="right">
222 % if ($UserObj->id) {
223 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
225 <& /Elements/EditCustomField, %ARGS, NamePrefix => 'Object-RT::User-new-CustomField-', CustomField => $CF &>
231 <& /Elements/Callback, _CallbackName => 'RightColumnBottom', UserObj => $UserObj, %ARGS &>
235 <&| /Widgets/TitleBox, title => loc('Comments about this user') &>
236 <textarea class="comments" name="Comments" cols="80" rows="5" wrap="virtual"><%$UserObj->Comments%></textarea>
238 %if ($UserObj->Privileged) {
240 <&| /Widgets/TitleBox, title => loc('Signature') &>
241 <textarea class="signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature%></textarea>
249 <& /Elements/Submit, Label => loc('Save Changes') &>
255 my $UserObj = new RT::User($session{'CurrentUser'});
256 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
261 $current_tab = 'Admin/Users/Modify.html?Create=1';
262 $title = loc("Create a new user");
266 $current_tab = 'Admin/Users/Modify.html?id='.$id;
268 ( $val, $msg ) = $UserObj->Create(
270 EmailAddress => $ARGS{'EmailAddress'},
271 Name => $ARGS{'Name'},
272 Comments => $ARGS{'Comments'},
273 Signature => $ARGS{'Signature'},
274 EmailAddress => $ARGS{'EmailAddress'},
275 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
276 Organization => $ARGS{'Organization'},
277 RealName => $ARGS{'RealName'},
278 NickName => $ARGS{'NickName'},
279 Lang => $ARGS{'Lang'},
280 EmailEncoding => $ARGS{'EmailEncoding'},
281 WebEncoding => $ARGS{'WebEncoding'},
282 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
283 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
284 Gecos => $ARGS{'Gecos'},
285 ExternalAuthId => $ARGS{'ExternalAuthId'},
286 AuthSystem => $ARGS{'AuthSystem'},
287 HomePhone => $ARGS{'HomePhone'},
288 WorkPhone => $ARGS{'WorkPhone'},
289 MobilePhone => $ARGS{'MobilePhone'},
290 PagerPhone => $ARGS{'PagerPhone'},
291 Address1 => $ARGS{'Address1'},
292 Address2 => $ARGS{'Address2'},
293 City => $ARGS{'City'},
294 State => $ARGS{'State'},
296 Country => $ARGS{'Country'},
297 Privileged => $ARGS{'Privileged'},
298 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
303 foreach my $key ( keys %ARGS) {
304 # Convert custom fields on the "new" object to custom fields on the one we've just created
305 if ($key =~ /^Object-RT::User-new-CustomField-(.*)$/) {
306 $ARGS{'Object-RT::User-'.$val.'-CustomField-'.$1} = delete $ARGS{$key};
309 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
311 push @results, loc('User could not be created: [_1]', $msg);
314 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
315 $val = $UserObj->Id();
319 $title = loc("Modify the user [_1]", $UserObj->Name);
322 # If the create failed
324 $title = loc("Create a new user");
332 # If we have a user to modify, lets try.
333 if ($UserObj->Id && $id ne 'new') {
335 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
336 Organization RealName NickName Lang EmailEncoding WebEncoding
337 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
338 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
339 Address2 City State Zip Country
342 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
345 push (@results,@fieldresults);
346 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
348 #deal with freeside customer links
349 push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
351 # {{{ Deal with special fields: Privileged, Enabled
352 if ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
353 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
354 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
357 #we're asking about enabled on the web page but really care about disabled.
358 $Disabled = $Enabled ? 0 : 1;
360 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
361 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
362 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
369 if ( $UserObj->Id ) {
370 my $password_not_set;
371 # Deal with Password field
372 if ( !$Pass1 and !$Pass2 ) {
373 $password_not_set = 1;
374 } elsif ( $Pass1 ne $Pass2 ) {
375 $password_not_set = 1;
376 push @results, loc("Passwords do not match.");
377 } elsif ( $Pass1 eq $Pass2 and !$UserObj->IsPassword($Pass1) ) {
378 my ($code, $msg) = $UserObj->SetPassword($Pass1);
379 push @results, loc_fuzzy($msg);
380 $password_not_set = 1 unless $code;
382 if ($id eq 'new' and $password_not_set) {
383 push @results, loc("A password was not set, so user won't be able to login.");
388 # {{{ Do some setup for the ui
389 unless ($UserObj->Disabled()) {
390 $EnabledChecked ="CHECKED";
393 if ($UserObj->Privileged()) {
394 $PrivilegedChecked = "CHECKED";
399 # set the id, so the the menu will have the right info, this needs to
400 # be done here to avoid creating and then modifying a user
411 $EmailAddress => undef
412 $FreeformContactInfo => undef
413 $Organization => undef
417 $SetPrivileged => undef
421 $EmailEncoding => undef
422 $WebEncoding => undef
423 $ExternalContactInfoId => undef
424 $ContactInfoSystem => undef
426 $ExternalAuthId => undef
430 $MobilePhone => undef
441 $OnlySearchForCustomers => undef
442 $OnlySearchForServices => undef
443 $CustomerString => undef
444 $ServiceString => undef