summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-06-25 07:33:05 +0200
committerlpsolit%gmail.com <>2005-06-25 07:33:05 +0200
commit05cc6289d00b21e12d4d59282384b8729a5c2b57 (patch)
treefdf103232c9428fe4c9f88b885afa790abc72f8d
parent5609425d739829a7c26840b021e3a89dceb34005 (diff)
downloadbugzilla-05cc6289d00b21e12d4d59282384b8729a5c2b57.tar.gz
bugzilla-05cc6289d00b21e12d4d59282384b8729a5c2b57.tar.xz
Bug 284273: Move productResponsibilities from editusers.cgi to Bugzilla::User.pm - Patch by Marc Schumann <wurblzap@gmail.com> r=mkanat a=justdave
-rw-r--r--Bugzilla/User.pm47
-rwxr-xr-xeditusers.cgi27
-rw-r--r--template/en/default/admin/users/confirm-delete.html.tmpl11
3 files changed, 51 insertions, 34 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 87239bc6e..3e68647c6 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -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:
diff --git a/editusers.cgi b/editusers.cgi
index 371e2a612..ba5cc827e 100755
--- a/editusers.cgi
+++ b/editusers.cgi
@@ -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 {
diff --git a/template/en/default/admin/users/confirm-delete.html.tmpl b/template/en/default/admin/users/confirm-delete.html.tmpl
index 4e5fd9c10..205f96b15 100644
--- a/template/en/default/admin/users/confirm-delete.html.tmpl
+++ b/template/en/default/admin/users/confirm-delete.html.tmpl
@@ -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