From 45b240a6124c67436cea18f90e4a3330ba819441 Mon Sep 17 00:00:00 2001 From: "justdave%syndicomm.com" <> Date: Wed, 6 Jun 2001 10:16:47 +0000 Subject: Fix for bug 75482: adding the capability to deactivate a group without deleting it (prevent new bugs from being placed into that group, but don't remove the group restriction from bugs already in it). Patch by Myk Melez r= justdave@syndicomm.com --- editgroups.cgi | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'editgroups.cgi') diff --git a/editgroups.cgi b/editgroups.cgi index 202cd56b9..1626fc3a4 100755 --- a/editgroups.cgi +++ b/editgroups.cgi @@ -105,16 +105,17 @@ unless ($action) { print "Name"; print "Description"; print "User RegExp"; + print "Active"; print "Action"; print "\n"; - SendSQL("SELECT bit,name,description,userregexp " . + SendSQL("SELECT bit,name,description,userregexp,isactive " . "FROM groups " . "WHERE isbuggroup != 0 " . "ORDER BY bit"); while (MoreSQLData()) { - my ($bit, $name, $desc, $regexp) = FetchSQLData(); + my ($bit, $name, $desc, $regexp, $isactive) = FetchSQLData(); print "\n"; print "$bit\n"; print "\n"; @@ -123,12 +124,14 @@ unless ($action) { print "\n"; print "\n"; print "\n"; + print "\n"; + print "\n"; print "Delete\n"; print "\n"; } print "\n"; - print "\n"; + print "\n"; print "Add Group\n"; print "\n"; print "\n"; @@ -146,6 +149,11 @@ to others in the same group.

"; 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.

"; + 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 +than deleting the group would be.

"; print "In addition, the following groups that determine user privileges exist. You can only edit the User rexexp on these groups. You should also take care not to duplicate the Names of any of them in your user groups.

"; @@ -201,10 +209,12 @@ if ($action eq 'add') { print "New Name"; print "New Description"; print "New User RegExp"; + print "Active"; print ""; print "\n"; print "\n"; print "\n"; + print "\n"; print "\n


\n"; print "\n"; print "\n"; @@ -218,6 +228,12 @@ 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 +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.

"; 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.

"; @@ -239,6 +255,10 @@ if ($action eq 'new') { my $name = trim($::FORM{name} || ''); my $desc = trim($::FORM{desc} || ''); my $regexp = trim($::FORM{regexp} || ''); + # convert an undefined value in the inactive field to zero + # (this occurs when the inactive checkbox is not checked + # and the browser does not send the field to the server) + my $isactive = $::FORM{isactive} || 0; unless ($name) { ShowError("You must enter a name for the new group.
" . @@ -259,6 +279,14 @@ if ($action eq 'new') { exit; } + if ($isactive != 0 && $isactive != 1) { + ShowError("The active flag was improperly set. There may be " . + "a problem with Bugzilla or a bug in your browser.
" . + "Please click the Back button and try again."); + PutFooter(); + 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 @@ -304,13 +332,14 @@ if ($action eq 'new') { # Add the new group SendSQL("INSERT INTO groups ( " . - "bit, name, description, isbuggroup, userregexp" . + "bit, name, description, isbuggroup, userregexp, isactive" . " ) VALUES ( " . $bit . "," . SqlQuote($name) . "," . SqlQuote($desc) . "," . "1," . - SqlQuote($regexp) . ")" ); + SqlQuote($regexp) . "," . + $isactive . ")" ); print "OK, done.

\n"; print "Your new group was assigned bit #$bit.

"; @@ -573,6 +602,23 @@ if ($action eq 'update') { " WHERE bit=" . SqlQuote($v)); print "Group $v user regexp updated.
\n"; } + # convert an undefined value in the inactive field to zero + # (this occurs when the inactive checkbox is not checked + # and the browser does not send the field to the server) + my $isactive = $::FORM{"isactive-$v"} || 0; + if ($::FORM{"oldisactive-$v"} != $isactive) { + $chgs = 1; + if ($isactive == 0 || $isactive == 1) { + SendSQL("UPDATE groups SET isactive=$isactive" . + " WHERE bit=" . SqlQuote($v)); + print "Group $v active flag updated.
\n"; + } else { + ShowError("The value '" . $isactive . + "' is not a valid value for the active flag.
" . + "There may be a problem with Bugzilla or a bug in your browser.
" . + "Update of active flag for group $v skipped."); + } + } } } if (!$chgs) { -- cgit v1.2.3-24-g4f1b