RT#38983: OBL - searching in Fibernetics Freeside [removed enable_fuzzy_on_exact]
[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 $access_user = $FS::CurrentUser::CurrentUser;
11
12 if ( FS::Conf->new->exists('disable_acl_changes') ) {
13   errorpage("Preference changes disabled in public demo");
14   die "shouldn't be reached";
15 }
16
17 my $error = '';
18
19 if ( FS::Auth->auth_class->can('change_password')
20        && grep { $cgi->param($_) !~ /^\s*$/ }
21             qw(_password new_password new_password2)
22    ) {
23
24   my $oldpass = $cgi->param('_password');
25   my $newpass = $cgi->param('new_password');
26
27   if ( $newpass ne $cgi->param('new_password2') ) {
28     $error = "New passwords don't match";
29
30   } elsif ( ! length($newpass) ) {
31     $error = 'No new password entered';
32
33   } elsif ( ! FS::Auth->authenticate( $access_user, $oldpass ) ) {
34     $error = 'Current password incorrect; password not changed';
35
36   } else {
37
38     $error = $access_user->is_password_allowed($newpass)
39           || $access_user->change_password($newpass);
40
41   }
42
43 }
44
45 #well, if you got your password change wrong, you don't get anything else
46 #changed right now.  but it should be sticky on the form
47 unless ( $error ) { # if ($access_user) {
48
49   my %param = $access_user->options;
50
51   #XXX autogen
52   my @paramlist = qw( locale menu_position default_customer_view 
53                       history_order
54                       spreadsheet_format mobile_menu
55                       disable_html_editor disable_enter_submit_onetimecharge
56                       enable_mask_clipboard_hack dashboard_customers
57                       customer_view_emails
58                       email_address
59                       snom-ip snom-username snom-password
60                       vonage-fromnumber vonage-username vonage-password
61                       cust_pkg-display_times
62                       show_pkgnum show_confitem_counts export_getsettings
63                       show_db_profile save_db_profile save_tmp_typesetting
64                       height width availHeight availWidth colorDepth
65                     );
66
67   foreach (@paramlist) {
68     scalar($cgi->param($_)) =~ /^[,.\-\@\w]*$/ && next;
69     $error ||= "Illegal value for parameter $_";
70     last;
71   }
72
73   foreach (@paramlist) {
74     $param{$_} = scalar($cgi->param($_));
75   }
76
77   $error ||= $access_user->replace( \%param );
78
79 }
80
81 if ( !$error and ($FS::TicketSystem::system || '') eq 'RT_Internal' ) {
82   # sync RT user locale on every update
83   my $locale = $access_user->option('locale');
84   FS::TicketSystem->init;
85   my $UserObj = FS::TicketSystem->session('')->{'CurrentUser'}->UserObj;
86   # Bypass RT ModifySelf ACL
87   $UserObj->CurrentUser( $RT::SystemUser );
88   if ( $UserObj->Lang ne $locale ) {
89     my ($val, $msg) = $UserObj->SetLang($locale);
90     $error = $msg if !$val;
91   }
92 }
93 </%init>