From 422a379558b0738d842c1e5b997ef8357ff18ac4 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Tue, 30 May 2006 01:11:03 +0000 Subject: Bug 324784: editgroups.cgi should make sure groups it edits/removes are not used by editparams.cgi (in data/params) - Patch by Frédéric Buclin r=wicked a=justdave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- editgroups.cgi | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'editgroups.cgi') diff --git a/editgroups.cgi b/editgroups.cgi index 9c1280d5c..7b86df35a 100755 --- a/editgroups.cgi +++ b/editgroups.cgi @@ -31,6 +31,7 @@ use lib "."; use Bugzilla; use Bugzilla::Constants; +use Bugzilla::Config qw(:DEFAULT :admin); use Bugzilla::Group; use Bugzilla::User; require "globals.pl"; @@ -338,6 +339,17 @@ if ($action eq 'del') { if (!$isbuggroup) { ThrowUserError("system_group_not_deletable", { name => $name }); } + # Groups having a special role cannot be deleted. + my @special_groups; + foreach my $special_group ('chartgroup', 'insidergroup', 'timetrackinggroup') { + if ($name eq Param($special_group)) { + push(@special_groups, $special_group); + } + } + if (scalar(@special_groups)) { + ThrowUserError('group_has_special_role', {'name' => $name, + 'groups' => \@special_groups}); + } # Group inheritance no longer appears in user_group_map. my $grouplist = join(',', @{Bugzilla::User->flatten_group_membership($gid)}); @@ -391,6 +403,17 @@ if ($action eq 'delete') { if (!$isbuggroup) { ThrowUserError("system_group_not_deletable", { name => $name }); } + # Groups having a special role cannot be deleted. + my @special_groups; + foreach my $special_group ('chartgroup', 'insidergroup', 'timetrackinggroup') { + if ($name eq Param($special_group)) { + push(@special_groups, $special_group); + } + } + if (scalar(@special_groups)) { + ThrowUserError('group_has_special_role', {'name' => $name, + 'groups' => \@special_groups}); + } my $cantdelete = 0; @@ -596,6 +619,16 @@ sub doGroupChanges { $chgs = 1; $dbh->do('UPDATE groups SET name = ? WHERE id = ?', undef, ($name, $gid)); + # If the group is used by some parameters, we have to update + # these parameters too. + my $update_params = 0; + foreach my $group ('chartgroup', 'insidergroup', 'timetrackinggroup') { + if ($cgi->param('oldname') eq Param($group)) { + SetParam($group, $name); + $update_params = 1; + } + } + WriteParams() if $update_params; } if ($desc ne $cgi->param('olddesc')) { $chgs = 1; -- cgit v1.2.3-24-g4f1b