From: lpsolit%gmail.com <> Date: Sat, 30 Sep 2006 03:05:27 +0000 (+0000) Subject: Bug 323912: When a group cannot be deleted because it is in used, ThrowUserError... X-Git-Tag: bugzilla-2.22.1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b99e7372013ff1e7aa75543c8249e81d12fb71a9;p=thirdparty%2Fbugzilla.git Bug 323912: When a group cannot be deleted because it is in used, ThrowUserError() should be called - Patch by Frédéric Buclin r=GavinS a=justdave --- diff --git a/editgroups.cgi b/editgroups.cgi index 33f7331312..fb0704bd9a 100755 --- a/editgroups.cgi +++ b/editgroups.cgi @@ -449,32 +449,31 @@ if ($action eq 'delete') { $cantdelete = 1; } - if (!$cantdelete) { - $dbh->do('UPDATE flagtypes SET grant_group_id = ? - WHERE grant_group_id = ?', - undef, (undef, $gid)); - $dbh->do('UPDATE flagtypes SET request_group_id = ? - WHERE request_group_id = ?', - undef, (undef, $gid)); - $dbh->do('DELETE FROM user_group_map WHERE group_id = ?', - undef, $gid); - $dbh->do('DELETE FROM group_group_map - WHERE grantor_id = ? OR member_id = ?', - undef, ($gid, $gid)); - $dbh->do('DELETE FROM bug_group_map WHERE group_id = ?', - undef, $gid); - $dbh->do('DELETE FROM group_control_map WHERE group_id = ?', - undef, $gid); - $dbh->do('DELETE FROM whine_schedules - WHERE mailto_type = ? AND mailto = ?', - undef, (MAILTO_GROUP, $gid)); - $dbh->do('DELETE FROM groups WHERE id = ?', - undef, $gid); - } - $vars->{'gid'} = $gid; $vars->{'name'} = $name; - $vars->{'cantdelete'} = $cantdelete; + + ThrowUserError('group_cannot_delete', $vars) if $cantdelete; + + $dbh->do('UPDATE flagtypes SET grant_group_id = ? + WHERE grant_group_id = ?', + undef, (undef, $gid)); + $dbh->do('UPDATE flagtypes SET request_group_id = ? + WHERE request_group_id = ?', + undef, (undef, $gid)); + $dbh->do('DELETE FROM user_group_map WHERE group_id = ?', + undef, $gid); + $dbh->do('DELETE FROM group_group_map + WHERE grantor_id = ? OR member_id = ?', + undef, ($gid, $gid)); + $dbh->do('DELETE FROM bug_group_map WHERE group_id = ?', + undef, $gid); + $dbh->do('DELETE FROM group_control_map WHERE group_id = ?', + undef, $gid); + $dbh->do('DELETE FROM whine_schedules + WHERE mailto_type = ? AND mailto = ?', + undef, (MAILTO_GROUP, $gid)); + $dbh->do('DELETE FROM groups WHERE id = ?', + undef, $gid); print $cgi->header(); $template->process("admin/groups/deleted.html.tmpl", $vars) diff --git a/template/en/default/admin/groups/deleted.html.tmpl b/template/en/default/admin/groups/deleted.html.tmpl index 2a5c2f870d..be067fa3e8 100644 --- a/template/en/default/admin/groups/deleted.html.tmpl +++ b/template/en/default/admin/groups/deleted.html.tmpl @@ -23,9 +23,7 @@ #%] [%# INTERFACE: - # gid: number. The group ID. # name: string. The name of the group. - # cantdelete: boolean int. Is 1 if the group couldn't have been deleted. #%] @@ -33,21 +31,7 @@ title = "Deleting group" %] -[% IF cantdelete %] -

- This group cannot be deleted because there are records - in the database which refer to it. All such records - must be removed or altered to remove the reference to this - group before the group can be deleted. -

- -

- View - the list of which records are affected. -

-[% ELSE %] -

The group [% name FILTER html %] has been deleted.

-[% END %] +

The group [% name FILTER html %] has been deleted.

Go back to the group list. diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 6c0bdebc1d..9f5e216172 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -483,6 +483,14 @@ The sort key must be an integer between 0 and 32767 inclusive. It cannot be [% sortkey FILTER html %]. + [% ELSIF error == "group_cannot_delete" %] + [% title = "Cannot Delete Group" %] + The [% name FILTER html %] group cannot be deleted because + there are + records + in the database which refer to it. All references to this group must + be removed before you can remove it. + [% ELSIF error == "group_exists" %] [% title = "The group already exists" %] The group [% name FILTER html %] already exists.