This commit was generated by cvs2svn to compensate for changes in r8690,
[freeside.git] / httemplate / pref / pref-process.html
1 % if ( $error ) {
2 %   $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(1). "pref.html?". $cgi->query_string ) %>
4 % } else {
5 <% include('/elements/header.html', 'Preferences updated') %>
6 <% include('/elements/footer.html') %>
7 % }
8 <%init>
9
10 my $error = '';
11 my $access_user = '';
12
13 if ( grep { $cgi->param($_) !~ /^\s*$/ }
14           qw(_password new_password new_password2)
15    ) {
16
17   $access_user = qsearchs( 'access_user', {
18     'username'  => getotaker,
19     '_password' => $cgi->param('_password'),
20   } );
21
22   $error = 'Current password incorrect; password not changed'
23     unless $access_user;
24
25   $error ||= "New passwords don't match"
26     unless $cgi->param('new_password') eq $cgi->param('new_password2');
27
28   $error ||= "No new password entered"
29    unless length($cgi->param('new_password'));
30
31   $access_user->_password($cgi->param('new_password')) unless $error;
32
33 } else {
34
35   $access_user = $FS::CurrentUser::CurrentUser;
36
37 }
38
39 #well, if you got your password change wrong, you don't get anything else
40 #changed right now.  but it should be sticky on the form
41 unless ( $error ) { # if ($access_user) {
42
43   my %param = $access_user->options;
44
45   #XXX autogen
46   my @paramlist = qw( menu_position default_customer_view
47                       email_address
48                       vonage-fromnumber vonage-username vonage-password
49                       show_pkgnum show_db_profile save_db_profile
50                       height width availHeight availWidth colorDepth
51                     );
52
53   foreach (@paramlist) {
54     scalar($cgi->param($_)) =~ /^[,.\-\@\w]*$/ && next;
55     $error ||= "Illegal value for parameter $_";
56     last;
57   }
58
59   foreach (@paramlist) {
60     $param{$_} = scalar($cgi->param($_));
61   }
62
63   $error ||= $access_user->replace( \%param );
64
65 }
66
67 </%init>