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 --- Bugzilla/User.pm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index e67a78c83..8045ee228 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -22,6 +22,7 @@ # Bradley Baetz # Joel Peshkin # Byron Jones +# Shane H. W. Travis # Max Kanat-Alexander ################################################################################ @@ -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 + +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 Some code modifies the set of stored queries. Because C does -- cgit v1.2.3-24-g4f1b