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

@@ -22,6 +22,7 @@
# Bradley Baetz <bbaetz@acm.org>
# Joel Peshkin <bugreport@peshkin.net>
# Byron Jones <bugzilla@glob.com.au>
# Shane H. W. Travis <travis@sedsystems.ca>
# Max Kanat-Alexander <mkanat@kerio.com>
################################################################################
@@ -38,6 +39,7 @@ use Bugzilla::Config;
use Bugzilla::Error;
use Bugzilla::Util;
use Bugzilla::Constants;
use Bugzilla::User::Setting;
use Bugzilla::Auth;
use base qw(Exporter);
@@ -224,6 +226,23 @@ sub queries {
return $self->{queries};
}
sub settings {
my ($self) = @_;
return $self->{'settings'} if (defined $self->{'settings'});
# IF the user is logged in
# THEN get the user's settings
# ELSE get default settings
if ($self->id) {
$self->{'settings'} = get_all_settings($self->id);
} else {
$self->{'settings'} = get_defaults();
}
return $self->{'settings'};
}
sub flush_queries_cache {
my $self = shift;
@@ -1148,6 +1167,20 @@ linkinfooter - Whether or not the query should be displayed in the footer.
Returns the disable text of the user, if any.
=item C<settings>
Returns a hash of hashes which holds the user's settings. The first key is
the name of the setting, as found in setting.name. The second key is one of:
is_enabled - true if the user is allowed to set the preference themselves;
false to force the site defaults
for themselves or must accept the global site default value
default_value - the global site default for this setting
value - the value of this setting for this user. Will be the same
as the default_value if the user is not logged in, or if
is_default is true.
is_default - a boolean to indicate whether the user has chosen to make
a preference for themself or use the site default.
=item C<flush_queries_cache>
Some code modifies the set of stored queries. Because C<Bugzilla::User> does