import of rt 3.0.4
[freeside.git] / rt / html / User / Prefs.html
1 %# BEGIN LICENSE BLOCK
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
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
10 %# from www.gnu.org.
11 %# 
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.
16 %# 
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.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24 <& /Elements/Header, Title=>loc("Preferences") &>
25 <& /User/Elements/Tabs, 
26     current_tab => 'User/Prefs.html', 
27     Title=>loc("Preferences") &>
28
29 <& /Elements/ListActions, actions => \@results &>
30
31 <FORM ACTION="<%$RT::WebPath%>/User/Prefs.html" METHOD=POST>
32 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
33
34 <TABLE WIDTH=100% BORDER=0>
35 <TR>
36
37 <TD VALIGN=TOP ROWSPAN=2>
38 <& /Elements/TitleBoxStart, title => loc('Identity') &>
39
40 <input type=hidden name="Name" value="<%$UserObj->Name%>">
41 <&|/l&>Email</&>: <input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
42 <BR>
43 <&|/l&>Real Name</&>: <input name="RealName" value="<%$UserObj->RealName%>"> 
44 <BR>
45 <&|/l&>Nickname</&>: <input name="NickName" value="<%$UserObj->NickName%>">
46 <& /Elements/TitleBoxEnd &>
47 <br>
48 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
49 <&|/l&>Residence</&>: <input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13>
50 <BR>
51 <&|/l&>Work</&>: <input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13>
52 <BR>
53 <&|/l&>Mobile</&>: <input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13>
54 <BR>
55 <&|/l&>Pager</&>: <input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13>
56 <& /Elements/TitleBoxEnd &>
57 </TD>
58 <TD VALIGN=TOP>
59 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
60 <& /Elements/TitleBoxStart, title => loc('Password') &>
61 <TABLE>
62 <TR>
63 <TD ALIGN=RIGHT>
64 <&|/l&>New Password</&>:
65 </TD>
66 <TD ALIGN=LEFT>
67 <input type=password name="Pass1">
68 </TD>
69 </TR>
70 <TR><TD ALIGN=RIGHT>
71 <&|/l&>Retype Password</&>:
72 </TD>
73 <TD>
74 <input type=password name="Pass2">
75 </TD>
76 </TR>
77 </TABLE>
78 % }
79 <& /Elements/TitleBoxEnd &>
80 </TD>
81 <TR>
82
83 <TD VALIGN=TOP>
84 <& /Elements/TitleBoxStart, title => loc('Location') &>
85 <&|/l&>Organization</&>: <input name="Organization" value="<%$UserObj->Organization%>">
86 <BR>
87 <&|/l&>Address1</&>: <input name="Address1" value="<%$UserObj->Address1%>">
88 <BR>
89 <&|/l&>Address2</&>: <input name="Address2" value="<%$UserObj->Address2%>">
90 <BR>
91 <&|/l&>City</&>: <input name="City" value="<%$UserObj->City%>" size=14>
92
93 <&|/l&>State</&>: <input name="State" value="<%$UserObj->State%>" size=3>
94
95 <&|/l&>Zip</&>: <input name="Zip" value="<%$UserObj->Zip%>" size=9>
96 <BR>
97 <&|/l&>Country</&>: <input name="Country" value="<%$UserObj->Country%>">
98 <BR>
99
100
101 <& /Elements/TitleBoxEnd &>
102 </TD>
103 </TR>
104 <TR>
105
106
107
108 <TD COLSPAN=2 VALIGN=TOP>
109 %if ($UserObj->Privileged) {
110 <BR>
111 <& /Elements/TitleBoxStart, title => loc('Signature') &>
112 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
113 <%$UserObj->Signature%></TEXTAREA>
114 <& /Elements/TitleBoxEnd &>
115 % }
116
117 </TD>
118
119 </TR>
120 </TABLE>
121
122
123 <& /Elements/Submit &>
124 </form>
125
126
127 <%INIT>
128
129 my $UserObj = new RT::User($session{'CurrentUser'});
130 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
131
132 my ($val, $msg);
133
134
135         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
136         $val = $UserObj->Id();
137     
138
139
140
141
142
143 # If we have a user to modify, lets try. 
144 if ($UserObj->Id) {
145     
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 
151                    );
152     
153     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
154                                             Object => $UserObj,
155                                             ARGSRef => \%ARGS );
156     push (@results,@fieldresults);
157
158
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));
163 }
164
165
166
167 #TODO: make this report errors properly
168 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
169     my ($code, $msg);
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");
174 }
175
176 # }}}
177 }
178
179
180 </%INIT>
181
182
183 <%ARGS>
184 $id => $session{'CurrentUser'}->Id
185 $Name  => undef
186 $Comments  => undef
187 $Signature  => undef
188 $EmailAddress  => undef
189 $FreeformContactInfo => undef
190 $Organization  => undef
191 $RealName  => undef
192 $NickName  => undef
193 $Privileged => undef
194 $SetPrivileged => undef
195 $Enabled => undef
196 $SetEnabled => undef
197 $Lang  => undef
198 $EmailEncoding  => undef
199 $WebEncoding => undef
200 $ExternalContactInfoId  => undef
201 $ContactInfoSystem  => undef
202 $Gecos => undef
203 $ExternalAuthId  => undef
204 $AuthSystem  => undef
205 $HomePhone => undef
206 $WorkPhone  => undef
207 $MobilePhone  => undef
208 $PagerPhone  => undef
209 $Address1 => undef
210 $Address2  => undef
211 $City  => undef
212 $State  => undef
213 $Zip  => undef
214 $Country => undef
215 $Pass1 => undef
216 $Pass2=> undef
217 $Create=> undef
218 </%ARGS>