Commit 5a69c0bc authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 308340: General Preferences tab is empty except for submit button when no…

Bug 308340: General Preferences tab is empty except for submit button when no user prefences are enabled - Patch by Frédéric Buclin <LpSolit@gmail.com> r=GavinS a=justdave
parent 05ec759c
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# Rights Reserved. # Rights Reserved.
# #
# Contributor(s): Gervase Markham <gerv@gerv.net> # Contributor(s): Gervase Markham <gerv@gerv.net>
# Frédéric Buclin <LpSolit@gmail.com>
#%] #%]
[%# INTERFACE: [%# INTERFACE:
...@@ -32,12 +33,14 @@ ...@@ -32,12 +33,14 @@
# changes_saved: boolean/string. True if the CGI processed form data before # changes_saved: boolean/string. True if the CGI processed form data before
# displaying anything, and can contain an optional custom # displaying anything, and can contain an optional custom
# message if required (which Perl still evaluates as True). # 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 %] [% filtered_login = user.login FILTER html %]
[% PROCESS global/header.html.tmpl [% PROCESS global/header.html.tmpl
title = "User Preferences" title = "User Preferences"
h2 = filtered_login h2 = filtered_login
style_urls = ['skins/standard/admin.css']
%] %]
[% tabs = [ { name => "account", label => "Account Preferences", [% tabs = [ { name => "account", label => "Account Preferences",
...@@ -77,28 +80,28 @@ ...@@ -77,28 +80,28 @@
<h3>[% current_tab.label %]</h3> <h3>[% current_tab.label %]</h3>
<form name="userprefsform" method="post" action="userprefs.cgi"> [% IF current_tab.saveable %]
<form name="userprefsform" method="post" action="userprefs.cgi">
<input type="hidden" name="tab" value="[% current_tab.name %]"> <input type="hidden" name="tab" value="[% current_tab.name %]">
[% END %]
[% PROCESS "account/prefs/${current_tab.name}.html.tmpl" [% PROCESS "account/prefs/${current_tab.name}.html.tmpl"
IF current_tab.name.defined %] IF current_tab.name.defined %]
[% IF current_tab.saveable %] [% IF current_tab.saveable %]
<input type="hidden" name="dosave" value="1"> <input type="hidden" name="dosave" value="1">
[% UNLESS dont_show_button %]
<table> <table>
<tr> <tr>
<td width="150"></td> <td width="150">&nbsp;</td>
<td> <td>
<input type="submit" value="Submit Changes"> <input type="submit" value="Submit Changes">
</td> </td>
</tr> </tr>
</table> </table>
[% END %] [% END %]
</form>
</form> [% END %]
[% PROCESS global/footer.html.tmpl %] [% PROCESS global/footer.html.tmpl %]
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
# The Original Code is the Bugzilla Bug Tracking System. # The Original Code is the Bugzilla Bug Tracking System.
# #
# Contributor(s): Shane H. W. Travis <travis@sedsystems.ca> # Contributor(s): Shane H. W. Travis <travis@sedsystems.ca>
# Frédéric Buclin <LpSolit@gmail.com>
# #
#%] #%]
...@@ -23,14 +24,23 @@ ...@@ -23,14 +24,23 @@
# default_value - string (global default for this setting) # default_value - string (global default for this setting)
# value - string (user-defined preference) # value - string (user-defined preference)
# is_default - boolean (true if user has no 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" %] [% PROCESS "global/setting-descs.none.tmpl" %]
[% IF settings.size %] [% IF settings.size %]
[% UNLESS has_settings_enabled %]
<p class="criticalmessages">
All user preferences have been disabled by the
<a href="mailto:[% Param("maintainer") %]">maintainer</a>
of this installation, and so you cannot customise any.
</p>
[% END %]
<table border="0" cellpadding="8"> <table border="0" cellpadding="8">
[% FOREACH name = setting_names %] [% FOREACH name = setting_names %]
[% IF settings.${name}.is_enabled %]
[% default_name = name _ '-isdefault' %] [% default_name = name _ '-isdefault' %]
[% default_val = settings.${name}.default_value %] [% default_val = settings.${name}.default_value %]
<tr> <tr>
...@@ -38,6 +48,7 @@ ...@@ -38,6 +48,7 @@
[% setting_descs.$name OR name FILTER html %] [% setting_descs.$name OR name FILTER html %]
</td> </td>
<td> <td>
[% IF settings.${name}.is_enabled %]
<select name="[% name %]" id="[% name %]"> <select name="[% name %]" id="[% name %]">
<option value="[% default_name %]" <option value="[% default_name %]"
[% ' selected="selected"' IF settings.${name}.is_default %]> [% ' selected="selected"' IF settings.${name}.is_default %]>
...@@ -52,11 +63,16 @@ ...@@ -52,11 +63,16 @@
</option> </option>
[% END %] [% END %]
</select> </select>
[% ELSE %]
<select name="[% name %]" id="[% name %]" disabled="disabled">
<option value="[% default_name %]">
Site Default ([% setting_descs.${default_val} OR default_val FILTER html %])
</option>
</select>
[% END %]
</td> </td>
</tr> </tr>
[% END %] [% END %]
[% END %]
</table> </table>
[% END %] [% END %]
<br> <br>
...@@ -146,10 +146,21 @@ sub SaveAccount { ...@@ -146,10 +146,21 @@ sub SaveAccount {
sub DoSettings { 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->{'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 { sub SaveSettings {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment