]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 284273: Move productResponsibilities from editusers.cgi to Bugzilla::User.pm...
authorlpsolit%gmail.com <>
Sat, 25 Jun 2005 05:33:05 +0000 (05:33 +0000)
committerlpsolit%gmail.com <>
Sat, 25 Jun 2005 05:33:05 +0000 (05:33 +0000)
Bugzilla/User.pm
editusers.cgi
template/en/default/admin/users/confirm-delete.html.tmpl

index 87239bc6ed02285df221eb9d8ed830cd1ed35224..3e68647c67301fd80f5cb3c9bc668d4fd7555d55 100644 (file)
@@ -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:
index 371e2a6121fcd6aab6b4500d7b760350ffb53ca1..ba5cc827e0dd051db4c0271a0b7f82c9b4d073ba 100755 (executable)
@@ -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 {
index 4e5fd9c10af0c06db999095de3da04f13efcc39b..205f96b151b6510fd1353fa70b563c69e8125ac6 100644 (file)
   # 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