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

Bug 110012 - show_bug templatisation. r=bbaetz, afranke.

parent 90713bc2
...@@ -27,16 +27,8 @@ ...@@ -27,16 +27,8 @@
use diagnostics; use diagnostics;
use strict; use strict;
use vars qw(
$template
$vars
);
package Attachment; package Attachment;
my $template = $::template;
my $vars = $::vars;
# This module requires that its caller have said "require CGI.pl" to import # This module requires that its caller have said "require CGI.pl" to import
# relevant functions from that script and its companion globals.pl. # relevant functions from that script and its companion globals.pl.
...@@ -44,11 +36,11 @@ my $vars = $::vars; ...@@ -44,11 +36,11 @@ my $vars = $::vars;
# Functions # Functions
############################################################################ ############################################################################
sub list sub query
{ {
# Displays a table of attachments for a given bug along with links for # Retrieves and returns an array of attachment records for a given bug.
# viewing, editing, or making requests for each attachment. # This data should be given to attachment/list.atml in an
# "attachments" variable.
my ($bugid) = @_; my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs"); my $in_editbugs = &::UserInGroup("editbugs");
...@@ -99,13 +91,7 @@ sub list ...@@ -99,13 +91,7 @@ sub list
push @attachments, \%a; push @attachments, \%a;
} }
$vars->{'bugid'} = $bugid; return \@attachments;
$vars->{'attachments'} = \@attachments;
$template->process("attachment/list.atml", $vars)
|| &::DisplayError("Template process failed: " . $template->error())
&& exit;
} }
1; 1;
...@@ -27,16 +27,8 @@ ...@@ -27,16 +27,8 @@
use diagnostics; use diagnostics;
use strict; use strict;
use vars qw(
$template
$vars
);
package Attachment; package Attachment;
my $template = $::template;
my $vars = $::vars;
# This module requires that its caller have said "require CGI.pl" to import # This module requires that its caller have said "require CGI.pl" to import
# relevant functions from that script and its companion globals.pl. # relevant functions from that script and its companion globals.pl.
...@@ -44,11 +36,11 @@ my $vars = $::vars; ...@@ -44,11 +36,11 @@ my $vars = $::vars;
# Functions # Functions
############################################################################ ############################################################################
sub list sub query
{ {
# Displays a table of attachments for a given bug along with links for # Retrieves and returns an array of attachment records for a given bug.
# viewing, editing, or making requests for each attachment. # This data should be given to attachment/list.atml in an
# "attachments" variable.
my ($bugid) = @_; my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs"); my $in_editbugs = &::UserInGroup("editbugs");
...@@ -99,13 +91,7 @@ sub list ...@@ -99,13 +91,7 @@ sub list
push @attachments, \%a; push @attachments, \%a;
} }
$vars->{'bugid'} = $bugid; return \@attachments;
$vars->{'attachments'} = \@attachments;
$template->process("attachment/list.atml", $vars)
|| &::DisplayError("Template process failed: " . $template->error())
&& exit;
} }
1; 1;
...@@ -32,22 +32,25 @@ my $UserInCanConfirmGroupSet = -1; ...@@ -32,22 +32,25 @@ my $UserInCanConfirmGroupSet = -1;
use lib qw(.); use lib qw(.);
require "CGI.pl"; require "CGI.pl";
require "bug_form.pl";
use RelationSet; use RelationSet;
# Shut up misguided -w warnings about "used only once": # Shut up misguided -w warnings about "used only once":
use vars %::versions, use vars qw(%versions
%::components, %components
%::COOKIE, %COOKIE
%::MFORM, %MFORM
%::legal_keywords, %legal_keywords
%::legal_opsys, %legal_opsys
%::legal_platform, %legal_platform
%::legal_priority, %legal_priority
%::settable_resolution, %settable_resolution
%::target_milestone, %target_milestone
%::legal_severity, %legal_severity
%::superusergroupset; %superusergroupset
$next_bug);
my $whoid = confirm_login(); my $whoid = confirm_login();
...@@ -466,22 +469,8 @@ if ($action eq Param("move-button-text")) { ...@@ -466,22 +469,8 @@ if ($action eq Param("move-button-text")) {
# the common updates to all bugs in @idlist start here # the common updates to all bugs in @idlist start here
# #
print "<TITLE>Update Bug " . join(" ", @idlist) . "</TITLE>\n"; print "<TITLE>Update Bug " . join(" ", @idlist) . "</TITLE>\n";
if (defined $::FORM{'id'}) {
navigation_header();
if (defined $::next_bug) {
# If there is another bug, then we're going to display it,
# so check that its a legal bug
# We need to check that its a number first
if (!(detaint_natural($::next_bug) && CanSeeBug($::next_bug))) {
# This isn't OK
# Rather than error out (which could validly happen if there
# was a bug in the list whose group was changed in the meantime)
# just remove references to it
undef $::next_bug;
}
}
}
print "<HR>\n"; print "<HR>\n";
$::query = "update bugs\nset"; $::query = "update bugs\nset";
$::comma = ""; $::comma = "";
umask(0); umask(0);
...@@ -973,13 +962,20 @@ The changes made were: ...@@ -973,13 +962,20 @@ The changes made were:
<p> <p>
"; ";
DumpBugActivity($id, $::FORM{'delta_ts'}); DumpBugActivity($id, $::FORM{'delta_ts'});
my $longdesc = GetLongDescriptionAsHTML($id); my $comments = GetComments($id);
my $longchanged = 0; my $longchanged = 0;
if (length($longdesc) > $::FORM{'longdesclength'}) { if (scalar(@$comments) > $::FORM{'longdesclength'}) {
$longchanged = 1; $longchanged = 1;
print "<P>Added text to the long description:<blockquote>"; print "<P>Added text to the long description:<blockquote>";
print substr($longdesc, $::FORM{'longdesclength'}); use vars qw($template $vars);
$vars->{'start_at'} = $::FORM{'longdesclength'};
$vars->{'comments'} = $comments;
$vars->{'quoteUrls'} = \&quoteUrls;
$template->process("show/comments.tmpl", $vars)
|| DisplayError("Template process failed: " . $template->error())
&& exit;
print "</blockquote>\n"; print "</blockquote>\n";
} }
SendSQL("unlock tables"); SendSQL("unlock tables");
...@@ -1394,14 +1390,29 @@ The changes made were: ...@@ -1394,14 +1390,29 @@ The changes made were:
} }
if (defined $::next_bug) { # Show next bug, if it exists.
print("<P>The next bug in your list is:\n"); if ($::COOKIE{"BUGLIST"} && $::FORM{'id'}) {
$::FORM{'id'} = $::next_bug; my @bugs = split(/:/, $::COOKIE{"BUGLIST"});
print "<HR>\n"; my $cur = lsearch(\@bugs, $::FORM{"id"});
if ($cur >= 0 && $cur < $#bugs) {
my $next_bug = $bugs[$cur + 1];
if (detaint_natural($next_bug) && CanSeeBug($next_bug)) {
navigation_header(); print "<hr>\n";
do "bug_form.pl"; print("<p>The next bug in your list is bug ");
} else { print("<a href='show_bug.cgi?id=$next_bug'>$next_bug</a>:</p>\n");
navigation_header(); $::FORM{'id'} = $next_bug;
PutFooter();
show_bug("header is already done");
exit;
}
else {
# Need this until the navigation_header() fn. goes away totally.
undef $::next_bug;
}
}
} }
navigation_header();
PutFooter();
...@@ -26,6 +26,7 @@ use strict; ...@@ -26,6 +26,7 @@ use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; require "CGI.pl";
require "bug_form.pl";
ConnectToDatabase(); ConnectToDatabase();
...@@ -49,32 +50,8 @@ if (defined ($::FORM{'id'})) { ...@@ -49,32 +50,8 @@ if (defined ($::FORM{'id'})) {
# End Data/Security Validation # End Data/Security Validation
###################################################################### ######################################################################
print "Content-type: text/html\n";
print "\n";
if (!defined $::FORM{'id'}) {
PutHeader("Search by bug number");
print "<FORM METHOD=GET ACTION=\"show_bug.cgi\">\n";
print "You may find a single bug by entering its bug id here: \n";
print "<INPUT NAME=id>\n";
print "<INPUT TYPE=\"submit\" VALUE=\"Show Me This Bug\">\n";
print "</FORM>\n";
PutFooter();
exit;
}
GetVersionTable(); GetVersionTable();
# Get the bug's summary (short description) and display it as print "Content-type: text/html\n\n";
# the page title.
SendSQL("SELECT short_desc FROM bugs WHERE bug_id = $::FORM{'id'}");
my ($summary) = FetchSQLData();
$summary = html_quote($summary);
PutHeader("Bug $::FORM{'id'} - $summary", "Bugzilla Bug $::FORM{'id'}", $summary, "", navigation_links() );
navigation_header();
print "<HR>\n";
$! = 0; show_bug();
do "bug_form.pl" || die "Error doing bug_form.pl: $!";
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
#%]
[% UNLESS header_done %]
[% INCLUDE global/header
title = "Search by bug number"
%]
[% END %]
<form method="get" action="show_bug.cgi">
<p>
You may find a single bug by entering its bug id here:
<input name="id" size="6">
<input type="submit" value="Show Me This Bug">
</p>
</form>
[% INCLUDE global/footer %]
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Gervase Markham <gerv@gerv.net>
#%]
[% IF bug_list.size > 0 %]
[% this_bug_idx = lsearch(bug_list, bug.bug_id) %]
<b>Bug List:</b>
[% IF this_bug_idx != -1 %]
([% this_bug_idx + 1 %] of [% bug_list.size %])
[% END %]
<a href="show_bug.cgi?id=[% bug_list.first %]">First</a>
<a href="show_bug.cgi?id=[% bug_list.last %]">Last</a>
[% IF this_bug_idx != -1 %]
[% IF this_bug_idx > 0 %]
[% prev_bug = this_bug_idx - 1 %]
<a href="show_bug.cgi?id=[% bug_list.$prev_bug %]">Prev</a>
[% ELSE %]
<i><font color="#777777">Prev</font></i>
[% END %]
[% IF this_bug_idx + 1 < bug_list.size %]
[% next_bug = this_bug_idx + 1 %]
<a href="show_bug.cgi?id=[% bug_list.$next_bug %]">Next</a>
[% ELSE %]
<i><font color="#777777">Next</font></i>
[% END %]
[% ELSE %]
(This bug is not in your list)
[% END %]
&nbsp;&nbsp;<a href="buglist.cgi?regetlastlist=1">Show list</a>
[% END %]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="query.cgi">Query page</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="enter_bug.cgi">Enter new bug</a>
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