diff --git a/mozilla/webtools/bugzilla/Bug.pm b/mozilla/webtools/bugzilla/Bug.pm index 7e703d14f8f..3dadd3cd5fa 100755 --- a/mozilla/webtools/bugzilla/Bug.pm +++ b/mozilla/webtools/bugzilla/Bug.pm @@ -37,8 +37,8 @@ use Bugzilla::Util; for my $key (qw (bug_id alias product version rep_platform op_sys bug_status resolution priority bug_severity component assigned_to reporter bug_file_loc short_desc target_milestone - qa_contact status_whiteboard creation_ts groupset - delta_ts votes whoid usergroupset comment query error) ){ + qa_contact status_whiteboard creation_ts + delta_ts votes whoid comment query error) ){ $ok_field{$key}++; } @@ -105,10 +105,6 @@ sub initBug { $self->{'whoid'} = $user_id; - &::SendSQL("SELECT groupset FROM profiles WHERE userid=$self->{'whoid'}"); - my $usergroupset = &::FetchOneColumn(); - if (!$usergroupset) { $usergroupset = '0' } - $self->{'usergroupset'} = $usergroupset; my $query = " select @@ -116,7 +112,7 @@ sub initBug { resolution, priority, bug_severity, components.name, assigned_to, reporter, bug_file_loc, short_desc, target_milestone, qa_contact, status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'), - groupset, delta_ts, sum(votes.count) + delta_ts, sum(votes.count) from bugs left join votes using(bug_id), products, components where bugs.bug_id = $bug_id @@ -124,10 +120,10 @@ sub initBug { AND components.id = bugs.component_id group by bugs.bug_id"; - &::SendSQL(&::SelectVisible($query, $user_id, $usergroupset)); - my @row; + &::SendSQL($query); + my @row = (); - if (@row = &::FetchSQLData()) { + if ((@row = &::FetchSQLData()) && &::CanSeeBug($bug_id, $self->{'whoid'})) { my $count = 0; my %fields; foreach my $field ("bug_id", "alias", "product", "version", "rep_platform", @@ -135,24 +131,21 @@ sub initBug { "bug_severity", "component", "assigned_to", "reporter", "bug_file_loc", "short_desc", "target_milestone", "qa_contact", "status_whiteboard", "creation_ts", - "groupset", "delta_ts", "votes") { + "delta_ts", "votes") { $fields{$field} = shift @row; if ($fields{$field}) { $self->{$field} = $fields{$field}; } $count++; } - } else { - &::SendSQL("select groupset from bugs where bug_id = $bug_id"); - if (@row = &::FetchSQLData()) { + } elsif (@row) { $self->{'bug_id'} = $bug_id; $self->{'error'} = "NotPermitted"; return $self; - } else { + } else { $self->{'bug_id'} = $bug_id; $self->{'error'} = "NotFound"; return $self; - } } $self->{'assigned_to'} = &::DBID_to_name($self->{'assigned_to'}); @@ -356,22 +349,6 @@ sub XML_Footer { return ("\n"); } -sub UserInGroup { - my $self = shift(); - my ($groupname) = (@_); - if ($self->{'usergroupset'} eq "0") { - return 0; - } - &::ConnectToDatabase(); - &::SendSQL("select (bit & $self->{'usergroupset'}) != 0 from groups where name = " - . &::SqlQuote($groupname)); - my $bit = &::FetchOneColumn(); - if ($bit) { - return 1; - } - return 0; -} - sub CanChangeField { my $self = shift(); my ($f, $oldvalue, $newvalue) = (@_); diff --git a/mozilla/webtools/bugzilla/Bugzilla/Bug.pm b/mozilla/webtools/bugzilla/Bugzilla/Bug.pm index 7e703d14f8f..3dadd3cd5fa 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Bug.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Bug.pm @@ -37,8 +37,8 @@ use Bugzilla::Util; for my $key (qw (bug_id alias product version rep_platform op_sys bug_status resolution priority bug_severity component assigned_to reporter bug_file_loc short_desc target_milestone - qa_contact status_whiteboard creation_ts groupset - delta_ts votes whoid usergroupset comment query error) ){ + qa_contact status_whiteboard creation_ts + delta_ts votes whoid comment query error) ){ $ok_field{$key}++; } @@ -105,10 +105,6 @@ sub initBug { $self->{'whoid'} = $user_id; - &::SendSQL("SELECT groupset FROM profiles WHERE userid=$self->{'whoid'}"); - my $usergroupset = &::FetchOneColumn(); - if (!$usergroupset) { $usergroupset = '0' } - $self->{'usergroupset'} = $usergroupset; my $query = " select @@ -116,7 +112,7 @@ sub initBug { resolution, priority, bug_severity, components.name, assigned_to, reporter, bug_file_loc, short_desc, target_milestone, qa_contact, status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'), - groupset, delta_ts, sum(votes.count) + delta_ts, sum(votes.count) from bugs left join votes using(bug_id), products, components where bugs.bug_id = $bug_id @@ -124,10 +120,10 @@ sub initBug { AND components.id = bugs.component_id group by bugs.bug_id"; - &::SendSQL(&::SelectVisible($query, $user_id, $usergroupset)); - my @row; + &::SendSQL($query); + my @row = (); - if (@row = &::FetchSQLData()) { + if ((@row = &::FetchSQLData()) && &::CanSeeBug($bug_id, $self->{'whoid'})) { my $count = 0; my %fields; foreach my $field ("bug_id", "alias", "product", "version", "rep_platform", @@ -135,24 +131,21 @@ sub initBug { "bug_severity", "component", "assigned_to", "reporter", "bug_file_loc", "short_desc", "target_milestone", "qa_contact", "status_whiteboard", "creation_ts", - "groupset", "delta_ts", "votes") { + "delta_ts", "votes") { $fields{$field} = shift @row; if ($fields{$field}) { $self->{$field} = $fields{$field}; } $count++; } - } else { - &::SendSQL("select groupset from bugs where bug_id = $bug_id"); - if (@row = &::FetchSQLData()) { + } elsif (@row) { $self->{'bug_id'} = $bug_id; $self->{'error'} = "NotPermitted"; return $self; - } else { + } else { $self->{'bug_id'} = $bug_id; $self->{'error'} = "NotFound"; return $self; - } } $self->{'assigned_to'} = &::DBID_to_name($self->{'assigned_to'}); @@ -356,22 +349,6 @@ sub XML_Footer { return ("\n"); } -sub UserInGroup { - my $self = shift(); - my ($groupname) = (@_); - if ($self->{'usergroupset'} eq "0") { - return 0; - } - &::ConnectToDatabase(); - &::SendSQL("select (bit & $self->{'usergroupset'}) != 0 from groups where name = " - . &::SqlQuote($groupname)); - my $bit = &::FetchOneColumn(); - if ($bit) { - return 1; - } - return 0; -} - sub CanChangeField { my $self = shift(); my ($f, $oldvalue, $newvalue) = (@_); diff --git a/mozilla/webtools/bugzilla/Bugzilla/Search.pm b/mozilla/webtools/bugzilla/Bugzilla/Search.pm index 482daca5c7d..d6e7a9b7f66 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Search.pm @@ -29,7 +29,7 @@ use strict; # The caller MUST require CGI.pl and globals.pl before using this -use vars qw($userid $usergroupset); +use vars qw($userid); package Bugzilla::Search; @@ -117,7 +117,7 @@ sub init { my @legal_fields = ("product", "version", "rep_platform", "op_sys", "bug_status", "resolution", "priority", "bug_severity", "assigned_to", "reporter", "component", - "target_milestone", "groupset"); + "target_milestone", "bug_group"); foreach my $field (keys %F) { if (lsearch(\@legal_fields, $field) != -1) { @@ -322,6 +322,12 @@ sub init { push(@wherepart, "$table.bug_id = bugs.bug_id"); $f = "$table.thetext"; }, + "^bug_group,(?!changed)" => sub { + push(@supptables, "LEFT JOIN bug_group_map bug_group_map_$chartid ON bugs.bug_id = bug_group_map_$chartid.bug_id"); + + push(@supptables, "LEFT JOIN groups groups_$chartid ON groups_$chartid.id = bug_group_map_$chartid.group_id"); + $f = "groups_$chartid.name"; + }, "^attachments\..*," => sub { my $table = "attachments_$chartid"; push(@supptables, "attachments $table"); @@ -747,7 +753,7 @@ sub init { # chart -1 is generated by other code above, not from the user- # submitted form, so we'll blindly accept any values in chart -1 if ((!$chartfields{$f}) && ($chart != -1)) { - my $errstr = "Can't use " . html_quote($f) . " as a field name. " . + my $errstr = "Can't use $f as a field name. " . "If you think you're getting this in error, please copy the " . "entire URL out of the address bar at the top of your browser " . "window and email it to <109679\@bugzilla.org>"; @@ -807,11 +813,27 @@ sub init { $suppseen{$str} = 1; } } - my $query = ("SELECT DISTINCT " . join(', ', @fields) . + my $query = ("SELECT DISTINCT " . + join(', ', @fields) . + ", COUNT(DISTINCT ugmap.group_id) AS cntuseringroups, " . + " COUNT(DISTINCT bgmap.group_id) AS cntbugingroups, " . + " ((COUNT(DISTINCT ccmap.who) AND cclist_accessible) " . + " OR ((bugs.reporter = $::userid) AND bugs.reporter_accessible) " . + " OR bugs.assigned_to = $::userid ) AS canseeanyway " . " FROM $suppstring" . - " WHERE " . join(' AND ', (@wherepart, @andlist))); - - $query = &::SelectVisible($query, $::userid, $::usergroupset); + " LEFT JOIN bug_group_map AS bgmap " . + " ON bgmap.bug_id = bugs.bug_id " . + " LEFT JOIN user_group_map AS ugmap " . + " ON bgmap.group_id = ugmap.group_id " . + " AND ugmap.user_id = $::userid " . + " AND ugmap.isbless = 0" . + " LEFT JOIN cc AS ccmap " . + " ON ccmap.who = $::userid AND ccmap.bug_id = bugs.bug_id " . + " WHERE " . join(' AND ', (@wherepart, @andlist)) . + " GROUP BY bugs.bug_id " . + " HAVING cntuseringroups = cntbugingroups" . + " OR canseeanyway" + ); if ($debug) { print "
" . value_quote($query) . "
f- - 's. A whole lot of f-ing going on if you want to create a new - administator.
f- - 's. A whole lot of f-ing going on if you want to create a new - administator.
"; + print "The Use For Bugs flag determines whether or not the group is eligible to be used for bugs. +If you remove this flag, it will no longer be possible for users to add bugs +to this group, although bugs already in the group will remain in the group. +Doing so is a much less drastic way to stop a group from growing +than deleting the group as well as a way to maintain lists of users without cluttering the lists of groups used for bug restrictions.
"; + print "The Type field identifies system groups.
";
PutFooter();
exit;
}
+#
+#
+# action='changeform' -> present form for altering an existing group
+#
+# (next action will be 'postchanges')
+#
+
+if ($action eq 'changeform') {
+ PutHeader("Change Group");
+
+ my $gid = trim($::FORM{group} || '');
+ unless ($gid) {
+ ShowError("No group specified.
" .
+ "Click the Back button and try again.");
+ PutFooter();
+ exit;
+ }
+
+ SendSQL("SELECT id, name, description, userregexp, isactive, isbuggroup
+ FROM groups WHERE id=" . SqlQuote($gid));
+ my ($group_id, $name, $description, $rexp, $isactive, $isbuggroup)
+ = FetchSQLData();
+
+ print "
"; print "Name is what is used with the UserInGroup() function in any customized cgi files you write that use a given group. It can also be used by -people submitting bugs by email to limit a bug to a certain groupset. It +people submitting bugs by email to limit a bug to a certain set of groups. It may not contain any spaces.
"; print "Description is what will be shown in the bug reports to members of the group where they can choose whether the bug will be restricted to others in the same group.
"; - print "The Active flag determines whether or not the group is active. -If you deactivate a group it will no longer be possible for users to add bugs -to that group, although bugs already in the group will remain in the group. -Deactivating a group is a much less drastic way to stop a group from growing + print "The Use For Bugs flag determines whether or not the group is eligible to be used for bugs. +If you clear this, it will no longer be possible for users to add bugs +to this group, although bugs already in the group will remain in the group. +Doing so is a much less drastic way to stop a group from growing than deleting the group would be. Note: If you are creating a group, you -probably want it to be active, in which case you should leave this checked.
"; +probably want it to be usable for bugs, in which case you should leave this checked.
"; print "User RegExp is optional, and if filled in, will automatically grant membership to this group to anyone creating a new account with an email address that matches this regular expression.
";
@@ -287,62 +361,30 @@ if ($action eq 'new') {
exit;
}
- # Major hack for bit values... perl can't handle 64-bit ints, so I can't
- # just do the math to get the next available bit number, gotta handle
- # them as strings... also, we're actually only going to allow 63 bits
- # because that's all that opblessgroupset masks for (the high bit is off
- # to avoid signing issues).
-
- my @bitvals = ('1','2','4','8','16','32','64','128','256','512','1024',
- '2048','4096','8192','16384','32768',
-
- '65536','131072','262144','524288','1048576','2097152',
- '4194304','8388608','16777216','33554432','67108864',
- '134217728','268435456','536870912','1073741824',
- '2147483648',
-
- '4294967296','8589934592','17179869184','34359738368',
- '68719476736','137438953472','274877906944',
- '549755813888','1099511627776','2199023255552',
- '4398046511104','8796093022208','17592186044416',
- '35184372088832','70368744177664','140737488355328',
-
- '281474976710656','562949953421312','1125899906842624',
- '2251799813685248','4503599627370496','9007199254740992',
- '18014398509481984','36028797018963968','72057594037927936',
- '144115188075855872','288230376151711744',
- '576460752303423488','1152921504606846976',
- '2305843009213693952','4611686018427387904');
-
- # First the next available bit
- my $bit = "";
- foreach (@bitvals) {
- if ($bit eq "") {
- SendSQL("SELECT bit FROM groups WHERE bit=" . SqlQuote($_));
- if (!FetchOneColumn()) { $bit = $_; }
- }
- }
- if ($bit eq "") {
- ShowError("Sorry, you already have the maximum number of groups " .
- "defined.
You must delete a group first before you " .
- "can add any more.");
- PutTrailer("Back to the group list");
+ if (!eval {qr/$regexp/}) {
+ ShowError("The regular expression you entered is invalid. " .
+ "Please click the Back button and try again.");
+ PutFooter();
exit;
}
# Add the new group
SendSQL("INSERT INTO groups ( " .
- "bit, name, description, isbuggroup, userregexp, isactive" .
+ "name, description, isbuggroup, userregexp, isactive, last_changed " .
" ) VALUES ( " .
- $bit . "," .
- SqlQuote($name) . "," .
- SqlQuote($desc) . "," .
+ SqlQuote($name) . ", " .
+ SqlQuote($desc) . ", " .
"1," .
- SqlQuote($regexp) . "," .
- $isactive . ")" );
-
+ SqlQuote($regexp) . ", " .
+ $isactive . ", NOW())" );
+ SendSQL("SELECT last_insert_id()");
+ my $gid = FetchOneColumn();
+ my $admin = GroupNameToId('admin');
+ SendSQL("INSERT INTO group_group_map (member_id, grantor_id, isbless)
+ VALUES ($admin, $gid, 0)");
+ SendSQL("INSERT INTO group_group_map (member_id, grantor_id, isbless)
+ VALUES ($admin, $gid, 1)");
print "OK, done.
\n"; - print "Your new group was assigned bit #$bit.
";
PutTrailer("Add another group",
"Back to the group list");
exit;
@@ -356,14 +398,14 @@ if ($action eq 'new') {
if ($action eq 'del') {
PutHeader("Delete group");
- my $bit = trim($::FORM{group} || '');
- unless ($bit) {
+ my $gid = trim($::FORM{group} || '');
+ unless ($gid) {
ShowError("No group specified.
" .
"Click the Back button and try again.");
PutFooter();
exit;
}
- SendSQL("SELECT bit FROM groups WHERE bit=" . SqlQuote($bit));
+ SendSQL("SELECT id FROM groups WHERE id=" . SqlQuote($gid));
if (!FetchOneColumn()) {
ShowError("That group doesn't exist.
" .
"Click the Back button and try again.");
@@ -372,17 +414,17 @@ if ($action eq 'del') {
}
SendSQL("SELECT name,description " .
"FROM groups " .
- "WHERE bit = " . SqlQuote($bit));
+ "WHERE id = " . SqlQuote($gid));
my ($name, $desc) = FetchSQLData();
print "
| Bit | "; + print "Id | "; print "Name | "; print "Description | "; print "
|---|---|---|---|
| $bit | \n"; + print "$gid | \n"; print "$name | \n"; print "$desc | \n"; print "
| User Regexp for Bug Group: | \n"; - print "\n"; - } print " | ||
| Closed for bug entry: | \n"; @@ -263,7 +256,7 @@ if ($action eq 'add') { print "