From: cyeh%bluemartini.com <>
Date: Sat, 24 Jun 2000 01:03:46 +0000 (+0000)
Subject: checkin to fix Bug 25010 "Need a way to edit the list of available groups".
X-Git-Tag: bugzilla-2.12~260
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8eb2d6ffa3b01ff437f1726fb17b0a326ede653d;p=thirdparty%2Fbugzilla.git
checkin to fix Bug 25010 "Need a way to edit the list of available groups".
Patches and work contributed by dave@intrec.com (Dave Miller).
Some cleanup work needs to be done with regards to permissions and bit-twiddling
see other bugs that are dependent on 25010 for details.
---
diff --git a/editgroups.cgi b/editgroups.cgi
index 1f329d8ac8..4d1b74bd7d 100755
--- a/editgroups.cgi
+++ b/editgroups.cgi
@@ -279,12 +279,12 @@ if ($action eq 'new') {
# First the next available bit
my $bit = "";
foreach (@bitvals) {
- if ($bit == "") {
+ if ($bit eq "") {
SendSQL("SELECT bit FROM groups WHERE bit=" . SqlQuote($_));
if (!FetchOneColumn()) { $bit = $_; }
}
}
- if ($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.");
@@ -349,11 +349,57 @@ if ($action eq 'del') {
print "\n";
print "\n";
- print "
Do you really want to delete this group?
\n"; - print "
"; @@ -367,23 +413,88 @@ if ($action eq 'del') { # if ($action eq 'delete') { - PutHeader("Deleting user"); - ShowError("This function has not been implemented yet! (Sorry)-
-Deleting a group will be implemented very shortly, stay tuned! -I just figured most people would be more interested in adding and editing -groups for the time being, so I would get that done first, so I could get this out here for people to use. :)
-Watch Bug 25010 on Mozilla's bugzilla for details. -
-";
+ PutHeader("Deleting group");
+ my $bit = trim($::FORM{group} || '');
+ unless ($bit) {
+ ShowError("No group specified.
" .
+ "Click the Back button and try again.");
+ PutFooter();
+ exit;
+ }
+ SendSQL("SELECT name " .
+ "FROM groups " .
+ "WHERE bit = " . SqlQuote($bit));
+ my ($name) = FetchSQLData();
+
+ my $cantdelete = 0;
+ my $opblessgroupset = '9223372036854775807'; # This is all 64 bits.
+
+ SendSQL("SELECT userid FROM profiles " .
+ "WHERE (groupset & $opblessgroupset)=$opblessgroupset");
+ my @opusers = ();
+ while (MoreSQLData()) {
+ my ($userid) = FetchSQLData();
+ push @opusers, $userid; # cache a list of the users with admin powers
+ }
+ SendSQL("SELECT login_name FROM profiles WHERE " .
+ "(groupset & $bit)=$bit OR (blessgroupset & $bit)=$bit");
+ if (FetchOneColumn()) {
+ if (!defined $::FORM{'removeusers'}) {
+ $cantdelete = 1;
+ }
+ }
+ SendSQL("SELECT bug_id FROM bugs WHERE (groupset & $bit)=$bit");
+ if (FetchOneColumn()) {
+ if (!defined $::FORM{'removebugs'}) {
+ $cantdelete = 1;
+ }
+ }
+ SendSQL("SELECT product FROM products WHERE product=" . SqlQuote($name));
+ if (FetchOneColumn()) {
+ if (!defined $::FORM{'unbind'}) {
+ $cantdelete = 1;
+ }
+ }
+
+ if ($cantdelete == 1) {
+ ShowError("This group cannot be deleted because there are child " .
+ "records in the database which refer to it. All child records " .
+ "must be removed or altered to remove the reference to this " .
+ "group before the group can be deleted.");
+ print "" .
+ "View the list of which records are affected
";
+ PutTrailer("Back to group list");
+ exit;
+ }
+
+ SendSQL("SELECT login_name,groupset,blessgroupset FROM profiles WHERE " .
+ "(groupset & $bit) OR (blessgroupset & $bit)");
+ if (FetchOneColumn()) {
+ SendSQL("UPDATE profiles SET groupset=(groupset-$bit) " .
+ "WHERE (groupset & $bit)");
+ print "All users have been removed from group $bit.
";
+ SendSQL("UPDATE profiles SET blessgroupset=(blessgroupset-$bit) " .
+ "WHERE (blessgroupset & $bit)");
+ print "All users with authority to add users to group $bit have " .
+ "had that authority removed.
";
+ }
+ SendSQL("SELECT bug_id FROM bugs WHERE (groupset & $bit)");
+ if (FetchOneColumn()) {
+ SendSQL("UPDATE bugs SET groupset=(groupset-$bit) " .
+ "WHERE (groupset & $bit)");
+ print "All bugs have had group bit $bit cleared. Any of these " .
+ "bugs that were not also in another group are now " .
+ "publicly visible.
";
+ }
+ SendSQL("DELETE FROM groups WHERE bit=$bit");
+ print "Group $bit has been deleted.
";
+
+ foreach my $userid (@opusers) {
+ SendSQL("UPDATE profiles SET groupset=$opblessgroupset " .
+ "WHERE userid=$userid");
+ print "Group bits restored for " . DBID_to_name($userid) .
+ " (maintainer)
\n";
+ }
PutTrailer("Back to group list");
exit;
diff --git a/editusers.cgi b/editusers.cgi
index 1b5d396a71..92ba42fa6b 100755
--- a/editusers.cgi
+++ b/editusers.cgi
@@ -253,19 +253,27 @@ List users with login name matching:
if ($action eq 'list') {
PutHeader("Select user");
- my $query = "SELECT login_name,realname,disabledtext " .
- "FROM profiles WHERE login_name ";
- if ($::FORM{'matchtype'} eq 'substr') {
- $query .= "like";
- $::FORM{'matchstr'} = '%' . $::FORM{'matchstr'} . '%';
- } elsif ($::FORM{'matchtype'} eq 'regexp') {
- $query .= "regexp";
- } elsif ($::FORM{'matchtype'} eq 'notregexp') {
- $query .= "not regexp";
+ my $query = "";
+ if (exists $::FORM{'matchtype'}) {
+ $query = "SELECT login_name,realname,disabledtext " .
+ "FROM profiles WHERE login_name ";
+ if ($::FORM{'matchtype'} eq 'substr') {
+ $query .= "like";
+ $::FORM{'matchstr'} = '%' . $::FORM{'matchstr'} . '%';
+ } elsif ($::FORM{'matchtype'} eq 'regexp') {
+ $query .= "regexp";
+ } elsif ($::FORM{'matchtype'} eq 'notregexp') {
+ $query .= "not regexp";
+ } else {
+ die "Unknown match type";
+ }
+ $query .= SqlQuote($::FORM{'matchstr'}) . " ORDER BY login_name";
+ } elsif (exists $::FORM{'query'}) {
+ $query = "SELECT login_name,realname,disabledtext " .
+ "FROM profiles WHERE " . $::FORM{'query'} . " ORDER BY login_name";
} else {
- die "Unknown match type";
+ die "Missing parameters";
}
- $query .= SqlQuote($::FORM{'matchstr'}) . " ORDER BY login_name";
SendSQL($query);
my $count = 0;
@@ -446,7 +454,7 @@ if ($action eq 'del') {
CheckUser($user);
# display some data about the user
- SendSQL("SELECT realname, groupset, emailnotification, login_name
+ SendSQL("SELECT realname, groupset, emailnotification
FROM profiles
WHERE login_name=" . SqlQuote($user));
my ($realname, $groupset, $emailnotification) = FetchSQLData();
@@ -478,7 +486,8 @@ if ($action eq 'del') {
my $found = 0;
while ( MoreSQLData() ) {
my ($bit,$name) = FetchSQLData();
- if ($bit & $groupset) {
+ my $cmpr = $bit & $groupset;
+ if ($cmpr) {
print "
\n" if $found;
print ucfirst $name;
$found = 1;