import rt 3.0.12
[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 <table callspacing=0 cellpadding=0>
42   <tr>
43     <td class=label><&|/l&>Email</&>: </td>
44     <td class=value><input name="EmailAddress" value="<%$UserObj->EmailAddress%>"></td>
45   </tr>
46   <tr>
47     <td class=label><&|/l&>Real Name</&>:</td>
48     <td class=value><input name="RealName" value="<%$UserObj->RealName%>"></td>  </tr>
49   <tr>
50     <td class=label><&|/l&>Nickname</&>:</td>
51     <td class=value><input name="NickName" value="<%$UserObj->NickName%>"></td>
52   </tr>
53   <tr>
54     <td class=label><&|/l&>Language</&>:</td>
55     <td class=value><& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &></td>
56   </tr>
57 </table>
58 <& /Elements/TitleBoxEnd &>
59 <br>
60 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
61 <table callspacing=0 cellpadding=0>
62   <tr>
63     <td class=label><&|/l&>Residence</&>:</td>
64     <td class=value><input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13></td>
65   </tr>
66   <tr>
67     <td class=label><&|/l&>Work</&>:</td>
68     <td class=value><input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13></td>
69   </tr>
70   <tr>
71     <td class=label><&|/l&>Mobile</&>:</td>
72     <td class=value><input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13></td>
73   </tr>
74   <tr>
75     <td class=label><&|/l&>Pager</&>:</td>
76     <td class=value><input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13></td>
77   </tr>
78 </table>
79 <& /Elements/TitleBoxEnd &>
80 </TD>
81 <TD VALIGN=TOP>
82 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
83 <& /Elements/TitleBoxStart, title => loc('Password') &>
84 <TABLE>
85 <TR>
86 <TD class=label>
87 <&|/l&>New Password</&>:
88 </TD>
89 <TD class=value>
90 <input type=password name="Pass1">
91 </TD>
92 </TR>
93 <TR><TD class=label>
94 <&|/l&>Retype Password</&>:
95 </TD>
96 <TD class=value>
97 <input type=password name="Pass2">
98 </TD>
99 </TR>
100 </TABLE>
101 <& /Elements/TitleBoxEnd &>
102 % }
103 </TD>
104 <TR>
105
106 <TD VALIGN=TOP>
107 <& /Elements/TitleBoxStart, title => loc('Location') &>
108 <table callspacing=0 cellpadding=0>
109   <tr>
110     <td class=label><&|/l&>Organization</&>:</td>
111     <td class=value><input name="Organization" value="<%$UserObj->Organization%>"></td>
112   </tr>
113   <tr>
114     <td class=label><&|/l&>Address1</&>:</td>
115     <td class=value><input name="Address1" value="<%$UserObj->Address1%>"></td>
116   </tr>
117   <tr>
118     <td class=label><&|/l&>Address2</&>:</td>
119     <td class=value><input name="Address2" value="<%$UserObj->Address2%>"></td>
120   </tr>
121   <tr>
122     <td class=label><&|/l&>City</&>:</td>
123     <td><input name="City" value="<%$UserObj->City%>" size=14></td>
124   </tr>
125   <tr>
126     <td class=label><&|/l&>State</&>:</td>
127     <td class=value><input name="State" value="<%$UserObj->State%>" size=3></td>
128   </tr>
129   <tr>
130     <td class=label><&|/l&>Zip</&>:</td>
131     <td class=value><input name="Zip" value="<%$UserObj->Zip%>" size=9></td>
132   </tr>
133   <tr>
134     <td class=label><&|/l&>Country</&>:</td>
135     <td class=value><input name="Country" value="<%$UserObj->Country%>"></td>
136   </tr>
137 </table>
138 <& /Elements/TitleBoxEnd &>
139 </TD>
140 </TR>
141 <TR>
142
143
144
145 <TD COLSPAN=2 VALIGN=TOP>
146 %if ($UserObj->Privileged) {
147 <BR>
148 <& /Elements/TitleBoxStart, title => loc('Signature') &>
149 <TEXTAREA COLS=80 ROWS=5 name="Signature" WRAP=HARD>
150 <%$UserObj->Signature%></TEXTAREA>
151 <& /Elements/TitleBoxEnd &>
152 % }
153
154 </TD>
155
156 </TR>
157 </TABLE>
158
159
160 <& /Elements/Submit, Label => loc('Save Preferences') &>
161 </form>
162
163
164 <%INIT>
165
166 my $UserObj = new RT::User($session{'CurrentUser'});
167 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
168
169 my ($val, $msg);
170
171
172         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
173         $val = $UserObj->Id();
174     
175
176
177
178
179
180 # If we have a user to modify, lets try. 
181 if ($UserObj->Id) {
182     
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
188                    );
189     
190     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
191                                             Object => $UserObj,
192                                             ARGSRef => \%ARGS );
193     if ($Lang) {
194         $session{'CurrentUser'}->LanguageHandle($Lang);
195         $session{'CurrentUser'}= $session{'CurrentUser'}; # Force writeback
196     }
197     push (@results,@fieldresults);
198
199
200 # {{{ Deal with special fields: Privileged, Enabled and Password
201 if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
202 my  ($code, $msg) = $UserObj->SetPrivileged($Privileged);
203      push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
204 }
205
206
207
208 #TODO: make this report errors properly
209 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
210     my ($code, $msg);
211     ($code, $msg) = $UserObj->SetPassword($Pass1);
212     push @results, loc('Password: [_1]', loc_fuzzy($msg));
213 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
214     push @results, loc("Passwords do not match. Your password has not been changed");
215 }
216
217 # }}}
218 }
219
220
221 </%INIT>
222
223
224 <%ARGS>
225 $id => $session{'CurrentUser'}->Id
226 $Name  => undef
227 $Comments  => undef
228 $Signature  => undef
229 $EmailAddress  => undef
230 $FreeformContactInfo => undef
231 $Organization  => undef
232 $RealName  => undef
233 $NickName  => undef
234 $Privileged => undef
235 $SetPrivileged => undef
236 $Enabled => undef
237 $SetEnabled => undef
238 $Lang  => undef
239 $EmailEncoding  => undef
240 $WebEncoding => undef
241 $ExternalContactInfoId  => undef
242 $ContactInfoSystem  => undef
243 $Gecos => undef
244 $ExternalAuthId  => undef
245 $AuthSystem  => undef
246 $HomePhone => undef
247 $WorkPhone  => undef
248 $MobilePhone  => undef
249 $PagerPhone  => undef
250 $Address1 => undef
251 $Address2  => undef
252 $City  => undef
253 $State  => undef
254 $Zip  => undef
255 $Country => undef
256 $Pass1 => undef
257 $Pass2=> undef
258 $Create=> undef
259 </%ARGS>