From 5a69c0bcd929b79ba6cc675058b50fc0d162141e Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Fri, 28 Oct 2005 16:56:53 +0000 Subject: Bug 308340: General Preferences tab is empty except for submit button when no user prefences are enabled - Patch by Frédéric Buclin r=GavinS a=justdave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/en/default/account/prefs/prefs.html.tmpl | 41 +++++++------ .../en/default/account/prefs/settings.html.tmpl | 68 +++++++++++++--------- userprefs.cgi | 15 ++++- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/template/en/default/account/prefs/prefs.html.tmpl b/template/en/default/account/prefs/prefs.html.tmpl index e849a4e99..352e303d6 100644 --- a/template/en/default/account/prefs/prefs.html.tmpl +++ b/template/en/default/account/prefs/prefs.html.tmpl @@ -17,6 +17,7 @@ # Rights Reserved. # # Contributor(s): Gervase Markham + # Frédéric Buclin #%] [%# INTERFACE: @@ -32,12 +33,14 @@ # changes_saved: boolean/string. True if the CGI processed form data before # displaying anything, and can contain an optional custom # message if required (which Perl still evaluates as True). + # dont_show_button: boolean. Prevent the display of the "Submit Changes" button. #%] [% filtered_login = user.login FILTER html %] [% PROCESS global/header.html.tmpl title = "User Preferences" h2 = filtered_login + style_urls = ['skins/standard/admin.css'] %] [% tabs = [ { name => "account", label => "Account Preferences", @@ -77,28 +80,28 @@

[% current_tab.label %]

-
- +[% IF current_tab.saveable %] + + +[% END %] - [% PROCESS "account/prefs/${current_tab.name}.html.tmpl" - IF current_tab.name.defined %] +[% PROCESS "account/prefs/${current_tab.name}.html.tmpl" + IF current_tab.name.defined %] - [% IF current_tab.saveable %] +[% IF current_tab.saveable %] - - - - - -
- -
- [% END %] - -
+ [% UNLESS dont_show_button %] + + + + + +
  + +
+ [% END %] + +[% END %] [% PROCESS global/footer.html.tmpl %] - - - diff --git a/template/en/default/account/prefs/settings.html.tmpl b/template/en/default/account/prefs/settings.html.tmpl index a425dcac1..3ef9a5852 100644 --- a/template/en/default/account/prefs/settings.html.tmpl +++ b/template/en/default/account/prefs/settings.html.tmpl @@ -12,6 +12,7 @@ # The Original Code is the Bugzilla Bug Tracking System. # # Contributor(s): Shane H. W. Travis + # Frédéric Buclin # #%] @@ -23,40 +24,55 @@ # default_value - string (global default for this setting) # value - string (user-defined preference) # is_default - boolean (true if user has no preference) + # has_settings_enabled : boolean; is true if there is at least one user pref + # enabled by the maintainer. #%] [% PROCESS "global/setting-descs.none.tmpl" %] [% IF settings.size %] + [% UNLESS has_settings_enabled %] +

+ All user preferences have been disabled by the + maintainer + of this installation, and so you cannot customise any. +

+ [% END %] + [% FOREACH name = setting_names %] - [% IF settings.${name}.is_enabled %] - [% default_name = name _ '-isdefault' %] - [% default_val = settings.${name}.default_value %] - - - - - [% END %] + [% default_name = name _ '-isdefault' %] + [% default_val = settings.${name}.default_value %] + + + + [% END %] -
- [% setting_descs.$name OR name FILTER html %] - - -
+ [% setting_descs.$name OR name FILTER html %] + + [% IF settings.${name}.is_enabled %] + + [% ELSE %] + + [% END %] +
[% END %]
diff --git a/userprefs.cgi b/userprefs.cgi index 796f2e0f9..ebbcefbab 100755 --- a/userprefs.cgi +++ b/userprefs.cgi @@ -146,10 +146,21 @@ sub SaveAccount { sub DoSettings { - $vars->{'settings'} = Bugzilla->user->settings; + my $settings = Bugzilla->user->settings; + $vars->{'settings'} = $settings; - my @setting_list = keys %{Bugzilla->user->settings}; + my @setting_list = keys %$settings; $vars->{'setting_names'} = \@setting_list; + + $vars->{'has_settings_enabled'} = 0; + # Is there at least one user setting enabled? + foreach my $setting_name (@setting_list) { + if ($settings->{"$setting_name"}->{'is_enabled'}) { + $vars->{'has_settings_enabled'} = 1; + last; + } + } + $vars->{'dont_show_button'} = !$vars->{'has_settings_enabled'}; } sub SaveSettings { -- cgit v1.2.3-24-g4f1b