3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
24 <& /Elements/Header, Title=>loc("Preferences") &>
25 <& /User/Elements/Tabs,
26 current_tab => 'User/Prefs.html',
27 Title=>loc("Preferences") &>
29 <& /Elements/ListActions, actions => \@results &>
31 <FORM ACTION="<%$RT::WebPath%>/User/Prefs.html" METHOD=POST>
32 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
34 <TABLE WIDTH=100% BORDER=0>
37 <TD VALIGN=TOP ROWSPAN=2>
38 <& /Elements/TitleBoxStart, title => loc('Identity') &>
40 <input type=hidden name="Name" value="<%$UserObj->Name%>">
41 <&|/l&>Email</&>: <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
43 <&|/l&>Real Name</&>: <input name="RealName" value="<%$UserObj->RealName%>">
45 <&|/l&>Nickname</&>: <input name="NickName" value="<%$UserObj->NickName%>">
46 <& /Elements/TitleBoxEnd &>
48 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
49 <&|/l&>Residence</&>: <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13>
51 <&|/l&>Work</&>: <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13>
53 <&|/l&>Mobile</&>: <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13>
55 <&|/l&>Pager</&>: <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13>
56 <& /Elements/TitleBoxEnd &>
59 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
60 <& /Elements/TitleBoxStart, title => loc('Password') &>
64 <&|/l&>New Password</&>:
67 <input type=password name="Pass1">
71 <&|/l&>Retype Password</&>:
74 <input type=password name="Pass2">
79 <& /Elements/TitleBoxEnd &>
84 <& /Elements/TitleBoxStart, title => loc('Location') &>
85 <&|/l&>Organization</&>: <input name="Organization" value="<%$UserObj->Organization%>">
87 <&|/l&>Address1</&>: <input name="Address1" value="<%$UserObj->Address1%>">
89 <&|/l&>Address2</&>: <input name="Address2" value="<%$UserObj->Address2%>">
91 <&|/l&>City</&>: <input name="City" value="<%$UserObj->City%>" size=14>
93 <&|/l&>State</&>: <input name="State" value="<%$UserObj->State%>" size=3>
95 <&|/l&>Zip</&>: <input name="Zip" value="<%$UserObj->Zip%>" size=9>
97 <&|/l&>Country</&>: <input name="Country" value="<%$UserObj->Country%>">
101 <& /Elements/TitleBoxEnd &>
108 <TD COLSPAN=2 VALIGN=TOP>
109 %if ($UserObj->Privileged) {
111 <& /Elements/TitleBoxStart, title => loc('Signature') &>
112 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
113 <%$UserObj->Signature%></TEXTAREA>
114 <& /Elements/TitleBoxEnd &>
123 <& /Elements/Submit &>
129 my $UserObj = new RT::User($session{'CurrentUser'});
130 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
135 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
136 $val = $UserObj->Id();
143 # If we have a user to modify, lets try.
146 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
147 Organization RealName NickName Lang EmailEncoding WebEncoding
148 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
149 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
150 Address2 City State Zip Country
153 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
156 push (@results,@fieldresults);
159 # {{{ Deal with special fields: Privileged, Enabled and Password
160 if ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
161 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
162 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
167 #TODO: make this report errors properly
168 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
170 ($code, $msg) = $UserObj->SetPassword($Pass1);
171 push @results, loc('Password: [_1]', loc_fuzzy($msg));
172 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
173 push @results, loc("Passwords do not match. Your password has not been changed");
184 $id => $session{'CurrentUser'}->Id
188 $EmailAddress => undef
189 $FreeformContactInfo => undef
190 $Organization => undef
194 $SetPrivileged => undef
198 $EmailEncoding => undef
199 $WebEncoding => undef
200 $ExternalContactInfoId => undef
201 $ContactInfoSystem => undef
203 $ExternalAuthId => undef
207 $MobilePhone => undef