Bug 171493 - make show_bug use Bug.pm and remove bug_form.pl

r=justdave, joel a=justdave
parent 0fcc2076
......@@ -59,7 +59,7 @@ sub new {
}
$self->{'name'} = $name;
$self->{'email'} = $email;
$self->{'email'} = $email || "__UNKNOWN__";
$self->{'exists'} = $exists;
# Generate a string to identify the user by name + email if the user
......
......@@ -921,14 +921,6 @@ END
}
{
eval("use Date::Parse");
# Templates will be recompiled if the source changes, but not if the
# settings in globals.pl change, so we need to be able to force a rebuild
# if that happens
# The last time the global template params were changed. Keep in UTC,
# YYYY-MM-DD
my $lastTemplateParamChange = str2time("2002-04-27", "UTC");
if (-e 'data/template') {
print "Removing existing compiled templates ...\n" unless $silent;
......@@ -967,6 +959,8 @@ END
js => sub { return $_; },
html_linebreak => sub { return $_; },
url_quote => sub { return $_; },
quoteUrls => sub { return $_; },
bug_link => [ sub { return sub { return $_; } }, 1],
csv => sub { return $_; },
time => sub { return $_; },
},
......
......@@ -1781,8 +1781,20 @@ $::template ||= Template->new(
# characters NOT in the regex set: [a-zA-Z0-9_\-.]. The 'uri'
# filter should be used for a full URL that may have
# characters that need encoding.
url_quote => \&Bugzilla::Util::url_quote,
url_quote => \&Bugzilla::Util::url_quote ,
quoteUrls => \&quoteUrls ,
bug_link => [ sub {
my ($context, $bug) = @_;
return sub {
my $text = shift;
return GetBugLink($text, $bug);
};
},
1
],
# In CSV, quotes are doubled, and we enclose the whole value in quotes
csv => sub
{
......@@ -1892,9 +1904,6 @@ $::vars =
# Generic linear search function
'lsearch' => \&Bugzilla::Util::lsearch ,
# quoteUrls - autolinkifies text
'quoteUrls' => \&quoteUrls ,
# UserInGroup - you probably want to cache this
'UserInGroup' => \&UserInGroup ,
......
......@@ -28,7 +28,8 @@ use lib qw(.);
use Bugzilla::Constants;
require "CGI.pl";
require "bug_form.pl";
use Bug;
use Bugzilla::User;
......@@ -491,28 +492,38 @@ close(PMAIL);
# Tell the user all about it
$vars->{'id'} = $id;
$vars->{'mail'} = $mailresults;
$vars->{'type'} = "created";
my $bug = new Bug($id, $::userid);
$vars->{'bug'} = $bug;
print "Content-type: text/html\n\n";
$template->process("bug/create/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
ThrowCodeError("bug_error") if $bug->error;
$vars->{'sentmail'} = [];
push (@{$vars->{'sentmail'}}, { type => 'created',
id => $id,
mail => $mailresults
});
foreach my $i (@all_deps) {
$vars->{'mail'} = "";
open(PMAIL, "-|") or exec('./processmail', $i, $::COOKIE{'Bugzilla_login'}); $vars->{'mail'} .= $_ while <PMAIL>;
my $mail = "";
open(PMAIL, "-|") or exec('./processmail', $i, $::COOKIE{'Bugzilla_login'});
$mail .= $_ while <PMAIL>;
close(PMAIL);
$vars->{'id'} = $i;
$vars->{'type'} = "dep";
push (@{$vars->{'sentmail'}}, { type => 'dep',
id => $i,
mail => $mail
});
}
# Let the user know we checked to see if we should email notice
# of this new bug to users with a relationship to the depenedant
# bug and who did and didn't receive email about it
$template->process("bug/process/results.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
my @bug_list;
if ($::COOKIE{"BUGLIST"}) {
@bug_list = split(/:/, $::COOKIE{"BUGLIST"});
}
$vars->{'bug_list'} = \@bug_list;
print "Content-type: text/html\n\n";
$template->process("bug/create/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
$::FORM{'id'} = $id;
show_bug("header is already done");
......@@ -33,8 +33,8 @@ use lib qw(.);
use Bugzilla::Constants;
require "CGI.pl";
require "bug_form.pl";
use Bug;
use Bugzilla::User;
use RelationSet;
......@@ -53,7 +53,7 @@ use vars qw(%versions
%settable_resolution
%target_milestone
%legal_severity
$next_bug);
);
ConnectToDatabase();
my $whoid = confirm_login();
......@@ -151,6 +151,23 @@ if (defined($::FORM{'id'})) {
}
}
# Set up the vars for nagiavtional <link> elements
my $next_bug;
if ($::COOKIE{"BUGLIST"} && $::FORM{'id'}) {
my @bug_list = split(/:/, $::COOKIE{"BUGLIST"});
$vars->{'bug_list'} = \@bug_list;
my $cur = lsearch(\@bug_list, $::FORM{"id"});
if ($cur >= 0 && $cur < $#bug_list) {
$next_bug = $bug_list[$cur + 1];
# Note that we only bother with the bug_id here, and get
# the full bug object at the end, before showing the edit
# page. If you change this, remember that we have not
# done the security checks on the next bug yet
$vars->{'bug'} = { bug_id => $next_bug };
}
}
# Start displaying the response page.
$template->process("bug/process/header.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
......@@ -1725,26 +1742,17 @@ foreach my $id (@idlist) {
}
}
# Show next bug, if it exists.
if ($::COOKIE{"BUGLIST"} && $::FORM{'id'}) {
my @bugs = split(/:/, $::COOKIE{"BUGLIST"});
$vars->{'bug_list'} = \@bugs;
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, $::userid)) {
$::FORM{'id'} = $next_bug;
$vars->{'next_id'} = $next_bug;
# Let the user know we are about to display the next bug in their list.
$template->process("bug/process/next.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
# now show the next bug
if ($next_bug) {
if (detaint_natural($next_bug) && CanSeeBug($next_bug, $::userid)) {
my $bug = new Bug($next_bug, $::userid);
$vars->{'bug'} = $bug;
ThrowCodeError("bug_error") if $bug->error;
show_bug("header is already done");
$template->process("bug/process/next.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
exit;
}
}
......
......@@ -25,10 +25,13 @@ use strict;
use lib qw(.);
require "CGI.pl";
require "bug_form.pl";
ConnectToDatabase();
use vars qw($template $vars $userid);
use Bug;
if ($::FORM{'GoAheadAndLogIn'}) {
confirm_login();
} else {
......@@ -39,11 +42,20 @@ if ($::FORM{'GoAheadAndLogIn'}) {
# Begin Data/Security Validation
######################################################################
unless (defined ($::FORM{'id'})) {
my $format = GetFormat("bug/choose", $::FORM{'format'}, $::FORM{'ctype'});
print "Content-type: $format->{'contenttype'}\n\n";
$template->process("$format->{'template'}", $vars) ||
ThrowTemplateError($template->error());
exit;
}
my $format = GetFormat("bug/show", $::FORM{'format'}, $::FORM{'ctype'});
# Make sure the bug ID is a positive integer representing an existing
# bug that the user is authorized to access.
if (defined ($::FORM{'id'})) {
ValidateBugID($::FORM{'id'});
}
ValidateBugID($::FORM{'id'});
######################################################################
# End Data/Security Validation
......@@ -51,6 +63,20 @@ if (defined ($::FORM{'id'})) {
GetVersionTable();
print "Content-type: text/html\n\n";
my $bug = new Bug($::FORM{'id'}, $userid);
$vars->{'bug'} = $bug;
ThrowCodeError("bug_error") if $bug->error;
# Next bug in list (if there is one)
my @bug_list;
if ($::COOKIE{"BUGLIST"}) {
@bug_list = split(/:/, $::COOKIE{"BUGLIST"});
}
$vars->{'bug_list'} = \@bug_list;
print "Content-type: $format->{'ctype'}\n\n";
$template->process("$format->{'template'}", $vars)
|| ThrowTemplateError($template->error());
show_bug();
......@@ -81,6 +81,8 @@ my $provider = Template::Provider->new(
js => sub { return $_ } ,
strike => sub { return $_ } ,
url_quote => sub { return $_ } ,
quoteUrls => sub { return $_ } ,
bug_link => [ sub { return sub { return $_; } }, 1] ,
csv => sub { return $_ } ,
time => sub { return $_ } ,
},
......
......@@ -68,7 +68,7 @@
# generated HTML
#%]
<pre>
[%- quoteUrls(comment.body) -%]
[%- comment.body FILTER quoteUrls -%]
</pre>
</div>
[% END %]
......
......@@ -23,8 +23,24 @@
title = "Bug $id Submitted"
%]
[% PROCESS bug/process/results.html.tmpl %]
[% FOREACH item = sentmail %]
[% PROCESS bug/process/results.html.tmpl
type = item.type
id = item.id
mail = item.mail
%]
[% END %]
<br>
[%# post_bug.cgi will add a copy of the filed bug below here %]
<hr>
[% PROCESS bug/edit.html.tmpl %]
<hr>
[% PROCESS bug/navigate.html.tmpl %]
<br>
[% PROCESS global/footer.html.tmpl %]
......@@ -20,19 +20,6 @@
# Vaskin Kissoyan <vkissoyan@yahoo.com>
#%]
[% filtered_desc = bug.short_desc FILTER html %]
[% filtered_timestamp = bug.delta_ts FILTER time %]
[% UNLESS header_done %]
[% PROCESS global/header.html.tmpl
title = "Bug $bug.bug_id - $bug.short_desc"
h1 = "Bugzilla Bug $bug.bug_id"
h2 = filtered_desc
h3 = "Last modified: $filtered_timestamp"
style_urls = [ "css/edit_bug.css" ]
%]
[% END %]
[% PROCESS bug/navigate.html.tmpl %]
[% PROCESS bug/time.html.tmpl %]
[% IF UserInGroup(Param('timetrackinggroup')) %]
......@@ -59,12 +46,10 @@
</script>
[% END %]
<hr>
<form name="changeform" method="post" action="process_bug.cgi">
<input type="hidden" name="delta_ts" value="[% bug.delta_ts %]">
<input type="hidden" name="longdesclength" value="[% bug.longdesclength %]">
<input type="hidden" name="longdesclength" value="[% bug.longdescs.size %]">
<input type="hidden" name="id" value="[% bug.bug_id %]">
[%# *** Hardware Reporter Product OS AddCC *** %]
......@@ -96,7 +81,7 @@
<b>Reporter:</b>
</td>
<td>
[% bug.reporter FILTER html %]
[% bug.reporter.identity FILTER html %]
</td>
</tr>
......@@ -128,19 +113,7 @@
Co<u>m</u>ponent</a>:
</b>
</td>
<td>
<label for="component" accesskey="m">
<select name="component" id="component">
[% FOREACH x = component_ %]
<option value="[% x FILTER html %]"
[% " selected" IF x == bug.component %]>[% x FILTER html %]
</option>
[% END %]
</select>
</label>
</td>
<td>&nbsp;</td>
[% PROCESS select selname => "component" accesskey => "m" %]
<td align="right">
<b><u>V</u>ersion:</b>
......@@ -203,14 +176,17 @@
<a href="bug_status.html#assigned_to">Assigned&nbsp;To</a>:
</b>
</td>
<td>[% bug.assigned_to FILTER html %]</td>
<td>[% bug.assigned_to.identity FILTER html %]</td>
<td>&nbsp;</td>
[% IF Param("usetargetmilestone") && bug.target_milestone %]
<td align="right">
<b>
<a href="[% bug.milestoneurl FILTER html %]"><u>T</u>arget
Milestone</a>:
[% IF bug.milestoneurl %]
<a href="[% bug.milestoneurl FILTER html %]">
[% END %]
<u>T</u>arget Milestone</a>:
[% "</a>" IF bug.milestoneurl %]
</b>
</td>
[% PROCESS select selname = "target_milestone" accesskey => "t" %]
......@@ -228,7 +204,7 @@
</td>
<td colspan="7">
<input name="qa_contact" accesskey="q"
value="[% bug.qa_contact FILTER html %]" size="60">
value="[% bug.qa_contact.email FILTER html %]" size="60">
</td>
</tr>
[% END %]
......@@ -248,8 +224,10 @@
value="[% bug.bug_file_loc FILTER html %]" size="60">
</td>
<td rowspan="4" colspan="2" valign="top">
[% IF flag_types.size > 0 %]
[% PROCESS "flag/list.html.tmpl" %]
[% IF bug.flag_types.size > 0 %]
[% PROCESS "flag/list.html.tmpl"
flag_types = bug.flag_types
any_flags_requesteeble = bug.any_flags_requesteeble %]
[% END %]
</td>
</tr>
......@@ -276,7 +254,7 @@
</tr>
[% END %]
[% IF use_keywords %]
[% IF bug.use_keywords %]
<tr>
<td align="right">
<b>
......@@ -350,7 +328,10 @@
[% PROCESS attachment/list.html.tmpl
attachments = bug.attachments
bugid = bug.bug_id %]
bugid = bug.bug_id
num_attachment_flag_types = bug.num_attachment_flag_types
show_attachment_flags = bug.show_attachment_flags
%]
[%# *** Dependencies Votes *** %]
......@@ -405,9 +386,13 @@
accesskey="c"></textarea>
<br>
[% IF groups.size > 0 %]
[% IF bug.groups.size > 0 %]
[% inallgroups = 1 %]
[% inagroup = 0 %]
[% FOREACH group = bug.groups %]
[% SET inallgroups = 0 IF NOT group.ingroup %]
[% SET inagroup = 1 IF group.ison %]
[% FOREACH group = groups %]
[% IF NOT group.mandatory %]
[% IF NOT emitted_description %]
[% emitted_description = 1 %]
......@@ -430,7 +415,7 @@
[% END %]
[% END %]
[% IF NOT user.inallgroups %]
[% IF NOT inallgroups %]
<b>
Only members of a group can change the visibility of a bug for
that group
......@@ -438,7 +423,7 @@
<br>
[% END %]
[% IF bug.inagroup %]
[% IF inagroup %]
<p>
<b>Users in the roles selected below can always view this bug:</b>
<br>
......@@ -472,16 +457,16 @@
[% knum = 1 %]
[% IF bug.bug_status == "UNCONFIRMED" &&
user.canconfirm %]
bug.user.canconfirm %]
<input type="radio" name="knob" value="confirm">
Confirm bug (change status to <b>NEW</b>)
<br>
[% knum = knum + 1 %]
[% END %]
[% IF user.canedit %]
[% IF bug.user.canedit %]
[% IF bug.isopened %]
[% IF bug.bug_status != "ASSIGNED" && user.canconfirm %]
[% IF bug.bug_status != "ASSIGNED" && bug.user.canconfirm %]
<input type="radio" name="knob" value="accept">
Accept bug (
[% "confirm bug, " IF bug.isunconfirmed %]change
......@@ -501,7 +486,7 @@
Resolve bug, changing <a href="bug_status.html">resolution</a> to
<select name="resolution"
onchange="document.changeform.knob[[% knum %]].checked=true">
[% FOREACH r = resolution %]
[% FOREACH r = bug.choices.resolution %]
<option value="[% r FILTER html %]">[% r FILTER html %]</option>
[% END %]
</select>
......@@ -523,9 +508,9 @@
(this.value != '')) {
document.changeform.knob[[% knum %]].checked=true;
}"
value="[% bug.assigned_to_email FILTER html %]">
value="[% bug.assigned_to.email FILTER html %]">
<br>
[% IF bug.isunconfirmed && user.canconfirm %]
[% IF bug.isunconfirmed && bug.user.canconfirm %]
&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="andconfirm">
and confirm bug (change status to <b>NEW</b>)
<br>
......@@ -537,7 +522,7 @@
[% " and QA contact" IF Param('useqacontact') %]
of selected component
<br>
[% IF bug.isunconfirmed && user.canconfirm %]
[% IF bug.isunconfirmed && bug.user.canconfirm %]
&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="compconfirm">
and confirm bug (change status to <b>NEW</b>)
<br>
......@@ -545,7 +530,7 @@
[% knum = knum + 1 %]
[% ELSE %]
[% IF bug.resolution != "MOVED" ||
(bug.resolution == "MOVED" && user.canmove) %]
(bug.resolution == "MOVED" && bug.user.canmove) %]
<input type="radio" name="knob" value="reopen"> Reopen bug
<br>
[% knum = knum + 1 %]
......@@ -574,7 +559,7 @@
</b>
</font>
[% IF user.canmove %]
[% IF bug.user.canmove %]
&nbsp; <font size="+1"><b> | </b></font> &nbsp;
<input type="submit" name="action"
value="[% Param("move-button-text") %]">
......@@ -598,19 +583,11 @@
<hr>
[% PROCESS bug/comments.html.tmpl
comments = bug.comments
comments = bug.longdescs
mode = "edit"
%]
</form>
<hr>
[% PROCESS bug/navigate.html.tmpl %]
<br>
[% PROCESS global/footer.html.tmpl %]
[%############################################################################%]
[%# Block for dependencies #%]
......@@ -620,7 +597,7 @@
<th align="right">Bug [% bug.bug_id %] [%+ dep.title %]:</th>
<td>
[% FOREACH depbug = bug.${dep.fieldname} %]
[% GetBugLink(depbug, depbug) %][% " " %]
[% depbug FILTER bug_link(depbug) %][% " " %]
[% END %]
</td>
<td>
......@@ -638,7 +615,7 @@
<td>
<label for="[% selname %]" accesskey="[% accesskey %]">
<select name="[% selname %]" id="[% selname %]">
[% FOREACH x = ${selname} %]
[% FOREACH x = bug.choices.${selname} %]
<option value="[% x FILTER html %]"
[% " selected" IF x == bug.${selname} %]>[% x FILTER html %]
</option>
......
......@@ -20,13 +20,22 @@
#%]
[%# INTERFACE:
# next_id : number; the ID of the next bug in the user's bug list.
# bug : Bug object; the next bug to show
#%]
<hr>
<p>
The next bug in your list is bug
<a href="show_bug.cgi?id=[% next_id %]">[% next_id %]</a>:
<a href="show_bug.cgi?id=[% bug.bug_id %]">[% bug.bug_id %]</a>:
</p>
[% PROCESS "bug/edit.html.tmpl" %]
<hr>
[% PROCESS bug/navigate.html.tmpl %]
<br>
[% PROCESS global/footer.html.tmpl %]
<!-- 1.0@bugzilla.org -->
[%# 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>
# Vaskin Kissoyan <vkissoyan@yahoo.com>
# Bradley Baetz <bbaetz@student.usyd.edu.au>
#%]
[% filtered_desc = bug.short_desc FILTER html %]
[% filtered_timestamp = bug.delta_ts FILTER time %]
[% PROCESS global/header.html.tmpl
title = "Bug $bug.bug_id - $bug.short_desc"
h1 = "Bugzilla Bug $bug.bug_id"
h2 = filtered_desc
h3 = "Last modified: $filtered_timestamp"
style_urls = [ "css/edit_bug.css" ]
%]
[% PROCESS bug/navigate.html.tmpl %]
<hr>
[% PROCESS bug/edit.html.tmpl %]
<hr>
[% PROCESS bug/navigate.html.tmpl %]
<br>
[% PROCESS global/footer.html.tmpl %]
......@@ -48,6 +48,10 @@
Attachment #[% attachid FILTER html %] ([% description FILTER html %])
is already obsolete.
[% ELSIF error == "bug_error" %]
Trying to retrieve bug [% bug.bug_id %] returned the error
[% bug.error FILTER html %]
[% ELSIF error == "cgi_error" %]
[% title = "CGI Error" %]
Bugzilla has had trouble interpreting your CGI request;
......
......@@ -21,8 +21,8 @@
#%]
[%# INTERFACE:
# bug_list: list of integers. List of bugs numbers of current query (if any).
# bug: integer. Number of current bug.
# bug_list: list of integers. List of bug numbers of current query (if any).
# bug.bug_id: integer. Number of current bug (for navigation purposes)
#%]
[% IF NOT (user_agent.match("MSIE [1-6]") OR user_agent.match("Mozilla/4")) %]
......
......@@ -30,7 +30,7 @@
<p>
<pre>
[%- quoteUrls(form.text) FILTER html -%]
[%- form.text FILTER quoteUrls FILTER html -%]
</pre>
</p>
......@@ -45,7 +45,7 @@
<p>
<pre>
[%- quoteUrls(form.text) -%]
[%- form.text FILTER quoteUrls -%]
</pre>
</p>
......
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