Commit ef85a567 authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 187837 - Unify showing and editing of quips. Patch by gerv; r=timeless, a=justdave.

parent ed5513d9
...@@ -46,23 +46,6 @@ my $action = $::FORM{'action'} || ""; ...@@ -46,23 +46,6 @@ my $action = $::FORM{'action'} || "";
if ($action eq "show") { if ($action eq "show") {
# Read in the entire quip list # Read in the entire quip list
SendSQL("SELECT quip FROM quips");
my @quips;
while (MoreSQLData()) {
my ($quip) = FetchSQLData();
push(@quips, $quip);
}
$vars->{'quips'} = \@quips;
$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"); SendSQL("SELECT quipid,userid,quip FROM quips");
my $quips; my $quips;
...@@ -83,7 +66,7 @@ if ($action eq "edit") { ...@@ -83,7 +66,7 @@ if ($action eq "edit") {
$vars->{'quipids'} = \@quipids; $vars->{'quipids'} = \@quipids;
$vars->{'quips'} = $quips; $vars->{'quips'} = $quips;
$vars->{'users'} = $users; $vars->{'users'} = $users;
$vars->{'edit_quips'} = 1; $vars->{'show_quips'} = 1;
} }
if ($action eq "add") { if ($action eq "add") {
......
...@@ -62,46 +62,51 @@ ...@@ -62,46 +62,51 @@
</form> </form>
[% IF show_quips %] [% IF show_quips %]
<h2> [% IF !UserInGroup('admin') %]
Existing quips: <h2>
</h2> Existing quips:
<ul> </h2>
[% FOREACH quip = quips %] <ul>
<li>[% quip FILTER html %]</li> [% FOREACH quip = quips %]
[% END %] <li>[% quip FILTER html %]</li>
</ul> [% END %]
[% ELSIF edit_quips %] </ul>
<h2>Edit existing quips:</h2> [% ELSE %]
<table border="1"> <h2>Edit existing quips:</h2>
<thead><tr> <table border="1">
<th>Action</th> <thead><tr>
<th>User</th> <th>Quip</th>
<th>Quip</th> <th>Author</th>
</tr></thead><tbody> <th>Action</th>
[% FOREACH quipid = quipids %] </tr></thead><tbody>
<tr> [% FOREACH quipid = quipids %]
<td> <tr>
<a href="quips.cgi?action=delete&amp;quipid=[% quipid FILTER uri%]"> <td>[% quips.$quipid.quip FILTER html %]</td>
Delete <td>
</a> [% userid = quips.$quipid.userid %]
</td> [% users.$userid FILTER html %]
<td> [% "Unknown" IF NOT users.$userid %]
[% userid = quips.$quipid.userid %] </td>
[% users.$userid FILTER html %] <td>
[% "Unknown" IF NOT users.$userid %] <a href="quips.cgi?action=delete&amp;quipid=[% quipid FILTER uri%]">
</td> Delete
<td>[% quips.$quipid.quip FILTER html %]</td> </a>
</tr> </td>
[% END %] </tr>
</tbody></table> [% END %]
</tbody>
</table>
<br>
[% END %]
[% ELSE %] [% ELSE %]
<p> <p>
Those who like their wisdom in large doses can Those who like their wisdom in large doses can
<a href="quips.cgi?action=show">view the whole quip list</a>. <a href="quips.cgi?action=show">view
[% IF UserInGroup('admin') %]
and edit
[% END %]
the whole quip list</a>.
</p> </p>
[% IF UserInGroup('admin') %]
<p><a href="quips.cgi?action=edit">Edit</a> the quip list.</p>
[% END %]
[% END %] [% END %]
[% PROCESS global/footer.html.tmpl %] [% PROCESS global/footer.html.tmpl %]
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