Commit 05cc6289 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 284273: Move productResponsibilities from editusers.cgi to Bugzilla::User.pm…

Bug 284273: Move productResponsibilities from editusers.cgi to Bugzilla::User.pm - Patch by Marc Schumann <wurblzap@gmail.com> r=mkanat a=justdave
parent 5609425d
......@@ -530,6 +530,27 @@ sub derive_groups {
$dbh->bz_unlock_tables() unless $already_locked;
}
sub product_responsibilities {
my $self = shift;
return $self->{'product_resp'} if defined $self->{'product_resp'};
return [] unless $self->id;
my $h = Bugzilla->dbh->selectall_arrayref(
qq{SELECT products.name AS productname,
components.name AS componentname,
initialowner,
initialqacontact
FROM products, components
WHERE products.id = components.product_id
AND ? IN (initialowner, initialqacontact)
},
{'Slice' => {}}, $self->id);
$self->{'product_resp'} = $h;
return $h;
}
sub can_bless {
my $self = shift;
......@@ -1386,6 +1407,32 @@ all MySQL supported, this will go away.
=end undocumented
=item C<product_responsibilities>
Retrieve user's product responsibilities as a list of hashes.
One hash per Bugzilla component the user has a responsibility for.
These are the hash keys:
=over
=item productname
Name of the product.
=item componentname
Name of the component.
=item initialowner
User ID of default assignee.
=item initialqacontact
User ID of default QA contact.
=back
=item C<can_bless>
When called with no arguments:
......
......@@ -404,10 +404,6 @@ if ($action eq 'search') {
$vars->{'otheruser'} = $otherUser;
$vars->{'editcomponents'} = UserInGroup('editcomponents');
# If the user is default assignee or default QA contact of a component,
# then no deletion is possible.
$vars->{'product_responsibilities'} = productResponsibilities($otherUserID);
# Find other cross references.
$vars->{'bugs'} = $dbh->selectrow_array(
qq{SELECT COUNT(*)
......@@ -504,7 +500,7 @@ if ($action eq 'search') {
{reason => "not_visible",
action => "delete",
object => "user"});
productResponsibilities($otherUserID)
@{$otherUser->product_responsibilities()}
&& ThrowUserError('user_has_responsibility');
Bugzilla->logout_user_by_id($otherUserID);
......@@ -672,27 +668,6 @@ sub canSeeUser {
return $dbh->selectrow_array($query, undef, $otherUserID);
}
# Retrieve product responsibilities, usable for both display and verification.
sub productResponsibilities {
my $userid = shift;
my $h = $dbh->selectall_arrayref(
qq{SELECT products.name AS productname,
components.name AS componentname,
initialowner,
initialqacontact
FROM products, components
WHERE products.id = components.product_id
AND ? IN (initialowner, initialqacontact)
},
{'Slice' => {}}, $userid);
if (@$h) {
return $h;
} else {
return undef;
}
}
# Retrieve user data for the user editing form. User creation and user
# editing code rely on this to call derive_groups().
sub userDataToVars {
......
......@@ -21,11 +21,6 @@
# editusers: is viewing user member of editusers?
# editcomponents: is viewing user member of editcomponents?
# otheruser: Bugzilla::User object of the viewed user.
# product_responsibilities: list of hashes, one entry per Bugzilla component.
# productname: Name of the product.
# componentname: Name of the component.
# initialowner: User ID of default assignee.
# initialqacontact: User ID of default QA contact.
# bugs: number of bugs the viewed user has a role in
# bug_activity: number of bugs the viewed user has activity
# entries on
......@@ -85,12 +80,12 @@
[% END %]
</td>
</tr>
[% IF product_responsibilities.size %]
[% IF otheruser.product_responsibilities.size %]
<tr>
<th>Product responsibilities:</th>
<td>
<ul>
[% FOREACH component = product_responsibilities %]
[% FOREACH component = otheruser.product_responsibilities %]
<li>
[% andstring = '' %]
[% FOREACH responsibility = ['initialowner', 'initialqacontact'] %]
......@@ -118,7 +113,7 @@
[% END %]
</table>
[% IF product_responsibilities.size %]
[% IF otheruser.product_responsibilities.size %]
<p>
You can't delete this user at this time because
[%+ otheruser.login FILTER html %] has got responsibilities for at least
......
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