Commit c4b39497 authored by travis%sedsystems.ca's avatar travis%sedsystems.ca

Bug 81642 : "Split bug / Clone bug": Enter new bug with prefilled fields

Patch by Shane H. W. Travis <travis@sedsystems.ca> r=jouni a=justdave
parent f2152e3a
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
# Dave Miller <justdave@syndicomm.com> # Dave Miller <justdave@syndicomm.com>
# Joe Robins <jmrobins@tgix.com> # Joe Robins <jmrobins@tgix.com>
# Gervase Markham <gerv@gerv.net> # Gervase Markham <gerv@gerv.net>
# Shane H. W. Travis <travis@sedsystems.ca>
############################################################################## ##############################################################################
# #
...@@ -38,6 +39,7 @@ use lib qw(.); ...@@ -38,6 +39,7 @@ use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Bug;
require "CGI.pl"; require "CGI.pl";
use vars qw( use vars qw(
...@@ -60,6 +62,9 @@ use vars qw( ...@@ -60,6 +62,9 @@ use vars qw(
# user is right from the start. # user is right from the start.
Bugzilla->login(LOGIN_REQUIRED) if AnyEntryGroups(); Bugzilla->login(LOGIN_REQUIRED) if AnyEntryGroups();
my $cloned_bug;
my $cloned_bug_id;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $product = $cgi->param('product'); my $product = $cgi->param('product');
...@@ -134,6 +139,8 @@ if (!defined $product) { ...@@ -134,6 +139,8 @@ if (!defined $product) {
$vars->{'target'} = "enter_bug.cgi"; $vars->{'target'} = "enter_bug.cgi";
$vars->{'format'} = $cgi->param('format'); $vars->{'format'} = $cgi->param('format');
$vars->{'cloned_bug_id'} = $cgi->param('cloned_bug_id');
print $cgi->header(); print $cgi->header();
$template->process("global/choose-product.html.tmpl", $vars) $template->process("global/choose-product.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -271,6 +278,16 @@ sub pickos { ...@@ -271,6 +278,16 @@ sub pickos {
Bugzilla->login(LOGIN_REQUIRED) if (!(AnyEntryGroups())); Bugzilla->login(LOGIN_REQUIRED) if (!(AnyEntryGroups()));
# If a user is trying to clone a bug
# Check that the user has authorization to view the parent bug
# Create an instance of Bug that holds the info from the parent
$cloned_bug_id = $cgi->param('cloned_bug_id');
if ($cloned_bug_id) {
ValidateBugID($cloned_bug_id);
$cloned_bug = new Bugzilla::Bug($cloned_bug_id, $userid);
}
# We need to check and make sure # We need to check and make sure
# that the user has permission to enter a bug against this product. # that the user has permission to enter a bug against this product.
if(!CanEnterProduct($product)) if(!CanEnterProduct($product))
...@@ -313,46 +330,106 @@ while (MoreSQLData()) { ...@@ -313,46 +330,106 @@ while (MoreSQLData()) {
my %default; my %default;
$vars->{'product'} = $product;
$vars->{'component_'} = \@components; $vars->{'component_'} = \@components;
$default{'component_'} = formvalue('component');
$vars->{'priority'} = \@legal_priority;
$vars->{'bug_severity'} = \@legal_severity;
$vars->{'rep_platform'} = \@legal_platform;
$vars->{'op_sys'} = \@legal_opsys;
$vars->{'use_keywords'} = 1 if (@::legal_keywords);
$vars->{'assigned_to'} = formvalue('assigned_to'); $vars->{'assigned_to'} = formvalue('assigned_to');
$vars->{'assigned_to_disabled'} = !UserInGroup('editbugs'); $vars->{'assigned_to_disabled'} = !UserInGroup('editbugs');
$vars->{'cc'} = formvalue('cc');
$vars->{'cc_disabled'} = 0; $vars->{'cc_disabled'} = 0;
$vars->{'product'} = $product; $vars->{'cloned_bug_id'} = $cloned_bug_id;
$vars->{'bug_file_loc'} = formvalue('bug_file_loc', "http://");
$vars->{'short_desc'} = formvalue('short_desc');
$vars->{'comment'} = formvalue('comment');
$vars->{'priority'} = \@legal_priority; if ($cloned_bug_id) {
$default{'priority'} = formvalue('priority', Param('defaultpriority'));
$vars->{'bug_severity'} = \@legal_severity; $default{'component_'} = $cloned_bug->{'component'};
$default{'bug_severity'} = formvalue('bug_severity', Param('defaultseverity')); $default{'priority'} = $cloned_bug->{'priority'};
$default{'bug_severity'} = $cloned_bug->{'bug_severity'};
$default{'rep_platform'} = $cloned_bug->{'rep_platform'};
$default{'op_sys'} = $cloned_bug->{'op_sys'};
$vars->{'rep_platform'} = \@legal_platform; $vars->{'short_desc'} = $cloned_bug->{'short_desc'};
$default{'rep_platform'} = pickplatform(); $vars->{'bug_file_loc'} = $cloned_bug->{'bug_file_loc'};
$vars->{'keywords'} = $cloned_bug->{'keywords'};
$vars->{'dependson'} = $cloned_bug_id;
$vars->{'blocked'} = "";
$vars->{'op_sys'} = \@legal_opsys; if (exists $cloned_bug->{'cc'}) {
$default{'op_sys'} = pickos(); $vars->{'cc'} = join (" ", @{$cloned_bug->{'cc'}});
} else {
$vars->{'cc'} = formvalue('cc');
}
$vars->{'keywords'} = formvalue('keywords'); # We need to ensure that we respect the 'insider' status of
$vars->{'dependson'} = formvalue('dependson'); # the first comment, if it has one. Either way, make a note
$vars->{'blocked'} = formvalue('blocked'); # that this bug was cloned from another bug.
$vars->{'commentprivacy'} = formvalue('commentprivacy'); $cloned_bug->longdescs();
my $isprivate = $cloned_bug->{'longdescs'}->[0]->{'isprivate'};
# Use the version specified in the URL, if one is supplied. If not, $vars->{'comment'} = "";
# then use the cookie-specified value. (Posting a bug sets a cookie $vars->{'commentprivacy'} = 0;
# for the current version.) If no URL or cookie version, the default
# version is the last one in the list (hopefully the latest one). if ( !($isprivate) ||
( ( Param("insidergroup") ) &&
( UserInGroup(Param("insidergroup")) ) )
) {
$vars->{'comment'} = $cloned_bug->{'longdescs'}->[0]->{'body'};
$vars->{'commentprivacy'} = $isprivate;
}
# Ensure that the groupset information is set up for later use.
$cloned_bug->groups();
} # end of cloned bug entry form
else {
$default{'component_'} = formvalue('component');
$default{'priority'} = formvalue('priority', Param('defaultpriority'));
$default{'bug_severity'} = formvalue('bug_severity', Param('defaultseverity'));
$default{'rep_platform'} = pickplatform();
$default{'op_sys'} = pickos();
$vars->{'short_desc'} = formvalue('short_desc');
$vars->{'bug_file_loc'} = formvalue('bug_file_loc', "http://");
$vars->{'keywords'} = formvalue('keywords');
$vars->{'dependson'} = formvalue('dependson');
$vars->{'blocked'} = formvalue('blocked');
$vars->{'cc'} = formvalue('cc');
$vars->{'comment'} = formvalue('comment');
$vars->{'commentprivacy'} = formvalue('commentprivacy');
} # end of normal/bookmarked entry form
# IF this is a cloned bug,
# AND the clone's product is the same as the parent's
# THEN use the version from the parent bug
# ELSE IF a version is supplied in the URL
# THEN use it
# ELSE IF there is a version in the cookie
# THEN use it (Posting a bug sets a cookie for the current version.)
# ELSE
# The default version is the last one in the list (which, it is
# hoped, will be the most recent one).
#
# Eventually maybe each product should have a "current version" # Eventually maybe each product should have a "current version"
# parameter. # parameter.
$vars->{'version'} = $::versions{$product} || []; $vars->{'version'} = $::versions{$product} || [];
if (formvalue('version')) {
if ( ($cloned_bug_id) &&
("$product" eq "$cloned_bug->{'product'}" ) ) {
$default{'version'} = $cloned_bug->{'version'};
} elsif (formvalue('version')) {
$default{'version'} = formvalue('version'); $default{'version'} = formvalue('version');
} elsif (defined $cgi->cookie("VERSION-$product") && } elsif (defined $cgi->cookie("VERSION-$product") &&
lsearch($vars->{'version'}, $cgi->cookie("VERSION-$product")) != -1) { lsearch($vars->{'version'}, $cgi->cookie("VERSION-$product")) != -1) {
...@@ -414,11 +491,23 @@ while (MoreSQLData()) { ...@@ -414,11 +491,23 @@ while (MoreSQLData()) {
); );
my $check; my $check;
# If this is the group for this product, make it checked. # If this is a cloned bug,
if(formvalue("maketemplate") ne "") # AND the product for this bug is the same as for the original
{ # THEN set a group's checkbox if the original also had it on
# If this is a bookmarked template, then we only want to set the # ELSE IF this is a bookmarked template
# bit for those bits set in the template. # THEN set a group's checkbox if was set in the bookmark
# ELSE
# set a groups's checkbox based on the group control map
#
if ( ($cloned_bug_id) &&
("$product" eq "$cloned_bug->{'product'}" ) ) {
foreach my $i (0..(@{$cloned_bug->{'groups'}}-1) ) {
if ($cloned_bug->{'groups'}->[$i]->{'bit'} == $id) {
$check = $cloned_bug->{'groups'}->[$i]->{'ison'};
}
}
}
elsif(formvalue("maketemplate") ne "") {
$check = formvalue("bit-$id", 0); $check = formvalue("bit-$id", 0);
} }
else { else {
...@@ -442,8 +531,6 @@ $vars->{'group'} = \@groups; ...@@ -442,8 +531,6 @@ $vars->{'group'} = \@groups;
$vars->{'default'} = \%default; $vars->{'default'} = \%default;
$vars->{'use_keywords'} = 1 if (@::legal_keywords);
my $format = my $format =
GetFormat("bug/create/create", scalar $cgi->param('format'), GetFormat("bug/create/create", scalar $cgi->param('format'),
scalar $cgi->param('ctype')); scalar $cgi->param('ctype'));
......
...@@ -252,7 +252,13 @@ function set_assign_to() { ...@@ -252,7 +252,13 @@ function set_assign_to() {
<tr><td align="right" valign="top"><strong>Description:</strong></td> <tr><td align="right" valign="top"><strong>Description:</strong></td>
<td colspan="3"> <td colspan="3">
<textarea wrap="hard" name="comment" rows="10" cols="80"> <textarea wrap="hard" name="comment" rows="10" cols="80">
[% comment FILTER html %]</textarea> [% IF cloned_bug_id %]
+++ This [% terms.bug %] was initially created as a clone of [% terms.Bug %] #[% cloned_bug_id %] +++
[% END %]
[% comment FILTER html %]
</textarea>
<br> <br>
</td> </td>
</tr> </tr>
......
...@@ -169,6 +169,8 @@ ...@@ -169,6 +169,8 @@
<a href="show_activity.cgi?id=[% bug.bug_id %]">View [% terms.Bug %] Activity</a> <a href="show_activity.cgi?id=[% bug.bug_id %]">View [% terms.Bug %] Activity</a>
&nbsp; | &nbsp; &nbsp; | &nbsp;
<a href="show_bug.cgi?format=multiple&amp;id=[% bug.bug_id %]">Format For Printing</a> <a href="show_bug.cgi?format=multiple&amp;id=[% bug.bug_id %]">Format For Printing</a>
&nbsp; | &nbsp;
<a href="enter_bug.cgi?cloned_bug_id=[% bug.bug_id %]">Clone This [% terms.Bug %]</a>
</b> </b>
</font> </font>
......
...@@ -418,6 +418,7 @@ ...@@ -418,6 +418,7 @@
'g.description', 'g.description',
'sel.name', 'sel.name',
'sel.description', 'sel.description',
'cloned_bug_id'
], ],
'bug/create/create-guided.html.tmpl' => [ 'bug/create/create-guided.html.tmpl' => [
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<tr> <tr>
<th align="right" valign="top"> <th align="right" valign="top">
<a href="[% target %]?product=[% p FILTER url_quote %] <a href="[% target %]?product=[% p FILTER url_quote %]
[% IF cloned_bug_id %]&amp;cloned_bug_id=[% cloned_bug_id FILTER url_quote %][% END %]
[% IF format %]&amp;format=[% format FILTER url_quote %][% END %]"> [% IF format %]&amp;format=[% format FILTER url_quote %][% END %]">
[% p FILTER html %]</a>: [% p FILTER html %]</a>:
</th> </th>
......
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