diff options
author | bugreport%peshkin.net <> | 2002-12-09 08:57:17 +0100 |
---|---|---|
committer | bugreport%peshkin.net <> | 2002-12-09 08:57:17 +0100 |
commit | 2e6c635d3fb541baa8ed376c2c09a99bc6844dcb (patch) | |
tree | c4e9108e81157f9a95395c745521d662a49a60bc /quips.cgi | |
parent | e008fbf65bc6c7fd9df37710d08167c2677a9aa1 (diff) | |
download | bugzilla-2e6c635d3fb541baa8ed376c2c09a99bc6844dcb.tar.gz bugzilla-2e6c635d3fb541baa8ed376c2c09a99bc6844dcb.tar.xz |
Bug 159627 quips should be editable and deleteable using the web interface
patch by burnus
r=timeless,a=justdave
Diffstat (limited to 'quips.cgi')
-rwxr-xr-x | quips.cgi | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -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()); |