From 2e6c635d3fb541baa8ed376c2c09a99bc6844dcb Mon Sep 17 00:00:00 2001 From: "bugreport%peshkin.net" <> Date: Mon, 9 Dec 2002 07:57:17 +0000 Subject: Bug 159627 quips should be editable and deleteable using the web interface patch by burnus r=timeless,a=justdave --- quips.cgi | 41 +++++++++++++++++++++++++ template/en/default/global/code-error.html.tmpl | 3 ++ template/en/default/global/user-error.html.tmpl | 6 +++- template/en/default/list/quips.html.tmpl | 35 +++++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/quips.cgi b/quips.cgi index be8d9f3ec..f1783cd0a 100755 --- a/quips.cgi +++ b/quips.cgi @@ -58,6 +58,34 @@ if ($action eq "show") { $vars->{'show_quips'} = 1; } +if ($action eq "edit") { + if (!UserInGroup('admin')) { + ThrowUserError("quips_edit_denied"); + } + # Read in the entire quip list + SendSQL("SELECT quipid,userid,quip FROM quips"); + + my $quips; + my @quipids; + while (MoreSQLData()) { + my ($quipid, $userid, $quip) = FetchSQLData(); + $quips->{$quipid} = {'userid' => $userid, 'quip' => $quip}; + push(@quipids, $quipid); + } + + my $users; + foreach my $quipid (@quipids) { + if (not defined $users->{$userid}) { + SendSQL("SELECT login_name FROM profiles WHERE userid = $userid"); + $users->{$userid} = FetchSQLData(); + } + } + $vars->{'quipids'} = \@quipids; + $vars->{'quips'} = $quips; + $vars->{'users'} = $users; + $vars->{'edit_quips'} = 1; +} + if ($action eq "add") { (Param('enablequips') eq "on") || ThrowUserError("no_new_quips"); @@ -71,6 +99,19 @@ if ($action eq "add") { $vars->{'added_quip'} = $comment; } +if ($action eq "delete") { + if (!UserInGroup('admin')) { + ThrowUserError("quips_edit_denied"); + } + my $quipid = $::FORM{"quipid"}; + ThrowCodeError("need_quipid") unless $quipid =~ /(\d+)/; + $quipid = $1; + + SendSQL("SELECT quip FROM quips WHERE quipid = $quipid"); + $vars->{'deleted_quip'} = FetchSQLData(); + SendSQL("DELETE FROM quips WHERE quipid = $quipid"); +} + print "Content-type: text/html\n\n"; $template->process("list/quips.html.tmpl", $vars) || ThrowTemplateError($template->error()); diff --git a/template/en/default/global/code-error.html.tmpl b/template/en/default/global/code-error.html.tmpl index 4b37ee4f1..a29cb1e1c 100644 --- a/template/en/default/global/code-error.html.tmpl +++ b/template/en/default/global/code-error.html.tmpl @@ -177,6 +177,9 @@ No Y axis was defined when creating report. The X axis is optional, but the Y axis is compulsory. + [% ELSIF error == "need_quipid" %] + A valid quipid is needed. + [% ELSIF error == "request_queue_group_invalid" %] The group field [% group FILTER html %] is invalid. diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index af72873c4..0d43b62a5 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -371,7 +371,7 @@ [% ELSIF error == "need_quip" %] [% title = "Quip Required" %] Please enter a quip in the text field. - + [% ELSIF error == "new_password_missing" %] [% title = "New Password Missing" %] You must enter a new password. @@ -480,6 +480,10 @@ [% title = "Quips Disabled" %] Quips are disabled. + [% ELSIF error == "quips_edit_denied" %] + [% title = "Permission Denied" %] + You do not have permission to edit quips. + [% ELSIF error == "reassign_to_empty" %] [% title = "Illegal Reassignment" %] You cannot reassign to a bug to nobody. Unless you diff --git a/template/en/default/list/quips.html.tmpl b/template/en/default/list/quips.html.tmpl index f83f08128..ccb5208b7 100644 --- a/template/en/default/list/quips.html.tmpl +++ b/template/en/default/list/quips.html.tmpl @@ -39,6 +39,14 @@

[% END %] +[% IF deleted_quip %] +

+ + The quip '[% deleted_quip FILTER html %]' has been deleted. + +

+[% END %] +

Bugzilla will pick a random quip for the headline on each bug list, and you can extend the quip list. Type in something clever or funny or boring @@ -62,11 +70,38 @@

  • [% quip FILTER html %]
  • [% END %] +[% ELSIF edit_quips %] +

    Edit existing quips:

    + + + + + + + [% FOREACH quipid = quipids %] + + + + + + [% END %] +
    ActionUserQuip
    + + Delete + + + [% userid = quips.$quipid.userid %] + [% users.$userid FILTER html %] + [% "Unknown" IF NOT users.$userid %] + [% quips.$quipid.quip FILTER html %]
    [% ELSE %]

    Those who like their wisdom in large doses can view the whole quip list.

    + [% IF UserInGroup('admin') %] +

    Edit the quip list.

    + [% END %] [% END %] [% PROCESS global/footer.html.tmpl %] -- cgit v1.2.3-24-g4f1b