Commit 4d36c161 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 302723: Deleting a user account when this user is the assignee or QA contact…

Bug 302723: Deleting a user account when this user is the assignee or QA contact of a bug should reassign this bug to the default ones - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wurblzap a=justdave
parent 59e098fd
...@@ -404,14 +404,14 @@ if ($action eq 'search') { ...@@ -404,14 +404,14 @@ if ($action eq 'search') {
$vars->{'editcomponents'} = UserInGroup('editcomponents'); $vars->{'editcomponents'} = UserInGroup('editcomponents');
# Find other cross references. # Find other cross references.
$vars->{'bugs'} = $dbh->selectrow_array( $vars->{'assignee_or_qa'} = $dbh->selectrow_array(
qq{SELECT COUNT(*) qq{SELECT COUNT(*)
FROM bugs FROM bugs
WHERE assigned_to = ? OR WHERE assigned_to = ? OR qa_contact = ?},
qa_contact = ? OR undef, ($otherUserID, $otherUserID));
reporter = ? $vars->{'reporter'} = $dbh->selectrow_array(
}, 'SELECT COUNT(*) FROM bugs WHERE reporter = ?',
undef, ($otherUserID, $otherUserID, $otherUserID)); undef, $otherUserID);
$vars->{'cc'} = $dbh->selectrow_array( $vars->{'cc'} = $dbh->selectrow_array(
'SELECT COUNT(*) FROM cc WHERE who = ?', 'SELECT COUNT(*) FROM cc WHERE who = ?',
undef, $otherUserID); undef, $otherUserID);
...@@ -487,7 +487,8 @@ if ($action eq 'search') { ...@@ -487,7 +487,8 @@ if ($action eq 'search') {
'series_data WRITE', 'series_data WRITE',
'whine_schedules WRITE', 'whine_schedules WRITE',
'whine_queries WRITE', 'whine_queries WRITE',
'whine_events WRITE'); 'whine_events WRITE',
'bugs WRITE');
Param('allowuserdeletion') Param('allowuserdeletion')
|| ThrowUserError('users_deletion_disabled'); || ThrowUserError('users_deletion_disabled');
...@@ -565,6 +566,37 @@ if ($action eq 'search') { ...@@ -565,6 +566,37 @@ if ($action eq 'search') {
$sth_deleteWhineEvent->execute($id); $sth_deleteWhineEvent->execute($id);
} }
# 3) Bugs
# 3.1) fall back to the default assignee
my $buglist = $dbh->selectall_arrayref(
'SELECT bug_id, initialowner
FROM bugs
INNER JOIN components ON components.id = bugs.component_id
WHERE assigned_to = ?', undef, $otherUserID);
my $sth_updateAssignee = $dbh->prepare(
'UPDATE bugs SET assigned_to = ? WHERE bug_id = ?');
foreach my $bug (@$buglist) {
my ($bug_id, $default_assignee) = @$bug;
$sth_updateAssignee->execute($default_assignee, $bug_id);
}
# 3.2) fall back to the default QA contact
$buglist = $dbh->selectall_arrayref(
'SELECT bug_id, initialqacontact
FROM bugs
INNER JOIN components ON components.id = bugs.component_id
WHERE qa_contact = ?', undef, $otherUserID);
my $sth_updateQAcontact = $dbh->prepare(
'UPDATE bugs SET qa_contact = ? WHERE bug_id = ?');
foreach my $bug (@$buglist) {
my ($bug_id, $default_qa_contact) = @$bug;
$sth_updateQAcontact->execute($default_qa_contact, $bug_id);
}
# Finally, remove the user account itself. # Finally, remove the user account itself.
$dbh->do('DELETE FROM profiles WHERE userid = ?', undef, $otherUserID); $dbh->do('DELETE FROM profiles WHERE userid = ?', undef, $otherUserID);
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
# editusers: is viewing user member of editusers? # editusers: is viewing user member of editusers?
# editcomponents: is viewing user member of editcomponents? # editcomponents: is viewing user member of editcomponents?
# otheruser: Bugzilla::User object of the viewed user. # otheruser: Bugzilla::User object of the viewed user.
# bugs: number of bugs the viewed user has a role in # reporter: number of bugs reported by the user
# assignee_or_qa: number of bugs the user is either the assignee
# or the QA contact
# bug_activity: number of bugs the viewed user has activity # bug_activity: number of bugs the viewed user has activity
# entries on # entries on
# cc number of bugs the viewed user is cc list member # cc number of bugs the viewed user is cc list member
...@@ -129,24 +131,22 @@ ...@@ -129,24 +131,22 @@
<h2>Confirmation</h2> <h2>Confirmation</h2>
[% IF bugs || bug_activity || cc || flags.requestee || flags.setter || [% IF reporter || assignee_or_qa || bug_activity || cc || flags.requestee ||
longdescs || namedqueries || profiles_activity || series || votes || flags.setter || longdescs || namedqueries || profiles_activity || series ||
watch.watched || watch.watcher || whine_events || whine_schedules %] votes || watch.watched || watch.watcher || whine_events || whine_schedules %]
<ul class="warningmessages"> <ul class="warningmessages">
[% IF bugs %] [% IF reporter %]
<li> <li>
[% otheruser.login FILTER html %] [% otheruser.login FILTER html %]
<a href="buglist.cgi?emailassigned_to1=1&amp;emailreporter1=1&amp;emailqa_contact1=1&amp;emailtype1=exact&amp;email1=[% otheruser.login FILTER url_quote %]">is <a href="buglist.cgi?emailreporter1=1&amp;emailtype1=exact&amp;email1=[% otheruser.login FILTER url_quote %]">has reported
related to [% IF reporter == 1 %]
[% IF bugs == 1 %] one [% terms.bug %]
[%+ terms.abug %]
[% ELSE %] [% ELSE %]
[%+ bugs %] [%+ terms.bugs %] [%+ reporter %] [%+ terms.bugs %]
[% END %]</a>, by having reported, being assigned to or being [% END %]</a>.
the QA contact.
If you delete the user account, the [% terms.bugs %] table in the If you delete the user account, the [% terms.bugs %] table in the
database will be inconsistent, resulting in database will be inconsistent, resulting in
[% IF bugs == 1 %] [% IF reporter == 1 %]
this [% terms.bug %] this [% terms.bug %]
[% ELSE %] [% ELSE %]
these [% terms.bugs %] these [% terms.bugs %]
...@@ -154,6 +154,20 @@ ...@@ -154,6 +154,20 @@
not appearing in [% terms.bug %] lists any more. not appearing in [% terms.bug %] lists any more.
</li> </li>
[% END %] [% END %]
[% IF assignee_or_qa %]
<li>
[% otheruser.login FILTER html %]
<a href="buglist.cgi?emailassigned_to1=1&amp;emailqa_contact1=1&amp;emailtype1=exact&amp;email1=[% otheruser.login FILTER url_quote %]">is
the assignee or the QA contact of
[% IF assignee_or_qa == 1 %]
one [% terms.bug %]
[% ELSE %]
[%+ assignee_or_qa %] [%+ terms.bugs %]
[% END %]</a>.
If you delete the user account, these roles will fall back to
the default assignee or default QA contact.
</li>
[% END %]
[% IF bugs_activity %] [% IF bugs_activity %]
<li> <li>
[% otheruser.login FILTER html %] has made [% otheruser.login FILTER html %] has made
......
...@@ -583,7 +583,8 @@ ...@@ -583,7 +583,8 @@
'admin/users/confirm-delete.html.tmpl' => [ 'admin/users/confirm-delete.html.tmpl' => [
'andstring', 'andstring',
'responsibilityterms.$responsibility', 'responsibilityterms.$responsibility',
'bugs', 'reporter',
'assignee_or_qa',
'cc', 'cc',
'flags.requestee', 'flags.requestee',
'flags.setter', 'flags.setter',
......
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