Bug 98123 : Create a user preferences infrastructure (became 'General Settings')

Patch by Shane H. W. Travis <travis@sedsystems.ca>   r=jouni, mkanat  a=myk


git-svn-id: svn://10.0.0.236/trunk@170515 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
travis%sedsystems.ca
2005-03-10 15:51:43 +00:00
parent af2addc516
commit 5b98831b40
15 changed files with 827 additions and 1 deletions

View File

@@ -20,6 +20,7 @@
# Christopher Aillon <christopher@aillon.com>
# Gervase Markham <gerv@gerv.net>
# Vlad Dascalu <jocuri@softhome.net>
# Shane H. W. Travis <travis@sedsystems.ca>
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();