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

Bug 67950 - Move the quip list into the database. Patch by davef@tetsubo.com; r=gerv, preed.

parent 8685e9a2
...@@ -270,18 +270,14 @@ sub LookupNamedQuery { ...@@ -270,18 +270,14 @@ sub LookupNamedQuery {
} }
sub GetQuip { sub GetQuip {
return if !Param('usequip');
my $quip; my $quip;
# This is stupid. We really really need to move the quip list into the DB! SendSQL("SELECT quip FROM quips ORDER BY RAND() LIMIT 1");
if (open(COMMENTS, "<data/comments")) {
my @cdata; if (MoreSQLData()) {
push(@cdata, $_) while <COMMENTS>; ($quip) = FetchSQLData();
close COMMENTS;
$quip = $cdata[int(rand($#cdata + 1))];
} }
$quip ||= "Bugzilla would like to put a random quip here, but nobody has entered any.";
return $quip; return $quip;
} }
...@@ -1542,7 +1538,7 @@ if ($::FORM{'debug'}) { ...@@ -1542,7 +1538,7 @@ if ($::FORM{'debug'}) {
# the list more compact. # the list more compact.
$vars->{'splitheader'} = $::COOKIE{'SPLITHEADER'} ? 1 : 0; $vars->{'splitheader'} = $::COOKIE{'SPLITHEADER'} ? 1 : 0;
$vars->{'quip'} = GetQuip() if Param('usequip'); $vars->{'quip'} = GetQuip();
$vars->{'currenttime'} = time2str("%a %b %e %T %Z %Y", time()); $vars->{'currenttime'} = time2str("%a %b %e %T %Z %Y", time());
# The following variables are used when the user is making changes to multiple bugs. # The following variables are used when the user is making changes to multiple bugs.
......
...@@ -1589,6 +1589,12 @@ $table{tokens} = ...@@ -1589,6 +1589,12 @@ $table{tokens} =
index(userid)'; index(userid)';
# 2002-07-19, davef@tetsubo.com, bug 67950:
# Store quips in the db.
$table{quips} =
'quipid mediumint not null auto_increment primary key,
userid mediumint not null default 0,
quip text not null';
########################################################################### ###########################################################################
...@@ -3015,6 +3021,34 @@ if (!GetFieldDef("bugs", "alias")) { ...@@ -3015,6 +3021,34 @@ if (!GetFieldDef("bugs", "alias")) {
$dbh->do("ALTER TABLE bugs ADD UNIQUE (alias)"); $dbh->do("ALTER TABLE bugs ADD UNIQUE (alias)");
} }
# 2002-07-15 davef@tetsubo.com - bug 67950
# Move quips to the db.
my $renamed_comments_file = 0;
if (GetFieldDef("quips", "quipid")) {
if (-s 'data/comments' && open (COMMENTS, "<data/comments")) {
print "Populating quips table from data/comments...\n";
while (<COMMENTS>) {
chomp;
$dbh->do("INSERT INTO quips (quip) VALUES ("
. $dbh->quote($_) . ")");
}
print "The data/comments file (used to store quips) has been
copied into the database, and the data/comments file
moved to data/comments.bak - you can delete this file
once you're satisfied the migration worked correctly.\n";
close COMMENTS;
rename("data/comments", "data/comments.bak") or next;
$renamed_comments_file = 1;
}
}
# Warn if data/comments.bak exists, as it should be deleted.
if (-s 'data/comments.bak' && !$renamed_comments_file) {
print "Please note the data/comments.bak file can be removed as it's
no longer used.\n";
}
# If you had to change the --TABLE-- definition in any way, then add your # If you had to change the --TABLE-- definition in any way, then add your
# differential change code *** A B O V E *** this comment. # differential change code *** A B O V E *** this comment.
# #
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
# #
# Contributor(s): Owen Taylor <otaylor@redhat.com> # Contributor(s): Owen Taylor <otaylor@redhat.com>
# Gervase Markham <gerv@gerv.net> # Gervase Markham <gerv@gerv.net>
# David Fallon <davef@tetsubo.com>
use diagnostics; use diagnostics;
use strict; use strict;
...@@ -34,8 +35,6 @@ use lib qw(.); ...@@ -34,8 +35,6 @@ use lib qw(.);
require "CGI.pl"; require "CGI.pl";
# Even though quips aren't (yet) in the database, we need to check
# logins for the footer
ConnectToDatabase(); ConnectToDatabase();
quietly_check_login(); quietly_check_login();
...@@ -43,14 +42,16 @@ my $action = $::FORM{'action'} || ""; ...@@ -43,14 +42,16 @@ my $action = $::FORM{'action'} || "";
if ($action eq "show") { if ($action eq "show") {
# Read in the entire quip list # Read in the entire quip list
if (open (COMMENTS, "<data/comments")) { SendSQL("SELECT quip FROM quips");
my @quips;
push (@quips, $_) while (<COMMENTS>); my @quips;
close COMMENTS; while (MoreSQLData()) {
my ($quip) = FetchSQLData();
$vars->{'quips'} = \@quips; push(@quips, $quip);
$vars->{'show_quips'} = 1;
} }
$vars->{'quips'} = \@quips;
$vars->{'show_quips'} = 1;
} }
if ($action eq "add") { if ($action eq "add") {
...@@ -67,9 +68,7 @@ if ($action eq "add") { ...@@ -67,9 +68,7 @@ if ($action eq "add") {
exit(); exit();
} }
open(COMMENTS, ">>data/comments"); SendSQL("INSERT INTO quips (userid, quip) VALUES (". $::userid . ", " . SqlQuote($comment) . ")");
print COMMENTS $comment . "\n";
close(COMMENTS);
$vars->{'added_quip'} = $comment; $vars->{'added_quip'} = $comment;
} }
......
...@@ -152,7 +152,6 @@ if (! defined $FORM{'product'}) { ...@@ -152,7 +152,6 @@ if (! defined $FORM{'product'}) {
} }
################################## ##################################
# user came in with no form data # # user came in with no form data #
################################## ##################################
...@@ -236,14 +235,6 @@ print <<FIN; ...@@ -236,14 +235,6 @@ print <<FIN;
<td align=left> <td align=left>
<input type=checkbox name=links checked value=1>&nbsp;Links to Bugs<br> <input type=checkbox name=links checked value=1>&nbsp;Links to Bugs<br>
<input type=checkbox name=banner checked value=1>&nbsp;Banner<br> <input type=checkbox name=banner checked value=1>&nbsp;Banner<br>
FIN
if (Param('usequip')) {
print "<input type=checkbox name=quip value=1>&nbsp;Quip<br>";
} else {
print "<input type=hidden name=quip value=0>";
}
print <<FIN;
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -299,7 +290,6 @@ FIN ...@@ -299,7 +290,6 @@ FIN
my $c = 0; my $c = 0;
my $quip = "Summary";
my $bugs_count = 0; my $bugs_count = 0;
my $bugs_new_this_week = 0; my $bugs_new_this_week = 0;
my $bugs_reopened = 0; my $bugs_reopened = 0;
...@@ -328,19 +318,6 @@ FIN ...@@ -328,19 +318,6 @@ FIN
$bugs_totals{$who}{$st} ++; $bugs_totals{$who}{$st} ++;
} }
if ($FORM{'quip'}) {
if (open (COMMENTS, "<data/comments")) {
my @cdata;
while (<COMMENTS>) {
push @cdata, $_;
}
close COMMENTS;
if(@cdata) {
$quip = "<i>" . $cdata[int(rand(scalar(@cdata)))] . "</i>";
}
}
}
######################### #########################
# start painting report # # start painting report #
######################### #########################
...@@ -349,7 +326,7 @@ FIN ...@@ -349,7 +326,7 @@ FIN
$bugs_status{'ASSIGNED'} ||= '0'; $bugs_status{'ASSIGNED'} ||= '0';
$bugs_status{'REOPENED'} ||= '0'; $bugs_status{'REOPENED'} ||= '0';
print <<FIN; print <<FIN;
<h1>$quip</h1> <h1>Summary</h1>
<table border=1 cellpadding=5> <table border=1 cellpadding=5>
<tr> <tr>
<td align=right><b>New Bugs This Week</b></td> <td align=right><b>New Bugs This Week</b></td>
...@@ -664,7 +641,6 @@ sub bybugs { ...@@ -664,7 +641,6 @@ sub bybugs {
sub most_doomed_for_milestone { sub most_doomed_for_milestone {
my $when = localtime (time); my $when = localtime (time);
my $ms = "M" . Param("curmilestone"); my $ms = "M" . Param("curmilestone");
my $quip = "Summary";
print "<center>\n<h1>"; print "<center>\n<h1>";
if( $FORM{'product'} ne "-All-" ) { if( $FORM{'product'} ne "-All-" ) {
...@@ -681,17 +657,6 @@ sub most_doomed_for_milestone { ...@@ -681,17 +657,6 @@ sub most_doomed_for_milestone {
# start painting report # # start painting report #
######################### #########################
if ($FORM{'quip'}) {
if (open (COMMENTS, "<data/comments")) {
my @cdata;
while (<COMMENTS>) {
push @cdata, $_;
}
close COMMENTS;
$quip = "<i>" . $cdata[int(rand($#cdata + 1))] . "</i>";
}
}
# Build up $query string # Build up $query string
my $query; my $query;
$query = "select distinct assigned_to from bugs where target_milestone=\"$ms\""; $query = "select distinct assigned_to from bugs where target_milestone=\"$ms\"";
...@@ -786,8 +751,7 @@ FIN ...@@ -786,8 +751,7 @@ FIN
sub most_recently_doomed { sub most_recently_doomed {
my $when = localtime (time); my $when = localtime (time);
my $ms = "M" . Param("curmilestone"); my $ms = "M" . Param("curmilestone");
my $quip = "Summary";
print "<center>\n<h1>"; print "<center>\n<h1>";
if( $FORM{'product'} ne "-All-" ) { if( $FORM{'product'} ne "-All-" ) {
SendSQL("SELECT defaultmilestone FROM products WHERE product = " . SendSQL("SELECT defaultmilestone FROM products WHERE product = " .
...@@ -803,18 +767,6 @@ sub most_recently_doomed { ...@@ -803,18 +767,6 @@ sub most_recently_doomed {
# start painting report # # start painting report #
######################### #########################
if ($FORM{'quip'}) {
if (open (COMMENTS, "<data/comments")) {
my @cdata;
while (<COMMENTS>) {
push @cdata, $_;
}
close COMMENTS;
$quip = "<i>" . $cdata[int(rand($#cdata + 1))] . "</i>";
}
}
# Build up $query string # Build up $query string
my $query = "select distinct assigned_to from bugs where bugs.bug_status='NEW' and target_milestone='' and bug_severity!='enhancement' and status_whiteboard='' and (product='Browser' or product='MailNews')"; my $query = "select distinct assigned_to from bugs where bugs.bug_status='NEW' and target_milestone='' and bug_severity!='enhancement' and status_whiteboard='' and (product='Browser' or product='MailNews')";
if ($FORM{'product'} ne "-All-" ) { if ($FORM{'product'} ne "-All-" ) {
......
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
<p>[% query FILTER html %]</p> <p>[% query FILTER html %]</p>
[% END %] [% END %]
[% IF quip %] [% IF Param('usequip') %]
[% DEFAULT quip = "Bugzilla would like to put a random quip here, but no one has entered any." %]
<a href="quips.cgi"><i>[% quip FILTER html %]</i></a> <a href="quips.cgi"><i>[% quip FILTER html %]</i></a>
[% END %] [% END %]
......
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