1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2005 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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 %# CONTRIBUTION SUBMISSION POLICY:
30 %# (The following paragraph is not intended to limit the rights granted
31 %# to you to modify and distribute this software under the terms of
32 %# the GNU General Public License and is only of importance to you if
33 %# you choose to contribute your changes and enhancements to the
34 %# community by submitting them to Best Practical Solutions, LLC.)
36 %# By intentionally submitting any modifications, corrections or
37 %# derivatives to this work, or any other work intended for use with
38 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 %# you are the copyright holder for those contributions and you grant
40 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 %# royalty-free, perpetual, license to use, copy, create derivative
42 %# works based on those contributions, and sublicense and distribute
43 %# those contributions and any derivatives thereof.
45 %# END BPS TAGGED BLOCK }}}
46 <& /Admin/Elements/Header, Title => $title &>
47 <& /Admin/Elements/UserTabs,
50 current_tab => $current_tab,
53 <& /Elements/ListActions, actions => \@results &>
55 <FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
57 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
59 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
61 <TABLE WIDTH=100% BORDER=0>
64 <TD VALIGN=TOP class="boxcontainer">
65 <& /Elements/TitleBoxStart, title => loc('Identity') &>
68 <TR><TD ALIGN="RIGHT">
71 <input name="Name" value="<%$UserObj->Name%>"> <b><&|/l&>(required)</&></b>
73 <TR><TD ALIGN="RIGHT">
76 <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
78 <TR><TD ALIGN="RIGHT">
81 <input name="RealName" value="<%$UserObj->RealName%>">
83 <TR><TD ALIGN="RIGHT">
86 <input name="NickName" value="<%$UserObj->NickName%>">
88 <TR><TD ALIGN="RIGHT">
89 <&|/l&>Unix login</&>:
91 <input name="Gecos" value="<%$UserObj->Gecos%>">
93 <TR><TD ALIGN="RIGHT">
96 <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
98 <TR><TD ALIGN="RIGHT">
99 <&|/l&>Extra info</&>:
101 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
104 <& /Elements/TitleBoxEnd &>
107 <& /Elements/TitleBoxStart, title => loc('Customers') &>
108 <& /Elements/EditCustomers, Object => $UserObj, CustomerString=> $CustomerString, ServiceString => $ServiceString &>
111 <& /Elements/TitleBoxStart, title => loc('Access control') &>
112 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
113 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
114 <&|/l&>Let this user access RT</&><BR>
117 <INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
118 <INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> <&|/l&>Let this user be granted rights</&><BR>
120 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
124 <&|/l&>New Password</&>:
127 <input type=password name="Pass1">
131 <&|/l&>Retype Password</&>:
134 <input type=password name="Pass2">
139 <& /Elements/TitleBoxEnd &>
142 <TD VALIGN=TOP class="boxcontainer">
143 <& /Elements/TitleBoxStart, title => loc('Location') &>
145 <TR><TD ALIGN="RIGHT">
146 <&|/l&>Organization</&>:
148 <input name="Organization" value="<%$UserObj->Organization%>">
150 <TR><TD ALIGN="RIGHT">
153 <input name="Address1" value="<%$UserObj->Address1%>">
155 <TR><TD ALIGN="RIGHT">
158 <input name="Address2" value="<%$UserObj->Address2%>">
160 <TR><TD ALIGN="RIGHT">
163 <input name="City" value="<%$UserObj->City%>" size=14>
166 <TR><TD ALIGN="RIGHT">
169 <input name="State" value="<%$UserObj->State%>" size=3>
172 <TR><TD ALIGN="RIGHT">
175 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
177 <TR><TD ALIGN="RIGHT">
180 <input name="Country" value="<%$UserObj->Country%>">
183 <& /Elements/TitleBoxEnd &>
185 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
187 <TR><TD ALIGN="RIGHT">
188 <&|/l&>Residence</&>:
190 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
192 <TR><TD ALIGN="RIGHT">
195 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
197 <TR><TD ALIGN="RIGHT">
200 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
202 <TR><TD ALIGN="RIGHT">
205 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
206 <& /Elements/TitleBoxEnd &>
213 <& /Elements/TitleBoxStart, title => loc('Custom Fields') &>
215 % my $CFs = $UserObj->CustomFields;
216 % while (my $CF = $CFs->Next) {
217 <TR VALIGN="TOP"><TD ALIGN="RIGHT">
220 <& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
226 <& /Elements/TitleBoxEnd &>
229 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
230 <TEXTAREA class="comments" name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%></TEXTAREA>
231 <& /Elements/TitleBoxEnd &>
232 %if ($UserObj->Privileged) {
234 <& /Elements/TitleBoxStart, title => loc('Signature') &>
235 <TEXTAREA class="signature" COLS=80 ROWS=5 name="Signature" WRAP=HARD><%$UserObj->Signature%></TEXTAREA>
236 <& /Elements/TitleBoxEnd &>
243 <& /Elements/Submit, Label => loc('Save Changes') &>
249 my $UserObj = new RT::User($session{'CurrentUser'});
250 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
255 $current_tab = 'Admin/Users/Modify.html?Create=1';
256 $title = loc("Create a new user");
260 $current_tab = 'Admin/Users/Modify.html?id='.$id;
262 ( $val, $msg ) = $UserObj->Create(
264 EmailAddress => $ARGS{'EmailAddress'},
265 Name => $ARGS{'Name'},
266 Comments => $ARGS{'Comments'},
267 Signature => $ARGS{'Signature'},
268 EmailAddress => $ARGS{'EmailAddress'},
269 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
270 Organization => $ARGS{'Organization'},
271 RealName => $ARGS{'RealName'},
272 NickName => $ARGS{'NickName'},
273 Lang => $ARGS{'Lang'},
274 EmailEncoding => $ARGS{'EmailEncoding'},
275 WebEncoding => $ARGS{'WebEncoding'},
276 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
277 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
278 Gecos => $ARGS{'Gecos'},
279 ExternalAuthId => $ARGS{'ExternalAuthId'},
280 AuthSystem => $ARGS{'AuthSystem'},
281 HomePhone => $ARGS{'HomePhone'},
282 WorkPhone => $ARGS{'WorkPhone'},
283 MobilePhone => $ARGS{'MobilePhone'},
284 PagerPhone => $ARGS{'PagerPhone'},
285 Address1 => $ARGS{'Address1'},
286 Address2 => $ARGS{'Address2'},
287 City => $ARGS{'City'},
288 State => $ARGS{'State'},
290 Country => $ARGS{'Country'},
291 Privileged => $ARGS{'Privileged'},
292 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
298 push @results, loc('User could not be created: [_1]', $msg);
301 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
302 $val = $UserObj->Id();
306 $title = loc("Modify the user [_1]", $UserObj->Name);
309 # If the create failed
311 $title = loc("Create a new user");
319 # If we have a user to modify, lets try.
320 if ($UserObj->Id && $id ne 'new') {
322 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
323 Organization RealName NickName Lang EmailEncoding WebEncoding
324 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
325 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
326 Address2 City State Zip Country
329 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
332 push (@results,@fieldresults);
333 push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
335 #deal with freeside customer links
336 push @results, ProcessObjectCustomers( ARGSRef => \%ARGS, Object => $UserObj );
338 # {{{ Deal with special fields: Privileged, Enabled
339 if ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
340 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
341 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
344 #we're asking about enabled on the web page but really care about disabled.
345 $Disabled = $Enabled ? 0 : 1;
347 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
348 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
349 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
356 if ( $UserObj->Id ) {
357 my $password_not_set;
358 # Deal with Password field
359 if ( !$Pass1 and !$Pass2 ) {
360 $password_not_set = 1;
361 } elsif ( $Pass1 ne $Pass2 ) {
362 $password_not_set = 1;
363 push @results, loc("Passwords do not match.");
364 } elsif ( $Pass1 eq $Pass2 and !$UserObj->IsPassword($Pass1) ) {
365 my ($code, $msg) = $UserObj->SetPassword($Pass1);
366 push @results, loc_fuzzy($msg);
367 $password_not_set = 1 unless $code;
369 if ($id eq 'new' and $password_not_set) {
370 push @results, loc("A password was not set, so user won't be able to login.");
375 # {{{ Do some setup for the ui
376 unless ($UserObj->Disabled()) {
377 $EnabledChecked ="CHECKED";
380 if ($UserObj->Privileged()) {
381 $PrivilegedChecked = "CHECKED";
386 # set the id, so the the menu will have the right info, this needs to
387 # be done here to avoid creating and then modifying a user
398 $EmailAddress => undef
399 $FreeformContactInfo => undef
400 $Organization => undef
404 $SetPrivileged => undef
408 $EmailEncoding => undef
409 $WebEncoding => undef
410 $ExternalContactInfoId => undef
411 $ContactInfoSystem => undef
413 $ExternalAuthId => undef
417 $MobilePhone => undef
428 $OnlySearchForCustomers => undef
429 $OnlySearchForServices => undef
430 $CustomerString => undef
431 $ServiceString => undef