import rt 3.8.9
[freeside.git] / rt / html / User / Prefs.html
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %# 
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title=>loc("Preferences") &>
49 <& /User/Elements/Tabs, 
50     current_tab => 'User/Prefs.html', 
51     Title=>loc("Preferences") &>
52
53 <& /Elements/ListActions, actions => \@results &>
54
55 <form action="<%$RT::WebPath%>/User/Prefs.html" method="post">
56 <input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
57
58 <table width="100%" border="0">
59 <tr>
60
61 <td valign="top" class="boxcontainer">
62 <&| /Widgets/TitleBox, title => loc('Identity'), id => "user-prefs-identity" &>
63
64 <input type="hidden" class="hidden" name="Name" value="<%$UserObj->Name%>" />
65 <table cellspacing="0" cellpadding="0">
66   <tr>
67     <td class="label"><&|/l&>Email</&>: </td>
68     <td class="value"><input name="EmailAddress" value="<%$UserObj->EmailAddress%>" /></td>
69   </tr>
70   <tr>
71     <td class="label"><&|/l&>Real Name</&>:</td>
72     <td class="value"><input name="RealName" value="<%$UserObj->RealName%>" /></td>  </tr>
73   <tr>
74     <td class="label"><&|/l&>Nickname</&>:</td>
75     <td class="value"><input name="NickName" value="<%$UserObj->NickName%>" /></td>
76   </tr>
77   <tr>
78     <td class="label"><&|/l&>Language</&>:</td>
79     <td class="value"><& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &></td>
80   </tr>
81 </table>
82 </&>
83 <&| /Widgets/TitleBox, title => loc('Phone numbers'), id => "user-prefs-phone" &>
84 <table cellspacing="0" cellpadding="0">
85   <tr>
86     <td class="label"><&|/l&>Residence</&>:</td>
87     <td class="value"><input name="HomePhone" value="<%$UserObj->HomePhone%>" size="13" /></td>
88   </tr>
89   <tr>
90     <td class="label"><&|/l&>Work</&>:</td>
91     <td class="value"><input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size="13" /></td>
92   </tr>
93   <tr>
94     <td class="label"><&|/l&>Mobile</&>:</td>
95     <td class="value"><input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size="13" /></td>
96   </tr>
97   <tr>
98     <td class="label"><&|/l&>Pager</&>:</td>
99     <td class="value"><input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size="13" /></td>
100   </tr>
101 </table>
102 </&>
103 <& /Elements/Callback, _CallbackName => 'FormLeftColumn', UserObj => $UserObj, %ARGS &>
104 </td>
105 <td valign="top" class="boxcontainer">
106 % unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
107 <&| /Widgets/TitleBox, title => loc('Password'), id => "user-prefs-password" &>
108 <table>
109 <tr>
110 <td class="label">
111 <&|/l&>New Password</&>:
112 </td>
113 <td class="value">
114 <input type="password" name="Pass1" />
115 </td>
116 </tr>
117 <tr><td class="label">
118 <&|/l&>Retype Password</&>:
119 </td>
120 <td class="value">
121 <input type="password" name="Pass2" />
122 </td>
123 </tr>
124 </table>
125 </&>
126 % }
127
128 <&| /Widgets/TitleBox, title => loc('Location'), id => "user-prefs-location" &>
129 <table cellspacing="0" cellpadding="0">
130   <tr>
131     <td class="label"><&|/l&>Organization</&>:</td>
132     <td class="value"><input name="Organization" value="<%$UserObj->Organization%>" /></td>
133   </tr>
134   <tr>
135     <td class="label"><&|/l&>Address1</&>:</td>
136     <td class="value"><input name="Address1" value="<%$UserObj->Address1%>" /></td>
137   </tr>
138   <tr>
139     <td class="label"><&|/l&>Address2</&>:</td>
140     <td class="value"><input name="Address2" value="<%$UserObj->Address2%>" /></td>
141   </tr>
142   <tr>
143     <td class="label"><&|/l&>City</&>:</td>
144     <td><input name="City" value="<%$UserObj->City%>" size="14" /></td>
145   </tr>
146   <tr>
147     <td class="label"><&|/l&>State</&>:</td>
148     <td class="value"><input name="State" value="<%$UserObj->State%>" size="3" /></td>
149   </tr>
150   <tr>
151     <td class="label"><&|/l&>Zip</&>:</td>
152     <td class="value"><input name="Zip" value="<%$UserObj->Zip%>" size="9" /></td>
153   </tr>
154   <tr>
155     <td class="label"><&|/l&>Country</&>:</td>
156     <td class="value"><input name="Country" value="<%$UserObj->Country%>" /></td>
157   </tr>
158 </table>
159 </&>
160 <& /Elements/Callback, _CallbackName => 'FormRightColumn', UserObj => $UserObj, %ARGS &>
161 </td>
162 </tr>
163 <tr>
164
165
166
167 <td colspan="2" valign="top" class="boxcontainer">
168 %if ($UserObj->Privileged) {
169 <br />
170 <&| /Widgets/TitleBox, title => loc('Signature') &>
171 <textarea cols="80" rows="5" name="Signature" class="signature" wrap="hard">
172 <%$UserObj->Signature%></textarea>
173 </&>
174 % }
175
176 </td>
177
178 </tr>
179 </table>
180
181 <& /Elements/Callback, _CallbackName => 'FormEnd', UserObj => $UserObj, %ARGS &>
182
183 <& /Elements/Submit, Label => loc('Save Preferences') &>
184 </form>
185
186
187 <%INIT>
188
189 my $UserObj = new RT::User($session{'CurrentUser'});
190 my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
191
192 my ($val, $msg);
193
194
195         $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
196         $val = $UserObj->Id();
197     
198
199
200
201
202
203 # If we have a user to modify, lets try. 
204 if ($UserObj->Id) {
205     
206     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
207                     Organization RealName NickName Lang EmailEncoding WebEncoding 
208                     ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
209                     AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
210                 Address2 City State Zip Country Lang
211                    );
212
213     $m->comp('/Elements/Callback', _CallbackName => 'UpdateLogic',
214                                     fields        => \@fields,
215                                     results       => \@results,
216                                     UserObj       => $UserObj,
217                                     ARGSRef       => \%ARGS);
218     
219     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
220                                             Object => $UserObj,
221                                             ARGSRef => \%ARGS );
222     if ($Lang) {
223         $session{'CurrentUser'}->LanguageHandle($Lang);
224         $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
225     }
226
227     push (@results,@fieldresults);
228
229
230 # {{{ Deal with special fields: Privileged, Enabled and Password
231 if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
232 my  ($code, $msg) = $UserObj->SetPrivileged($Privileged);
233      push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
234 }
235
236
237
238 #TODO: make this report errors properly
239 if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
240     my ($code, $msg);
241     ($code, $msg) = $UserObj->SetPassword($Pass1);
242     push @results, loc('Password: [_1]', loc_fuzzy($msg));
243 } elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
244     push @results, loc("Passwords do not match. Your password has not been changed");
245 }
246
247 # }}}
248 }
249
250
251 </%INIT>
252
253
254 <%ARGS>
255 $id => $session{'CurrentUser'}->Id
256 $Name  => undef
257 $Comments  => undef
258 $Signature  => undef
259 $EmailAddress  => undef
260 $FreeformContactInfo => undef
261 $Organization  => undef
262 $RealName  => undef
263 $NickName  => undef
264 $Privileged => undef
265 $SetPrivileged => undef
266 $Enabled => undef
267 $SetEnabled => undef
268 $Lang  => undef
269 $EmailEncoding  => undef
270 $WebEncoding => undef
271 $ExternalContactInfoId  => undef
272 $ContactInfoSystem  => undef
273 $Gecos => undef
274 $ExternalAuthId  => undef
275 $AuthSystem  => undef
276 $HomePhone => undef
277 $WorkPhone  => undef
278 $MobilePhone  => undef
279 $PagerPhone  => undef
280 $Address1 => undef
281 $Address2  => undef
282 $City  => undef
283 $State  => undef
284 $Zip  => undef
285 $Country => undef
286 $Pass1 => undef
287 $Pass2=> undef
288 $Create=> undef
289 </%ARGS>