1 %# {{{ BEGIN BPS TAGGED BLOCK
5 %# This software is Copyright (c) 1996-2004 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>
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">
94 <&|/l&>Extra info</&>:
96 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
99 <& /Elements/TitleBoxEnd &>
101 <& /Elements/TitleBoxStart, title => loc('Access control') &>
102 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
103 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
104 <&|/l&>Let this user access RT</&><BR>
107 <INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
108 <INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> <&|/l&>Let this user be granted rights</&><BR>
110 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
114 <&|/l&>New Password</&>:
117 <input type=password name="Pass1">
121 <&|/l&>Retype Password</&>:
124 <input type=password name="Pass2">
129 <& /Elements/TitleBoxEnd &>
132 <TD VALIGN=TOP class="boxcontainer">
133 <& /Elements/TitleBoxStart, title => loc('Location') &>
135 <TR><TD ALIGN="RIGHT">
136 <&|/l&>Organization</&>:
138 <input name="Organization" value="<%$UserObj->Organization%>">
140 <TR><TD ALIGN="RIGHT">
143 <input name="Address1" value="<%$UserObj->Address1%>">
145 <TR><TD ALIGN="RIGHT">
148 <input name="Address2" value="<%$UserObj->Address2%>">
150 <TR><TD ALIGN="RIGHT">
153 <input name="City" value="<%$UserObj->City%>" size=14>
156 <TR><TD ALIGN="RIGHT">
159 <input name="State" value="<%$UserObj->State%>" size=3>
162 <TR><TD ALIGN="RIGHT">
165 <input name="Zip" value="<%$UserObj->Zip%>" size=9>
167 <TR><TD ALIGN="RIGHT">
170 <input name="Country" value="<%$UserObj->Country%>">
173 <& /Elements/TitleBoxEnd &>
175 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
177 <TR><TD ALIGN="RIGHT">
178 <&|/l&>Residence</&>:
180 <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
182 <TR><TD ALIGN="RIGHT">
185 <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
187 <TR><TD ALIGN="RIGHT">
190 <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
192 <TR><TD ALIGN="RIGHT">
195 <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
196 <& /Elements/TitleBoxEnd &>
204 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
205 <TEXTAREA name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%>
207 <& /Elements/TitleBoxEnd &>
208 %if ($UserObj->Privileged) {
210 <& /Elements/TitleBoxStart, title => loc('Signature') &>
211 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
212 <%$UserObj->Signature%></TEXTAREA>
213 <& /Elements/TitleBoxEnd &>
220 <& /Elements/Submit, Label => loc('Save Changes') &>
226 my $UserObj = new RT::User($session{'CurrentUser'});
227 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
232 $current_tab = 'Admin/Users/Modify.html?Create=1';
233 $title = loc("Create a new user");
237 $current_tab = 'Admin/Users/Modify.html?id='.$id;
239 ( $val, $msg ) = $UserObj->Create(
241 EmailAddress => $ARGS{'EmailAddress'},
242 Name => $ARGS{'Name'},
243 Comments => $ARGS{'Comments'},
244 Signature => $ARGS{'Signature'},
245 EmailAddress => $ARGS{'EmailAddress'},
246 FreeformContactInfo => $ARGS{'FreeformContactInfo'},
247 Organization => $ARGS{'Organization'},
248 RealName => $ARGS{'RealName'},
249 NickName => $ARGS{'NickName'},
250 Lang => $ARGS{'Lang'},
251 EmailEncoding => $ARGS{'EmailEncoding'},
252 WebEncoding => $ARGS{'WebEncoding'},
253 ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
254 ContactInfoSystem => $ARGS{'ContactInfoSystem'},
255 Gecos => $ARGS{'Gecos'},
256 ExternalAuthId => $ARGS{'ExternalAuthId'},
257 AuthSystem => $ARGS{'AuthSystem'},
258 HomePhone => $ARGS{'HomePhone'},
259 WorkPhone => $ARGS{'WorkPhone'},
260 MobilePhone => $ARGS{'MobilePhone'},
261 PagerPhone => $ARGS{'PagerPhone'},
262 Address1 => $ARGS{'Address1'},
263 Address2 => $ARGS{'Address2'},
264 City => $ARGS{'City'},
265 State => $ARGS{'State'},
267 Country => $ARGS{'Country'},
268 Privileged => $ARGS{'Privileged'},
269 Disabled => ($ARGS{'Enabled'} ? 0 : 1)
274 push @results, loc('User could not be created: [_1]', $msg);
277 # set the id, so the the menu will have the right info
280 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
281 $val = $UserObj->Id();
285 $title = loc("Modify the user [_1]", $UserObj->Name);
288 # If the create failed
290 $title = loc("Create a new user");
299 # If we have a user to modify, lets try.
300 if ($UserObj->Id && $id ne 'new') {
302 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
303 Organization RealName NickName Lang EmailEncoding WebEncoding
304 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
305 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
306 Address2 City State Zip Country
309 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
312 push (@results,@fieldresults);
315 # {{{ Deal with special fields: Privileged, Enabled and Password
316 if ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
317 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
318 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
321 #we're asking about enabled on the web page but really care about disabled.
328 if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
329 my ($code, $msg) = $UserObj->SetDisabled($Disabled);
330 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
334 #TODO: make this report errors properly
335 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
337 ($code, $msg) = $UserObj->SetPassword($Pass1);
338 push @results, loc('Password: [_1]', loc_fuzzy($msg));
339 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
340 push @results, loc("Passwords do not match.");
347 # {{{ Do some setup for the ui
348 unless ($UserObj->Disabled()) {
349 $EnabledChecked ="CHECKED";
352 if ($UserObj->Privileged()) {
353 $PrivilegedChecked = "CHECKED";
365 $EmailAddress => undef
366 $FreeformContactInfo => undef
367 $Organization => undef
371 $SetPrivileged => undef
375 $EmailEncoding => undef
376 $WebEncoding => undef
377 $ExternalContactInfoId => undef
378 $ContactInfoSystem => undef
380 $ExternalAuthId => undef
384 $MobilePhone => undef