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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user