From ab5067bb0995cce2afe51803b5f005cc9f994416 Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" <> Date: Fri, 11 Mar 2005 00:21:33 +0000 Subject: Bug 41972 : Per-user pref to turn quips off Patch by Shane H. W. Travis r=mkanat a=justdave --- Bugzilla/Config.pm | 13 +++++++++++++ checksetup.pl | 3 +++ defparams.pl | 18 +++++++++--------- quips.cgi | 14 +++++--------- template/en/default/global/setting-descs.none.tmpl | 1 + template/en/default/global/user-error.html.tmpl | 4 ---- template/en/default/list/list.html.tmpl | 2 +- template/en/default/list/quips.html.tmpl | 8 ++++---- 8 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm index 097c7b6c4..d91755891 100644 --- a/Bugzilla/Config.pm +++ b/Bugzilla/Config.pm @@ -237,6 +237,19 @@ sub UpdateParams { delete $param{'loginmethod'}; } + # Remove quip-display control from parameters + # and give it to users via User Settings (Bug 41972) + if ( exists $param{'enablequips'} + && !exists $param{'quip_list_entry_control'}) + { + my $new_value; + ($param{'enablequips'} eq 'on') && do {$new_value = 'open';}; + ($param{'enablequips'} eq 'approved') && do {$new_value = 'moderated';}; + ($param{'enablequips'} eq 'frozen') && do {$new_value = 'closed';}; + $param{'quip_list_entry_control'} = $new_value; + delete $param{'enablequips'}; + } + # --- DEFAULTS FOR NEW PARAMS --- foreach my $item (@param_list) { diff --git a/checksetup.pl b/checksetup.pl index 529b025b5..42ee7e295 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -4136,6 +4136,9 @@ if (!defined $dbh->bz_get_index_def('bugs_activity','who')) { $dbh->do('ALTER TABLE bugs_activity ADD INDEX (who)'); } +# 2005-03-03 travis@sedsystems.ca -- Bug 41972 +add_setting ("display_quips", {"on" => 1, "off" => 2 }, "on" ); + # # Final checks... diff --git a/defparams.pl b/defparams.pl index af5715235..5e2110d61 100644 --- a/defparams.pl +++ b/defparams.pl @@ -390,16 +390,16 @@ sub find_languages { }, { - name => 'enablequips', - desc => 'Controls the appearance of quips at the top of buglists.', + name => 'quip_list_entry_control', + desc => 'Controls how easily users can add entries to the quip list.' . + '', type => 's', - choices => ['on', 'approved', 'frozen', 'off'], - default => 'on', + choices => ['open', 'moderated', 'closed'], + default => 'open', checker => \&check_multi }, diff --git a/quips.cgi b/quips.cgi index dc0106450..766d1a792 100755 --- a/quips.cgi +++ b/quips.cgi @@ -41,10 +41,6 @@ Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; -if (Param('enablequips') eq "off") { - ThrowUserError("quips_disabled"); -} - my $action = $cgi->param('action') || ""; if ($action eq "show") { @@ -75,12 +71,12 @@ if ($action eq "show") { } if ($action eq "add") { - (Param('enablequips') eq "on" or Param('enablequips') eq "approved") - || ThrowUserError("no_new_quips"); - + (Param('quip_list_entry_control') eq "closed") && + ThrowUserError("no_new_quips"); + # Add the quip - my $approved = (Param('enablequips') eq "on") ? '1' : '0'; - $approved = 1 if(UserInGroup('admin')); + my $approved = + (Param('quip_list_entry_control') eq "open") || (UserInGroup('admin')) || 0; my $comment = $cgi->param("quip"); $comment || ThrowUserError("need_quip"); $comment !~ m/ "Show a quip at the top of each bug list", "off" => "Off", "on" => "On" } diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 2d992dfce..0821fbcd3 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -917,10 +917,6 @@ [% title = "Query Name Too Long" %] The name of the query must be less than 64 characters long. - [% ELSIF error == "quips_disabled" %] - [% title = "Quips Disabled" %] - Quips are disabled. - [% ELSIF error == "reassign_to_empty" %] [% title = "Illegal Reassignment" %] To reassign [% terms.abug %], you must provide an address for diff --git a/template/en/default/list/list.html.tmpl b/template/en/default/list/list.html.tmpl index 919c9b21c..e0a5a2b93 100644 --- a/template/en/default/list/list.html.tmpl +++ b/template/en/default/list/list.html.tmpl @@ -57,7 +57,7 @@

[% query FILTER html %]

[% END %] - [% IF Param('enablequips') != 'off' %] + [% IF user.settings.display_quips.value == 'on' %] [% DEFAULT quip = "$terms.Bugzilla would like to put a random quip here, but no one has entered any." %] [% quip FILTER html %] [% END %] diff --git a/template/en/default/list/quips.html.tmpl b/template/en/default/list/quips.html.tmpl index f5f22edd1..c43822aa1 100644 --- a/template/en/default/list/quips.html.tmpl +++ b/template/en/default/list/quips.html.tmpl @@ -37,7 +37,7 @@

Your quip '[% added_quip FILTER html %]' has been added. - [% IF Param("enablequips") == "approved" AND !user.groups.admin %] + [% IF Param("quip_list_entry_control") == "moderated" AND !user.groups.admin %] It will be used as soon as it gets approved. [% END %] @@ -60,7 +60,7 @@ [% terms.Bugzilla %] will pick a random quip for the headline on each [% terms.bug %] list, and you can extend the quip list. Type in something clever or funny or boring (but not obscene or offensive, please) and bonk on the button. - [% IF Param("enablequips") == "approved" AND !user.groups.admin %] + [% IF Param("quip_list_entry_control") == "moderated" AND !user.groups.admin %] Note that your quip has to be approved before it is used. [% END %]

@@ -88,8 +88,8 @@

Edit existing quips:

Note: Only approved quips will be shown. - If enablequips is set to on, entered quips are automatically - approved. + If the parameter 'quip_list_entry_control' is set to open, + entered quips are automatically approved.

-- cgit v1.2.3-24-g4f1b