]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Fix for bug 80289: Group restrictions are now identified with checkboxes instead...
authorjustdave%syndicomm.com <>
Wed, 27 Jun 2001 08:44:32 +0000 (08:44 +0000)
committerjustdave%syndicomm.com <>
Wed, 27 Jun 2001 08:44:32 +0000 (08:44 +0000)
Patch by Joe Robbins <jmrobins@tgix.com>
r= justdave@syndicomm.com

bug_form.pl
buglist.cgi
enter_bug.cgi
post_bug.cgi
process_bug.cgi

index 7801f27545ab87b7f5a6ed7a6fb1f753f8e73a88..8e5d251ae481956fa5557a83c649dbd18cb7a775 100644 (file)
@@ -368,23 +368,34 @@ print "
 
 
 if ($::usergroupset ne '0') {
-    SendSQL("select bit, description, (bit & $bug{'groupset'} != 0) " . 
-            "from groups where bit & $::usergroupset != 0 " . 
-            "and isbuggroup != 0 " . 
+    SendSQL("select bit, name, description, (bit & $bug{'groupset'} != 0) " .
+           "from groups where bit & $::usergroupset != 0 " .
+           "and isbuggroup != 0 " . 
             # Include active groups as well as inactive groups to which
             # the bug already belongs.  This way the bug can be removed
             # from an inactive group but can only be added to active ones.
             "and (isactive = 1 or (bit & $bug{'groupset'} != 0)) " . 
-            "order by bit");
+           "order by description");
+    # We only print out a header bit for this section if there are any
+    # results.
+    if(MoreSQLData()) {
+      print "<br><b>Only users in the selected groups can view this bug:</b><br>\n";
+    }
     while (MoreSQLData()) {
-        my ($bit, $description, $ison) = (FetchSQLData());
-        my $check0 = !$ison ? " SELECTED" : "";
-        my $check1 = $ison ? " SELECTED" : "";
-        print "<select name=bit-$bit><option value=0$check0>\n";
-        print "People not in the \"$description\" group can see this bug\n";
-        print "<option value=1$check1>\n";
-        print "Only people in the \"$description\" group can see this bug\n";
-        print "</select><br>\n";
+      my ($bit, $name, $description, $ison) = (FetchSQLData());
+      # For product groups, we only want to display the checkbox if either
+      # (1) The bit is already set, or
+      # (2) It's the group for this product.
+      # All other product groups will be skipped.  Non-product bug groups
+      # will still be displayed.
+      if($ison || ($name eq $bug{'product'}) || (!defined $::proddesc{$name})) {
+        # Modifying this to use checkboxes instead
+        my $checked = $ison ? " CHECKED" : "";
+        # indent these a bit
+        print "&nbsp;&nbsp;&nbsp;&nbsp;";
+        print "<input type=checkbox name=\"bit-$bit\" value=1$checked>\n";
+        print "$description<br>\n";
+      }
     }
 }
 
index 58279a1c70249923a064498809931d41c2851400..6c0ff1e7ffdd36082508844af4f947825b74028f 100755 (executable)
@@ -1450,17 +1450,21 @@ document.write(\" <input type=button value=\\\"Uncheck All\\\" onclick=\\\"SetCh
 <TEXTAREA WRAP=HARD NAME=comment ROWS=5 COLS=80></TEXTAREA><BR>";
 
 if ($::usergroupset ne '0' && $buggroupset =~ /^\d+$/) {
-    SendSQL("select bit, description, (bit & $buggroupset != 0) from groups where bit & $::usergroupset != 0 and isbuggroup != 0 order by bit");
+    SendSQL("select bit, description, (bit & $buggroupset != 0) from groups where bit & $::usergroupset != 0 and isbuggroup != 0 order by description");
+    # We only print out a header bit for this section if there are any
+    # results.
+    if(MoreSQLData()) {
+      print "<br><b>Only users in the selected groups can view this bug:</b><br>\n";
+    }
     while (MoreSQLData()) {
         my ($bit, $description, $ison) = (FetchSQLData());
-        my $check0 = !$ison ? " SELECTED" : "";
-        my $check1 = $ison ? " SELECTED" : "";
-        print "<select name=bit-$bit><option value=0$check0>\n";
-        print "People not in the \"$description\" group can see these bugs\n";
-        print "<option value=1$check1>\n";
-        print "Only people in the \"$description\" group can see these bugs\n";
-        print "</select><br>\n";
-    }
+        # Modifying this to use checkboxes instead
+        my $checked = $ison ? " CHECKED" : "";
+        # indent these a bit
+        print "&nbsp;&nbsp;&nbsp;&nbsp;";
+        print "<input type=checkbox name=\"bit-$bit\" value=1$checked>\n";
+        print "$description<br>\n";
+      }
 }
 
 
