From 6674f61905d98aee08b95c22181aa439bfb041e5 Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" <> Date: Thu, 10 Mar 2005 23:51:40 +0000 Subject: Bug 98123 : Create a user preferences infrastructure (became 'General Settings') Patch by Shane H. W. Travis r=jouni, mkanat a=myk --- userprefs.cgi | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'userprefs.cgi') diff --git a/userprefs.cgi b/userprefs.cgi index 342df065b..3331d5b91 100755 --- a/userprefs.cgi +++ b/userprefs.cgi @@ -20,6 +20,7 @@ # Christopher Aillon # Gervase Markham # Vlad Dascalu +# Shane H. W. Travis use strict; @@ -139,6 +140,39 @@ sub SaveAccount { } +sub DoSettings { + $vars->{'settings'} = Bugzilla->user->settings; + + my @setting_list = keys %{Bugzilla->user->settings}; + $vars->{'setting_names'} = \@setting_list; +} + +sub SaveSettings { + my $cgi = Bugzilla->cgi; + + my $settings = Bugzilla->user->settings; + my @setting_list = keys %{Bugzilla->user->settings}; + + foreach my $name (@setting_list) { + next if ! ($settings->{$name}->{'is_enabled'}); + my $value = $cgi->param($name); + + # de-taint the value. + if ($value =~ /^([-\w]+)$/ ) { + $value = $1; + } + if ($value eq "${name}-isdefault" ) { + if (! $settings->{$name}->{'is_default'}) { + $settings->{$name}->reset_to_default; + } + } + else { + $settings->{$name}->set($value); + } + } + $vars->{'settings'} = Bugzilla->user->settings(1); +} + sub DoEmail { my $dbh = Bugzilla->dbh; @@ -367,6 +401,11 @@ SWITCH: for ($current_tab_name) { DoAccount(); last SWITCH; }; + /^settings$/ && do { + SaveSettings() if $cgi->param('dosave'); + DoSettings(); + last SWITCH; + }; /^email$/ && do { SaveEmail() if $cgi->param('dosave'); DoEmail(); -- cgit v1.2.3-24-g4f1b