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 <table callspacing=0 cellpadding=0>
43 <td class=label><&|/l&>Email</&>: </td>
44 <td class=value><input name="EmailAddress" value="<%$UserObj->EmailAddress%>"></td>
47 <td class=label><&|/l&>Real Name</&>:</td>
48 <td class=value><input name="RealName" value="<%$UserObj->RealName%>"></td> </tr>
50 <td class=label><&|/l&>Nickname</&>:</td>
51 <td class=value><input name="NickName" value="<%$UserObj->NickName%>"></td>
54 <td class=label><&|/l&>Language</&>:</td>
55 <td class=value><& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &></td>
58 <& /Elements/TitleBoxEnd &>
60 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
61 <table callspacing=0 cellpadding=0>
63 <td class=label><&|/l&>Residence</&>:</td>
64 <td class=value><input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13></td>
67 <td class=label><&|/l&>Work</&>:</td>
68 <td class=value><input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13></td>
71 <td class=label><&|/l&>Mobile</&>:</td>
72 <td class=value><input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13></td>
75 <td class=label><&|/l&>Pager</&>:</td>
76 <td class=value><input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13></td>
79 <& /Elements/TitleBoxEnd &>
82 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
83 <& /Elements/TitleBoxStart, title => loc('Password') &>
87 <&|/l&>New Password</&>:
90 <input type=password name="Pass1">
94 <&|/l&>Retype Password</&>:
97 <input type=password name="Pass2">
101 <& /Elements/TitleBoxEnd &>
107 <& /Elements/TitleBoxStart, title => loc('Location') &>
108 <table callspacing=0 cellpadding=0>
110 <td class=label><&|/l&>Organization</&>:</td>
111 <td class=value><input name="Organization" value="<%$UserObj->Organization%>"></td>
114 <td class=label><&|/l&>Address1</&>:</td>
115 <td class=value><input name="Address1" value="<%$UserObj->Address1%>"></td>
118 <td class=label><&|/l&>Address2</&>:</td>
119 <td class=value><input name="Address2" value="<%$UserObj->Address2%>"></td>
122 <td class=label><&|/l&>City</&>:</td>
123 <td><input name="City" value="<%$UserObj->City%>" size=14></td>
126 <td class=label><&|/l&>State</&>:</td>
127 <td class=value><input name="State" value="<%$UserObj->State%>" size=3></td>
130 <td class=label><&|/l&>Zip</&>:</td>
131 <td class=value><input name="Zip" value="<%$UserObj->Zip%>" size=9></td>
134 <td class=label><&|/l&>Country</&>:</td>
135 <td class=value><input name="Country" value="<%$UserObj->Country%>"></td>
138 <& /Elements/TitleBoxEnd &>
145 <TD COLSPAN=2 VALIGN=TOP>
146 %if ($UserObj->Privileged) {
148 <& /Elements/TitleBoxStart, title => loc('Signature') &>
149 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
150 <%$UserObj->Signature%></TEXTAREA>
151 <& /Elements/TitleBoxEnd &>
160 <& /Elements/Submit &>
166 my $UserObj = new RT::User($session{'CurrentUser'});
167 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
172 $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
173 $val = $UserObj->Id();
180 # If we have a user to modify, lets try.
183 my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
184 Organization RealName NickName Lang EmailEncoding WebEncoding
185 ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
186 AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
187 Address2 City State Zip Country Lang
190 my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
193 $session{'CurrentUser'}->LanguageHandle($Lang) if $Lang;
194 push (@results,@fieldresults);
197 # {{{ Deal with special fields: Privileged, Enabled and Password
198 if ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
199 my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
200 push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
205 #TODO: make this report errors properly
206 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
208 ($code, $msg) = $UserObj->SetPassword($Pass1);
209 push @results, loc('Password: [_1]', loc_fuzzy($msg));
210 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
211 push @results, loc("Passwords do not match. Your password has not been changed");
222 $id => $session{'CurrentUser'}->Id
226 $EmailAddress => undef
227 $FreeformContactInfo => undef
228 $Organization => undef
232 $SetPrivileged => undef
236 $EmailEncoding => undef
237 $WebEncoding => undef
238 $ExternalContactInfoId => undef
239 $ContactInfoSystem => undef
241 $ExternalAuthId => undef
245 $MobilePhone => undef