index 62c7fc49caeb1871df1ff2bb9b5563e661fad6c7..c78628a6c9d3174ec295c662c42f9bc05842ef89 100755 (executable)
@@ -408,11 +408,21 @@ print "
 ";
 
 if ($::usergroupset ne '0') {
-    SendSQL("SELECT bit, description FROM groups " .
+    SendSQL("SELECT bit, name, description FROM groups " .
             "WHERE bit & $::usergroupset != 0 " .
             "  AND isbuggroup != 0 AND isactive = 1 ORDER BY description");
-     while (MoreSQLData()) {
-        my ($bit, $description) = (FetchSQLData());
+    # We only print out a header bit for this section if there are any
+    # results.
+    if(MoreSQLData()) {
+      print "<br><b>Only users in the selected groups can view this bug:</b><br>\n";
+      print "<font size=\"-1\">(Leave all boxes unchecked to make this a public bug.)</font><br><br>\n";
+    }
+    while (MoreSQLData()) {
+        my ($bit, $prodname, $description) = (FetchSQLData());
+        # Don't want to include product groups other than this product.
+        unless(($prodname eq $product) || (!defined($::proddesc{$prodname}))) {
+            next;
+        }
         # Rather than waste time with another Param check and another database
         # access, $group_bit will only have a non-zero value if we're using
         # bug groups and have  one for this product, so I'll check on that
@@ -421,21 +431,20 @@ if ($::usergroupset ne '0') {
         # select-box patch.  Also, if $group_bit is 0, it won't match the
         # current group, either, so I'll compare it to the current bit
         # instead of checking for non-zero. -DDM, 3/11/00
-        my $check = 0; # default selection
-        if($group_bit == $bit) {
-            # In addition, we need to handle the possibility that we're coming
-            # from a bookmark template.  We'll simply check if we've got a
-            # parameter called bit-# passed.  If so, then we're coming from a
-            # template, and we'll use the template value.
-            $check = formvalue("bit-$bit","1");
+        # Modifying this to use checkboxes instead of a select list.
+        # -JMR, 5/11/01
+        # If this is the group for this product, make it checked.
+        my $check = ($group_bit == $bit);
+        # If this is a bookmarked template, then we only want to set the bit
+        # for those bits set in the template.
+        if(formvalue("maketemplate","") eq "Remember values as bookmarkable template") {
+          $check = formvalue("bit-$bit",0);
         }
-        print BuildPulldown("bit-$bit",
-                            [["0",
-                             "People not in the \"$description\" group can see this bug"],
-                             ["1",
-                              "Only people in the \"$description\" group can see this bug"]],
-                            $check);
-        print "<BR>\n";
+        my $checked = $check ? " CHECKED" : "";
+        # indent these a bit
+        print "&nbsp;&nbsp;&nbsp;&nbsp;";
+        print "<input type=checkbox name=\"bit-$bit\" value=1$checked>\n";
+        print "$description<br>\n";
     }
 }
 
index 68842b64627454ff3c36f119edabaf929ff3fcc0..e8369089797db8811b82801f4b5b9b03f4972a0e 100755 (executable)
@@ -202,7 +202,7 @@ $comment = trim($comment);
 # OK except for the fact that it causes e-mail to be suppressed.
 $comment = $comment ? $comment : " ";
 
-$query .= "now(), 0";
+$query .= "now(), (0";
 
 foreach my $b (grep(/^bit-\d*$/, keys %::FORM)) {
     if ($::FORM{$b}) {
@@ -226,7 +226,7 @@ foreach my $b (grep(/^bit-\d*$/, keys %::FORM)) {
 
 
 
-$query .= ")\n";
+$query .= ") & $::usergroupset)\n";
 
 
 my %ccids;
index 1b02b7b0c64040283595f85396d82d4904d38b0a..26ea412c17d9106da9213265f391784afaef0b21 100755 (executable)
@@ -382,20 +382,50 @@ sub CheckonComment( $ ) {
     return( ! $ret ); # Return val has to be inverted
 }
 
-
-my $foundbit = 0;
-foreach my $b (grep(/^bit-\d*$/, keys %::FORM)) {
-    if (!$foundbit) {
-        $foundbit = 1;
-        DoComma();
-        $::query .= "groupset = 0";
-    }
-    if ($::FORM{$b}) {
-        my $v = substr($b, 4);
-        $::query .= "+ $v";     # Carefully written so that the math is
+# Changing this so that it will process groups from checkboxes instead of
+# select lists.  This means that instead of looking for the bit-X values in
+# the form, we need to loop through all the bug groups this user has access
+# to, and for each one, see if it's selected.
+# In addition, adding a little extra work so that we don't clobber groupsets
+# for bugs where the user doesn't have access to the group, but does to the
+# bug (as with the proposed reporter access patch.)
+if($::usergroupset ne '0') {
+  # We want to start from zero and build up, since if all boxes have been
+  # unchecked, we want to revert to 0.
+  DoComma();
+  $::query .= "groupset = 0";
+  SendSQL("select bit from groups ".
+          "where bit & $::usergroupset != 0 ".
+          "and isbuggroup != 0 ".
+          "order by bit");
+  while(my $b = FetchSQLData()) {
+    if($::FORM{"bit-$b"}) {
+      $::query .= " + $b";      # Carefully written so that the math is
                                 # done by MySQL, which can handle 64-bit math,
                                 # and not by Perl, which I *think* can not.
     }
+  }
+  # If we're changing the groupset, then we want to check for any bits
+  # that may have been excluded because the user wasn't in that group, but
+  # that were set previously.
+  my $tmpbugid = 0;
+  if(defined $::FORM{'id'}) {
+    $tmpbugid = $::FORM{'id'};
+  } else {
+    $tmpbugid = (grep(/^id_/, (keys %::FORM)))[0];
+    $tmpbugid =~ s/^id_//;
+  }
+  SendSQL("select sum(bit) from groups ".
+          "LEFT JOIN bugs ON bugs.groupset & bit != 0 ".
+          "where bugs.bug_id = $tmpbugid ".
+          "and bit & $::usergroupset = 0 ".
+          "and isbuggroup != 0");
+  if(MoreSQLData()) {
+    my ($bitsum) = FetchSQLData();
+    if($bitsum =~ /^\d+$/) {
+      $::query .= " + $bitsum";
+    }
+  }
 }
 
 foreach my $field ("rep_platform", "priority", "bug_severity",