From: lpsolit%gmail.com <> Date: Sat, 22 Nov 2008 03:55:57 +0000 (+0000) Subject: Bug 453681: Do not display the "Yes, delete" button if deleting a user account would... X-Git-Tag: bugzilla-3.2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a9a74f093f50ec0286beb407a7543e410e9f987;p=thirdparty%2Fbugzilla.git Bug 453681: Do not display the "Yes, delete" button if deleting a user account would cause FK constraint errors - Patch by Frédéric Buclin r=wurblzap a=LpSolit --- diff --git a/editusers.cgi b/editusers.cgi index 674b211f13..b93f1c063c 100755 --- a/editusers.cgi +++ b/editusers.cgi @@ -358,6 +358,9 @@ if ($action eq 'search') { $vars->{'otheruser'} = $otherUser; # Find other cross references. + $vars->{'attachments'} = $dbh->selectrow_array( + 'SELECT COUNT(*) FROM attachments WHERE submitter_id = ?', + undef, $otherUserID); $vars->{'assignee_or_qa'} = $dbh->selectrow_array( qq{SELECT COUNT(*) FROM bugs @@ -372,6 +375,9 @@ if ($action eq 'search') { $vars->{'bugs_activity'} = $dbh->selectrow_array( 'SELECT COUNT(*) FROM bugs_activity WHERE who = ?', undef, $otherUserID); + $vars->{'component_cc'} = $dbh->selectrow_array( + 'SELECT COUNT(*) FROM component_cc WHERE user_id = ?', + undef, $otherUserID); $vars->{'email_setting'} = $dbh->selectrow_array( 'SELECT COUNT(*) FROM email_setting WHERE user_id = ?', undef, $otherUserID); @@ -402,6 +408,9 @@ if ($action eq 'search') { $vars->{'profiles_activity'} = $dbh->selectrow_array( 'SELECT COUNT(*) FROM profiles_activity WHERE who = ? AND userid != ?', undef, ($otherUserID, $otherUserID)); + $vars->{'quips'} = $dbh->selectrow_array( + 'SELECT COUNT(*) FROM quips WHERE userid = ?', + undef, $otherUserID); $vars->{'series'} = $dbh->selectrow_array( 'SELECT COUNT(*) FROM series WHERE creator = ?', undef, $otherUserID); @@ -514,6 +523,7 @@ if ($action eq 'search') { $otherUserID); $dbh->do('DELETE FROM profiles_activity WHERE userid = ? OR who = ?', undef, ($otherUserID, $otherUserID)); + $dbh->do('UPDATE quips SET userid = NULL where userid = ?', undef, $otherUserID); $dbh->do('DELETE FROM tokens WHERE userid = ?', undef, $otherUserID); $dbh->do('DELETE FROM user_group_map WHERE user_id = ?', undef, $otherUserID); diff --git a/template/en/default/admin/users/confirm-delete.html.tmpl b/template/en/default/admin/users/confirm-delete.html.tmpl index 218775dca6..00f4d32d29 100644 --- a/template/en/default/admin/users/confirm-delete.html.tmpl +++ b/template/en/default/admin/users/confirm-delete.html.tmpl @@ -101,17 +101,34 @@ For now, you can [% END %] [% ELSE %] + [% accept_deletion = 1 %] -

Confirmation

- - [% display_warning = 0 %] - - [% IF reporter || bugs_activity || flags.setter || longdescs || profiles_activity %] + [% IF attachments || reporter || bugs_activity || flags.setter || longdescs || profiles_activity %]
-

The following deletions are highly not recommended and - will generate referential integrity inconsistencies!

+

The following deletions are unsafe and would generate referential + integrity inconsistencies!

- [% display_warning = 1 %] + [% accept_deletion = 0 %] [% END %] - [% IF assignee_or_qa || cc || email_setting || flags.requestee || - namedqueries || profile_setting || series || votes || watch.watched || + [% IF assignee_or_qa || cc || component_cc || email_setting || flags.requestee || + namedqueries || profile_setting || quips || series || votes || watch.watched || watch.watcher || whine_events || whine_schedules %]

The following deletions are safe and will not generate @@ -245,6 +262,17 @@ If you delete the user account, it will be removed from these CC lists. [% END %] + [% IF component_cc %] +

  • + [% otheruser.login FILTER html %] is on the default CC list of + [% IF component_cc == 1 %] + one component + [% ELSE %] + [%+ component_cc %] components + [% END %]. + If you delete the user account, it will be removed from these CC lists. +
  • + [% END %] [% IF email_setting %]
  • The user's e-mail settings will be deleted along with the user @@ -327,6 +355,23 @@ will be deleted along with the user account.
  • [% END %] + [% IF quips %] +
  • + [% otheruser.login FILTER html %] has sumbitted + [% IF quip == 1 %] + one quip + [% ELSE %] + [%+ quips %] quips + [% END %]. + If you delete the user account, + [% IF votes == 1 %] + this quip + [% ELSE %] + these quips + [% END %] + will have no author anymore, but will remain available. +
  • + [% END %] [% IF votes %]
  • [% otheruser.login FILTER html %] has voted on @@ -402,28 +447,28 @@ [% END %]
  • - [% display_warning = 1 %] - [% END %] - - [% IF display_warning %] -

    - Please be aware of the consequences of this before continuing. -

    - [% END %] -

    Do you really want to delete this user account?

    + [% IF accept_deletion %] +

    + Please be aware of the consequences of this before continuing. +

    +

    Do you really want to delete this user account?

    -
    -

    - - - - - [% INCLUDE listselectionhiddenfields %] -

    -
    +
    +

    + + + + + [% INCLUDE listselectionhiddenfields %] +

    +
    +

    If you do not want to delete the user account at this time, + [% ELSE %] +

    You cannot delete this user account due to unsafe actions reported above. You can + [% END %] -

    If you do not want to delete the user account at this time, + [% END %] [% END %]