]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 323912: When a group cannot be deleted because it is in used, ThrowUserError...
authorlpsolit%gmail.com <>
Sat, 30 Sep 2006 03:05:27 +0000 (03:05 +0000)
committerlpsolit%gmail.com <>
Sat, 30 Sep 2006 03:05:27 +0000 (03:05 +0000)
editgroups.cgi
template/en/default/admin/groups/deleted.html.tmpl
template/en/default/global/user-error.html.tmpl

index 33f73313122e3f5d6c4e9a674881ba92ed1b19a5..fb0704bd9adb57c9b59ba2af49f28d04d65513c6 100755 (executable)
@@ -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)
index 2a5c2f870d0688b646a158a962792d943261f599..be067fa3e83d9c37071ea5641d3c00a02fedef34 100644 (file)
@@ -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.
   #%]
 
 
   title = "Deleting group"
 %]
 
-[% IF cantdelete %]
-  <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>The group [% name FILTER html %] has been deleted.</p>
 
 <p>Go back to the <a href="editgroups.cgi">group list</a>.
 
index 6c0bdebc1d9d8278ed547adbd9b5b7943ec85674..9f5e21617285f285a73113cd32855d6deca5ff0f 100644 (file)
     The sort key must be an integer between 0 and 32767 inclusive.
     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" %]
     [% title = "The group already exists" %]
     The group [% name FILTER html %] already exists.