Commit 8132a036 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 453681: Do not display the "Yes, delete" button if deleting a user account…

Bug 453681: Do not display the "Yes, delete" button if deleting a user account would cause FK constraint errors - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=wurblzap a=LpSolit
parent c72d0568
...@@ -358,6 +358,9 @@ if ($action eq 'search') { ...@@ -358,6 +358,9 @@ if ($action eq 'search') {
$vars->{'otheruser'} = $otherUser; $vars->{'otheruser'} = $otherUser;
# Find other cross references. # 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( $vars->{'assignee_or_qa'} = $dbh->selectrow_array(
qq{SELECT COUNT(*) qq{SELECT COUNT(*)
FROM bugs FROM bugs
...@@ -372,6 +375,9 @@ if ($action eq 'search') { ...@@ -372,6 +375,9 @@ if ($action eq 'search') {
$vars->{'bugs_activity'} = $dbh->selectrow_array( $vars->{'bugs_activity'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM bugs_activity WHERE who = ?', 'SELECT COUNT(*) FROM bugs_activity WHERE who = ?',
undef, $otherUserID); undef, $otherUserID);
$vars->{'component_cc'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM component_cc WHERE user_id = ?',
undef, $otherUserID);
$vars->{'email_setting'} = $dbh->selectrow_array( $vars->{'email_setting'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM email_setting WHERE user_id = ?', 'SELECT COUNT(*) FROM email_setting WHERE user_id = ?',
undef, $otherUserID); undef, $otherUserID);
...@@ -402,6 +408,9 @@ if ($action eq 'search') { ...@@ -402,6 +408,9 @@ if ($action eq 'search') {
$vars->{'profiles_activity'} = $dbh->selectrow_array( $vars->{'profiles_activity'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM profiles_activity WHERE who = ? AND userid != ?', 'SELECT COUNT(*) FROM profiles_activity WHERE who = ? AND userid != ?',
undef, ($otherUserID, $otherUserID)); undef, ($otherUserID, $otherUserID));
$vars->{'quips'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM quips WHERE userid = ?',
undef, $otherUserID);
$vars->{'series'} = $dbh->selectrow_array( $vars->{'series'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM series WHERE creator = ?', 'SELECT COUNT(*) FROM series WHERE creator = ?',
undef, $otherUserID); undef, $otherUserID);
......
...@@ -101,17 +101,34 @@ ...@@ -101,17 +101,34 @@
For now, you can For now, you can
[% END %] [% END %]
[% ELSE %] [% ELSE %]
[% accept_deletion = 1 %]
<h2>Confirmation</h2> [% IF attachments || reporter || bugs_activity || flags.setter || longdescs || profiles_activity %]
[% display_warning = 0 %]
[% IF reporter || bugs_activity || flags.setter || longdescs || profiles_activity %]
<div class="criticalmessages"> <div class="criticalmessages">
<p>The following deletions are <b>highly not recommended</b> and <p>The following deletions are <b>unsafe</b> and would generate referential
will generate referential integrity inconsistencies!</p> integrity inconsistencies!</p>
<ul> <ul>
[% IF attachments %]
<li>
[% otheruser.login FILTER html %]
<a href="buglist.cgi?field0-0-0=attachments.submitter&type0-0-0=equals&value0-0-0=
[%- otheruser.login FILTER url_quote %]">has submitted
[% IF attachments == 1 %]
one attachment
[% ELSE %]
[%+ attachments %] attachments
[% END %]</a>.
If you delete the user account, the database records will be
inconsistent, resulting in
[% IF attachments == 1 %]
this attachment
[% ELSE %]
these attachments
[% END %]
not appearing in [% terms.bugs %] any more.
</li>
[% END %]
[% IF reporter %] [% IF reporter %]
<li> <li>
[% otheruser.login FILTER html %] [% otheruser.login FILTER html %]
...@@ -205,11 +222,11 @@ ...@@ -205,11 +222,11 @@
[% END %] [% END %]
</ul> </ul>
</div> </div>
[% display_warning = 1 %] [% accept_deletion = 0 %]
[% END %] [% END %]
[% IF assignee_or_qa || cc || email_setting || flags.requestee || [% IF assignee_or_qa || cc || component_cc || email_setting || flags.requestee ||
namedqueries || profile_setting || series || votes || watch.watched || namedqueries || profile_setting || quips || series || votes || watch.watched ||
watch.watcher || whine_events || whine_schedules %] watch.watcher || whine_events || whine_schedules %]
<div class="warningmessages"> <div class="warningmessages">
<p>The following deletions are <b>safe</b> and will not generate <p>The following deletions are <b>safe</b> and will not generate
...@@ -245,6 +262,17 @@ ...@@ -245,6 +262,17 @@
If you delete the user account, it will be removed from these CC lists. If you delete the user account, it will be removed from these CC lists.
</li> </li>
[% END %] [% END %]
[% IF component_cc %]
<li>
[% otheruser.login FILTER html %] is on the default CC list of
[% IF component_cc == 1 %]
one component
[% ELSE %]
[%+ component_cc %] components
[% END %]</a>.
If you delete the user account, it will be removed from these CC lists.
</li>
[% END %]
[% IF email_setting %] [% IF email_setting %]
<li> <li>
The user's e-mail settings will be deleted along with the user The user's e-mail settings will be deleted along with the user
...@@ -327,6 +355,23 @@ ...@@ -327,6 +355,23 @@
will be deleted along with the user account. will be deleted along with the user account.
</li> </li>
[% END %] [% END %]
[% IF quips %]
<li>
[% 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.
</li>
[% END %]
[% IF votes %] [% IF votes %]
<li> <li>
[% otheruser.login FILTER html %] has voted on [% otheruser.login FILTER html %] has voted on
...@@ -402,28 +447,28 @@ ...@@ -402,28 +447,28 @@
[% END %] [% END %]
</ul> </ul>
</div> </div>
[% display_warning = 1 %]
[% END %]
[% IF display_warning %]
<p class="areyoureallyreallysure">
Please be aware of the consequences of this before continuing.
</p>
[% END %]
<p>Do you really want to delete this user account?</p> [% IF accept_deletion %]
<p class="areyoureallyreallysure">
Please be aware of the consequences of this before continuing.
</p>
<p>Do you really want to delete this user account?</p>
<form method="post" action="editusers.cgi"> <form method="post" action="editusers.cgi">
<p> <p>
<input type="submit" id="delete" value="Yes, delete"/> <input type="submit" id="delete" value="Yes, delete"/>
<input type="hidden" name="action" value="delete" /> <input type="hidden" name="action" value="delete" />
<input type="hidden" name="userid" value="[% otheruser.id %]" /> <input type="hidden" name="userid" value="[% otheruser.id %]" />
<input type="hidden" name="token" value="[% token FILTER html %]"> <input type="hidden" name="token" value="[% token FILTER html %]">
[% INCLUDE listselectionhiddenfields %] [% INCLUDE listselectionhiddenfields %]
</p> </p>
</form> </form>
<p>If you do not want to delete the user account at this time,
[% ELSE %]
<p><b>You cannot delete this user account</b> due to unsafe actions reported above. You can
[% END %]
<p>If you do not want to delete the user account at this time, [% END %]
[% END %] [% END %]
<a href="editusers.cgi?action=edit&amp;userid=[% otheruser.id %] <a href="editusers.cgi?action=edit&amp;userid=[% otheruser.id %]
......
...@@ -506,12 +506,15 @@ ...@@ -506,12 +506,15 @@
], ],
'admin/users/confirm-delete.html.tmpl' => [ 'admin/users/confirm-delete.html.tmpl' => [
'attachments'
'reporter', 'reporter',
'assignee_or_qa', 'assignee_or_qa',
'cc', 'cc',
'component_cc',
'flags.requestee', 'flags.requestee',
'flags.setter', 'flags.setter',
'longdescs', 'longdescs',
'quips',
'votes', 'votes',
'series', 'series',
'watch.watched', 'watch.watched',
......
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