Commit efacaaf6 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 323912: When a group cannot be deleted because it is in used,…

Bug 323912: When a group cannot be deleted because it is in used, ThrowUserError() should be called - Patch by Frédéric Buclin <LpSolit@gmail.com> r=GavinS a=myk
parent 3cacaab9
...@@ -426,7 +426,11 @@ if ($action eq 'delete') { ...@@ -426,7 +426,11 @@ if ($action eq 'delete') {
$cantdelete = 1; $cantdelete = 1;
} }
if (!$cantdelete) { $vars->{'gid'} = $gid;
$vars->{'name'} = $name;
ThrowUserError('group_cannot_delete', $vars) if $cantdelete;
$dbh->do('UPDATE flagtypes SET grant_group_id = ? $dbh->do('UPDATE flagtypes SET grant_group_id = ?
WHERE grant_group_id = ?', WHERE grant_group_id = ?',
undef, (undef, $gid)); undef, (undef, $gid));
...@@ -447,11 +451,6 @@ if ($action eq 'delete') { ...@@ -447,11 +451,6 @@ if ($action eq 'delete') {
undef, (MAILTO_GROUP, $gid)); undef, (MAILTO_GROUP, $gid));
$dbh->do('DELETE FROM groups WHERE id = ?', $dbh->do('DELETE FROM groups WHERE id = ?',
undef, $gid); undef, $gid);
}
$vars->{'gid'} = $gid;
$vars->{'name'} = $name;
$vars->{'cantdelete'} = $cantdelete;
print $cgi->header(); print $cgi->header();
$template->process("admin/groups/deleted.html.tmpl", $vars) $template->process("admin/groups/deleted.html.tmpl", $vars)
......
...@@ -23,9 +23,7 @@ ...@@ -23,9 +23,7 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# gid: number. The group ID.
# name: string. The name of the group. # name: string. The name of the group.
# cantdelete: boolean int. Is 1 if the group couldn't have been deleted.
#%] #%]
...@@ -33,21 +31,7 @@ ...@@ -33,21 +31,7 @@
title = "Deleting group" title = "Deleting group"
%] %]
[% IF cantdelete %] <p>The group [% name FILTER html %] has been deleted.</p>
<p>
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.
</p>
<p>
<a href="editgroups.cgi?action=del&amp;group=[% gid FILTER url_quote %]">View</a>
the list of which records are affected.
</p>
[% ELSE %]
<p><b>The group [% name FILTER html %] has been deleted.</b></p>
[% END %]
<p>Go back to the <a href="editgroups.cgi">group list</a>. <p>Go back to the <a href="editgroups.cgi">group list</a>.
......
...@@ -508,6 +508,14 @@ ...@@ -508,6 +508,14 @@
The sort key must be an integer between 0 and 32767 inclusive. The sort key must be an integer between 0 and 32767 inclusive.
It cannot be <em>[% sortkey FILTER html %]</em>. It cannot be <em>[% sortkey FILTER html %]</em>.
[% ELSIF error == "group_cannot_delete" %]
[% title = "Cannot Delete Group" %]
The <em>[% name FILTER html %]</em> group cannot be deleted because
there are
<a href="editgroups.cgi?action=del&amp;group=[% gid FILTER url_quote %]">records</a>
in the database which refer to it. All references to this group must
be removed before you can remove it.
[% ELSIF error == "group_exists" %] [% ELSIF error == "group_exists" %]
[% title = "The group already exists" %] [% title = "The group already exists" %]
The group [% name FILTER html %] already exists. The group [% name FILTER html %] already exists.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment