$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;
=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:
$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(*)
{reason => "not_visible",
action => "delete",
object => "user"});
- productResponsibilities($otherUserID)
+ @{$otherUser->product_responsibilities()}
&& ThrowUserError('user_has_responsibility');
Bugzilla->logout_user_by_id($otherUserID);
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 {
# 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
[% 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'] %]
[% 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