From 05cc6289d00b21e12d4d59282384b8729a5c2b57 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 25 Jun 2005 05:33:05 +0000 Subject: Bug 284273: Move productResponsibilities from editusers.cgi to Bugzilla::User.pm - Patch by Marc Schumann r=mkanat a=justdave --- Bugzilla/User.pm | 47 ++++++++++++++++++++++ editusers.cgi | 27 +------------ .../default/admin/users/confirm-delete.html.tmpl | 11 ++--- 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 + +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 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 %] - [% IF product_responsibilities.size %] + [% IF otheruser.product_responsibilities.size %] Product responsibilities:
    - [% FOREACH component = product_responsibilities %] + [% FOREACH component = otheruser.product_responsibilities %]
  • [% andstring = '' %] [% FOREACH responsibility = ['initialowner', 'initialqacontact'] %] @@ -118,7 +113,7 @@ [% END %] -[% IF product_responsibilities.size %] +[% IF otheruser.product_responsibilities.size %]

    You can't delete this user at this time because [%+ otheruser.login FILTER html %] has got responsibilities for at least -- cgit v1.2.3-24-g4f1b