]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 81642 : "Split bug / Clone bug": Enter new bug with prefilled fields
authortravis%sedsystems.ca <>
Tue, 1 Feb 2005 03:15:53 +0000 (03:15 +0000)
committertravis%sedsystems.ca <>
Tue, 1 Feb 2005 03:15:53 +0000 (03:15 +0000)
Patch by Shane H. W. Travis <travis@sedsystems.ca>  r=jouni  a=justdave

enter_bug.cgi
template/en/default/bug/create/create.html.tmpl
template/en/default/bug/knob.html.tmpl
template/en/default/filterexceptions.pl
template/en/default/global/choose-product.html.tmpl

index b159d10313730f8dd67280b303ae0e3ccd39b068..46cac6f882055466098c2740e1de5cddff983f4e 100755 (executable)
@@ -21,6 +21,7 @@
 #                 Dave Miller <justdave@syndicomm.com>
 #                 Joe Robins <jmrobins@tgix.com>
 #                 Gervase Markham <gerv@gerv.net>
+#                 Shane H. W. Travis <travis@sedsystems.ca>
 
 ##############################################################################
 #
@@ -38,6 +39,7 @@ use lib qw(.);
 
 use Bugzilla;
 use Bugzilla::Constants;
+use Bugzilla::Bug;
 require "CGI.pl";
 
 use vars qw(
@@ -60,6 +62,9 @@ use vars qw(
 # user is right from the start. 
 Bugzilla->login(LOGIN_REQUIRED) if AnyEntryGroups();
 
+my $cloned_bug;
+my $cloned_bug_id;
+
 my $cgi = Bugzilla->cgi;
 
 my $product = $cgi->param('product');
@@ -133,6 +138,8 @@ if (!defined $product) {
 
         $vars->{'target'} = "enter_bug.cgi";
         $vars->{'format'} = $cgi->param('format');
+
+        $vars->{'cloned_bug_id'} = $cgi->param('cloned_bug_id');
         
         print $cgi->header();
         $template->process("global/choose-product.html.tmpl", $vars)
@@ -271,6 +278,16 @@ sub pickos {
 
 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
 # that the user has permission to enter a bug against this product.
 if(!CanEnterProduct($product))
@@ -313,46 +330,106 @@ while (MoreSQLData()) {
 
 my %default;
 
-$vars->{'component_'} = \@components;
-$default{'component_'} = formvalue('component');
+$vars->{'product'}               = $product;
+$vars->{'component_'}            = \@components;
+
+$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_disabled'} = !UserInGroup('editbugs');
+$vars->{'assigned_to'}           = formvalue('assigned_to');
+$vars->{'assigned_to_disabled'}  = !UserInGroup('editbugs');
+$vars->{'cc_disabled'}           = 0;
 
-$vars->{'cc'} = formvalue('cc');
-$vars->{'cc_disabled'} = 0;
+$vars->{'cloned_bug_id'}         = $cloned_bug_id;
 
-$vars->{'product'} = $product;
-$vars->{'bug_file_loc'} = formvalue('bug_file_loc', "http://");
-$vars->{'short_desc'} = formvalue('short_desc');
-$vars->{'comment'} = formvalue('comment');
+if ($cloned_bug_id) {
 
-$vars->{'priority'} = \@legal_priority;
-$default{'priority'} = formvalue('priority', Param('defaultpriority'));
+    $default{'component_'}    = $cloned_bug->{'component'};
+    $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->{'bug_severity'} = \@legal_severity;
-$default{'bug_severity'} = formvalue('bug_severity', Param('defaultseverity'));
+    $vars->{'short_desc'}     = $cloned_bug->{'short_desc'};
+    $vars->{'bug_file_loc'}   = $cloned_bug->{'bug_file_loc'};
+    $vars->{'keywords'}       = $cloned_bug->{'keywords'};
+    $vars->{'dependson'}      = $cloned_bug_id;
+    $vars->{'blocked'}        = "";
 
-$vars->{'rep_platform'} = \@legal_platform;
-$default{'rep_platform'} = pickplatform();
+    if (exists $cloned_bug->{'cc'}) {
+        $vars->{'cc'}         = join (" ", @{$cloned_bug->{'cc'}});
+    } else {
+        $vars->{'cc'}         = formvalue('cc');
+    }
+
+# We need to ensure that we respect the 'insider' status of
+# the first comment, if it has one. Either way, make a note
+# that this bug was cloned from another bug.
+
+    $cloned_bug->longdescs();
+    my $isprivate             = $cloned_bug->{'longdescs'}->[0]->{'isprivate'};
+
+    $vars->{'comment'}        = "";
+    $vars->{'commentprivacy'} = 0;
+
+    if ( !($isprivate) ||
+         ( ( Param("insidergroup") ) && 
+           ( UserInGroup(Param("insidergroup")) ) ) 
+       ) {
+        $vars->{'comment'}        = $cloned_bug->{'longdescs'}->[0]->{'body'};
+        $vars->{'commentprivacy'} = $isprivate;
+    }
 
-$vars->{'op_sys'} = \@legal_opsys; 
-$default{'op_sys'} = pickos();
+# Ensure that the groupset information is set up for later use.
+    $cloned_bug->groups();
 
-$vars->{'keywords'} = formvalue('keywords');
-$vars->{'dependson'} = formvalue('dependson');
-$vars->{'blocked'} = formvalue('blocked');
+} # end of cloned bug entry form
 
-$vars->{'commentprivacy'} = formvalue('commentprivacy');
+else {
 
-# Use the version specified in the URL, if one is supplied. If not,
-# then use the cookie-specified value. (Posting a bug sets a cookie
-# for the current version.) If no URL or cookie version, the default
-# version is the last one in the list (hopefully the latest one).
+    $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"
 # parameter.
 $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');
 } elsif (defined $cgi->cookie("VERSION-$product") &&
     lsearch($vars->{'version'}, $cgi->cookie("VERSION-$product")) != -1) {
@@ -414,11 +491,23 @@ while (MoreSQLData()) {
              );
     my $check;
 
-    # If this is the group for this product, make it checked.
-    if(formvalue("maketemplate") ne "") 
-    {
-        # If this is a bookmarked template, then we only want to set the
-        # bit for those bits set in the template.        
+    # If this is a cloned bug, 
+    # 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
+    # ELSE IF this is a bookmarked 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);
     }
     else {
@@ -442,8 +531,6 @@ $vars->{'group'} = \@groups;
 
 $vars->{'default'} = \%default;
 
-$vars->{'use_keywords'} = 1 if (@::legal_keywords);
-
 my $format = 
   GetFormat("bug/create/create", scalar $cgi->param('format'), 
             scalar $cgi->param('ctype'));
index 1d2287526bc902aac362b530f2eefd7089084c4a..a5d5e213ca696bafb093d3e6eccd2057ec540a03 100644 (file)
@@ -252,7 +252,13 @@ function set_assign_to() {
   <tr><td align="right" valign="top"><strong>Description:</strong></td>
     <td colspan="3">
       <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>
     </td>
   </tr>
index 463132f9f06774c6b5a1164c4b1939f520563ad0..6318fd8183c4a1cdbf11ea8676732fc9cd269eed 100644 (file)
         <a href="show_activity.cgi?id=[% bug.bug_id %]">View [% terms.Bug %] Activity</a>
         &nbsp; | &nbsp;
         <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>
     </font>
 
index 0b6bb90deb3ad8fd99658a80000514595419ecf0..6f57dc8634ecdc7fd4c1b3093b900696ab16aacf 100644 (file)
   'g.description',
   'sel.name',
   'sel.description',
+  'cloned_bug_id'
 ],
 
 'bug/create/create-guided.html.tmpl' => [
index ead2adc08d6b5dd457ab2cdaab5fee7075c0f1eb..da13ee84ff09dc74abce0566f31fa1dab35e9feb 100644 (file)
@@ -43,6 +43,7 @@
   <tr>
     <th align="right" valign="top">
       <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 %]">
       [% p FILTER html %]</a>:
     </th>