From 3b7203dc9ffe441e3e0c1710630c22bf03ee4214 Mon Sep 17 00:00:00 2001 From: Nick Harper Date: Thu, 28 Mar 2013 15:00:11 -0700 Subject: [PATCH] Include more packages in Owned Packages view Summary: If a user is a member of a project, and that project is an owner of a package, it would make sense to display those packages in the list of owned packages. Test Plan: create a project that I'm a member of, then create a package that that project owns, and reload /owners/view/owned/ and see the package listed. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5355 --- .../PhabricatorOwnersController.php | 1 + .../PhabricatorOwnersListController.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/applications/owners/controller/PhabricatorOwnersController.php b/src/applications/owners/controller/PhabricatorOwnersController.php index f41ac3f1c2..2bc82f2086 100644 --- a/src/applications/owners/controller/PhabricatorOwnersController.php +++ b/src/applications/owners/controller/PhabricatorOwnersController.php @@ -61,6 +61,7 @@ abstract class PhabricatorOwnersController extends PhabricatorController { $nav->addLabel('Packages'); $this->getExtraPackageViews($nav); $nav->addFilter('view/owned', 'Owned'); + $nav->addFilter('view/projects', 'Projects'); $nav->addFilter('view/all', 'All'); $nav->selectFilter($this->getSideNavFilter(), 'view/owned'); diff --git a/src/applications/owners/controller/PhabricatorOwnersListController.php b/src/applications/owners/controller/PhabricatorOwnersListController.php index babe04b9c1..b77b60fcb9 100644 --- a/src/applications/owners/controller/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/PhabricatorOwnersListController.php @@ -105,6 +105,25 @@ final class PhabricatorOwnersListController $user->getPHID()); $packages = $package->loadAllFromArray($data); + $header = 'Owned Packages'; + $nodata = 'No owned packages'; + break; + case 'projects': + $projects = id(new PhabricatorProjectQuery()) + ->setViewer($user) + ->withMemberPHIDs(array($user->getPHID())) + ->withStatus(PhabricatorProjectQuery::STATUS_ANY) + ->execute(); + $owner_phids = mpull($projects, 'getPHID'); + $data = queryfx_all( + $package->establishConnection('r'), + 'SELECT p.* FROM %T p JOIN %T o ON p.id = o.packageID + WHERE o.userPHID IN (%Ls) GROUP BY p.id', + $package->getTableName(), + $owner->getTableName(), + $owner_phids); + $packages = $package->loadAllFromArray($data); + $header = 'Owned Packages'; $nodata = 'No owned packages'; break;