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 @@
use diagnostics;
use strict;
use vars qw(
$template
$vars
);
package Attachment;
my $template = $::template;
my $vars = $::vars;
# This module requires that its caller have said "require CGI.pl" to import
# relevant functions from that script and its companion globals.pl.
......@@ -44,11 +36,11 @@ my $vars = $::vars;
# Functions
############################################################################
sub list
sub query
{
# Displays a table of attachments for a given bug along with links for
# viewing, editing, or making requests for each attachment.
# Retrieves and returns an array of attachment records for a given bug.
# This data should be given to attachment/list.atml in an
# "attachments" variable.
my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs");
......@@ -98,14 +90,8 @@ sub list
$in_editbugs);
push @attachments, \%a;
}
$vars->{'bugid'} = $bugid;
$vars->{'attachments'} = \@attachments;
$template->process("attachment/list.atml", $vars)
|| &::DisplayError("Template process failed: " . $template->error())
&& exit;
return \@attachments;
}
1;
......@@ -27,16 +27,8 @@
use diagnostics;
use strict;
use vars qw(
$template
$vars
);
package Attachment;
my $template = $::template;
my $vars = $::vars;
# This module requires that its caller have said "require CGI.pl" to import
# relevant functions from that script and its companion globals.pl.
......@@ -44,11 +36,11 @@ my $vars = $::vars;
# Functions
############################################################################
sub list
sub query
{
# Displays a table of attachments for a given bug along with links for
# viewing, editing, or making requests for each attachment.
# Retrieves and returns an array of attachment records for a given bug.
# This data should be given to attachment/list.atml in an
# "attachments" variable.
my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs");
......@@ -98,14 +90,8 @@ sub list
$in_editbugs);
push @attachments, \%a;
}
$vars->{'bugid'} = $bugid;
$vars->{'attachments'} = \@attachments;
$template->process("attachment/list.atml", $vars)
|| &::DisplayError("Template process failed: " . $template->error())
&& exit;
return \@attachments;
}
1;
......@@ -32,22 +32,25 @@ my $UserInCanConfirmGroupSet = -1;
use lib qw(.);
require "CGI.pl";
require "bug_form.pl";
use RelationSet;
# Shut up misguided -w warnings about "used only once":
use vars %::versions,
%::components,
%::COOKIE,
%::MFORM,
%::legal_keywords,
%::legal_opsys,
%::legal_platform,
%::legal_priority,
%::settable_resolution,
%::target_milestone,
%::legal_severity,
%::superusergroupset;
use vars qw(%versions
%components
%COOKIE
%MFORM
%legal_keywords
%legal_opsys
%legal_platform
%legal_priority
%settable_resolution
%target_milestone
%legal_severity
%superusergroupset
$next_bug);
my $whoid = confirm_login();
......@@ -466,22 +469,8 @@ if ($action eq Param("move-button-text")) {
# the common updates to all bugs in @idlist start here
#
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";
$::query = "update bugs\nset";
$::comma = "";
umask(0);
......@@ -973,13 +962,20 @@ The changes made were:
<p>
";
DumpBugActivity($id, $::FORM{'delta_ts'});
my $longdesc = GetLongDescriptionAsHTML($id);
my $comments = GetComments($id);
my $longchanged = 0;
if (length($longdesc) > $::FORM{'longdesclength'}) {
if (scalar(@$comments) > $::FORM{'longdesclength'}) {
$longchanged = 1;
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";
}
SendSQL("unlock tables");
......@@ -1394,14 +1390,29 @@ The changes made were:
}
if (defined $::next_bug) {
print("<P>The next bug in your list is:\n");
$::FORM{'id'} = $::next_bug;
print "<HR>\n";
# Show next bug, if it exists.
if ($::COOKIE{"BUGLIST"} && $::FORM{'id'}) {
my @bugs = split(/:/, $::COOKIE{"BUGLIST"});
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();
do "bug_form.pl";
} else {
navigation_header();
PutFooter();
print "<hr>\n";
print("<p>The next bug in your list is bug ");
print("<a href='show_bug.cgi?id=$next_bug'>$next_bug</a>:</p>\n");
$::FORM{'id'} = $next_bug;
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;
use lib qw(.);
require "CGI.pl";
require "bug_form.pl";
ConnectToDatabase();
......@@ -49,32 +50,8 @@ if (defined ($::FORM{'id'})) {
# 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();
# Get the bug's summary (short description) and display it as
# 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";
print "Content-type: text/html\n\n";
$! = 0;
do "bug_form.pl" || die "Error doing bug_form.pl: $!";
show_bug();
[%# 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