import rt 3.4.6
[freeside.git] / rt / html / User / Prefs.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
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
16 %# from www.gnu.org.
17 %# 
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.
22 %# 
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.
26 %# 
27 %# 
28 %# CONTRIBUTION SUBMISSION POLICY:
29 %# 
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.)
35 %# 
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.
44 %# 
45 %# END BPS TAGGED BLOCK }}}
46 <& /Elements/Header, Title=>loc("Preferences") &>
47 <& /User/Elements/Tabs, 
48     current_tab => 'User/Prefs.html', 
49     Title=>loc("Preferences") &>
50
51 <& /Elements/ListActions, actions => \@results &>
52
53 <FORM ACTION="<%$RT::WebPath%>/User/Prefs.html" METHOD=POST>
54 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
55
56 <TABLE WIDTH=100% BORDER=0>
57 <TR>
58
59 <TD VALIGN=TOP class="boxcontainer">
60 <& /Elements/TitleBoxStart, title => loc('Identity') &>
61
62 <input type=hidden name="Name" value="<%$UserObj->Name%>">
63 <table callspacing=0 cellpadding=0>
64   <tr>
65     <td class=label><&|/l&>Email</&>: </td>
66     <td class=value><input name="EmailAddress" value="<%$UserObj->EmailAddress%>"></td>
67   </tr>
68   <tr>
69     <td class=label><&|/l&>Real Name</&>:</td>
70     <td class=value><input name="RealName" value="<%$UserObj->RealName%>"></td>  </tr>
71   <tr>
72     <td class=label><&|/l&>Nickname</&>:</td>
73     <td class=value><input name="NickName" value="<%$UserObj->NickName%>"></td>
74   </tr>
75   <tr>
76     <td class=label><&|/l&>Language</&>:</td>
77     <td class=value><& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &></td>
78   </tr>
79 </table>
80 <& /Elements/TitleBoxEnd &>
81 <br>
82 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
83 <table callspacing=0 cellpadding=0>
84   <tr>
85     <td class=label><&|/l&>Residence</&>:</td>
86     <td class=value><input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13></td>
87   </tr>
88   <tr>
89     <td class=label><&|/l&>Work</&>:</td>
90     <td class=value><input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13></td>
91   </tr>
92   <tr>
93     <td class=label><&|/l&>Mobile</&>:</td>
94     <td class=value><input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13></td>
95   </tr>
96   <tr>
97     <td class=label><&|/l&>Pager</&>:</td>
98     <td class=value><input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13></td>
99   </tr>
100 </table>
101 <& /Elements/TitleBoxEnd &>
102 </TD>
103 <TD VALIGN=TOP class="boxcontainer">
104 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
105 <& /Elements/TitleBoxStart, title => loc('Password') &>
106 <TABLE>
107 <TR>
108 <TD class=label>
109 <&|/l&>New Password</&>:
110 </TD>
111 <TD class=value>
112 <input type=password name="Pass1">
113 </TD>
114 </TR>
115 <TR><TD class=label>
116 <&|/l&>Retype Password</&>:
117 </TD>
118 <TD class=value>
119 <input type=password name="Pass2">
120 </TD>
121 </TR>
122 </TABLE>
123 <& /Elements/TitleBoxEnd &>
124 % }
125
126 <& /Elements/TitleBoxStart, title => loc('Location') &>
127 <table callspacing=0 cellpadding=0>
128   <tr>
129     <td class=label><&|/l&>Organization</&>:</td>
130     <td class=value><input name="Organization" value="<%$UserObj->Organization%>"></td>
131   </tr>
132   <tr>
133     <td class=label><&|/l&>Address1</&>:</td>
134     <td class=value><input name="Address1" value="<%$UserObj->Address1%>"></td>
135   </tr>
136   <tr>
137     <td class=label><&|/l&>Address2</&>:</td>
138     <td class=value><input name="Address2" value="<%$UserObj->Address2%>"></td>
139   </tr>
140   <tr>
141     <td class=label><&|/l&>City</&>:</td>
142     <td><input name="City" value="<%$UserObj->City%>" size=14></td>
143   </tr>
144   <tr>
145     <td class=label><&|/l&>State</&>:</td>
146     <td class=value><input name="State" value="<%$UserObj->State%>" size=3></td>
147   </tr>
148   <tr>
149     <td class=label><&|/l&>Zip</&>:</td>
150     <td class=value><input name="Zip" value="<%$UserObj->Zip%>" size=9></td>
151   </tr>
152   <tr>
153     <td class=label><&|/l&>Country</&>:</td>
154     <td class=value><input name="Country" value="<%$UserObj->Country%>"></td>
155   </tr>
156 </table>
157 <& /Elements/TitleBoxEnd &>
158 </TD>
159 </TR>
160 <TR>
161
162
163
164 <TD COLSPAN=2 VALIGN=TOP class="boxcontainer">
165 %if ($UserObj->Privileged) {
166 <BR>
167 <& /Elements/TitleBoxStart, title => loc('Signature') &>
168 <TEXTAREA COLS=80 ROWS=5 name="Signature" class="signature" WRAP=HARD>
169 <%$UserObj->Signature%></TEXTAREA>
170 <& /Elements/TitleBoxEnd &>
171 % }
172
173 </TD>
174
175 </TR>
176 </TABLE>
177
178
179 <& /Elements/Submit, Label => loc('Save Preferences') &>
180 </form>
181
182
183 <%INIT>
184
185 my $UserObj = new RT::User($session{'CurrentUser'});
186 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
187
188 my ($val, $msg);
189
190
191         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
192         $val = $UserObj->Id();
193     
194
195
196
197
198
199 # If we have a user to modify, lets try. 
200 if ($UserObj->Id) {
201     
202     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
203                     Organization RealName NickName Lang EmailEncoding WebEncoding 
204                     ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
205                     AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
206                 Address2 City State Zip Country Lang
207                    );
208     
209     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
210                                             Object => $UserObj,
211                                             ARGSRef => \%ARGS );
212     if ($Lang) {
213         $session{'CurrentUser'}->LanguageHandle($Lang);
214         $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
215     }
216
217     push (@results,@fieldresults);
218
219
220 # {{{ Deal with special fields: Privileged, Enabled and Password
221 if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
222 my  ($code, $msg) = $UserObj->SetPrivileged($Privileged);
223      push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
224 }
225
226
227
228 #TODO: make this report errors properly
229 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
230     my ($code, $msg);
231     ($code, $msg) = $UserObj->SetPassword($Pass1);
232     push @results, loc('Password: [_1]', loc_fuzzy($msg));
233 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
234     push @results, loc("Passwords do not match. Your password has not been changed");
235 }
236
237 # }}}
238 }
239
240
241 </%INIT>
242
243
244 <%ARGS>
245 $id => $session{'CurrentUser'}->Id
246 $Name  => undef
247 $Comments  => undef
248 $Signature  => undef
249 $EmailAddress  => undef
250 $FreeformContactInfo => undef
251 $Organization  => undef
252 $RealName  => undef
253 $NickName  => undef
254 $Privileged => undef
255 $SetPrivileged => undef
256 $Enabled => undef
257 $SetEnabled => undef
258 $Lang  => undef
259 $EmailEncoding  => undef
260 $WebEncoding => undef
261 $ExternalContactInfoId  => undef
262 $ContactInfoSystem  => undef
263 $Gecos => undef
264 $ExternalAuthId  => undef
265 $AuthSystem  => undef
266 $HomePhone => undef
267 $WorkPhone  => undef
268 $MobilePhone  => undef
269 $PagerPhone  => undef
270 $Address1 => undef
271 $Address2  => undef
272 $City  => undef
273 $State  => undef
274 $Zip  => undef
275 $Country => undef
276 $Pass1 => undef
277 $Pass2=> undef
278 $Create=> undef
279 </%ARGS>