1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Remove PhabricatorOwnersOwner::loadAffiliatedPackages()

Summary: See D3193 for discussion.

Test Plan: Ran `owners.query` via conduit, verified I got sensible output.

Reviewers: vrana, btrahan, meitros

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D3194
This commit is contained in:
epriestley 2012-08-08 12:26:13 -07:00
parent 8cdd801515
commit 386735a39d
2 changed files with 5 additions and 36 deletions

View file

@ -81,26 +81,6 @@ final class ConduitAPI_owners_query_Method
return $packages; return $packages;
} }
protected static function queryByAffiliatedUser($owner) {
$is_valid_phid =
phid_get_type($owner) == PhabricatorPHIDConstants::PHID_TYPE_USER;
if (!$is_valid_phid) {
throw id(new ConduitException('ERR-INVALID-PARAMETER'))
->setErrorDescription(
'Expected user PHID for affiliation, got '.$owner);
}
$owners = PhabricatorOwnersOwner::loadAffiliatedPackages($owner);
$package_ids = mpull($owners, 'getPackageID');
$packages = array();
foreach ($package_ids as $id) {
$packages[] = id(new PhabricatorOwnersPackage())->load($id);
}
return $packages;
}
public static function queryByPath($repo_callsign, $path) { public static function queryByPath($repo_callsign, $path) {
// note: we call this from the deprecated path.getowners conduit call. // note: we call this from the deprecated path.getowners conduit call.
@ -165,9 +145,12 @@ final class ConduitAPI_owners_query_Method
} }
if ($is_affiliated_query) { if ($is_affiliated_query) {
$packages = self::queryByAffiliatedUser( $query = id(new PhabricatorOwnersPackageQuery())
$request->getValue('userAffiliated')); ->setViewer($request->getUser());
$query->withOwnerPHIDs(array($request->getValue('userAffiliated')));
$packages = $query->execute();
} else if ($is_owner_query) { } else if ($is_owner_query) {
$owner = nonempty( $owner = nonempty(
$request->getValue('userOwner'), $request->getValue('userOwner'),

View file

@ -69,18 +69,4 @@ final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO {
return array_unique(array_merge($users_in_project_phids, $user_phids)); return array_unique(array_merge($users_in_project_phids, $user_phids));
} }
// Loads all affiliated packages for a user. This includes packages owned by
// any project the user is a member of.
public static function loadAffiliatedPackages($user_phid) {
$query = new PhabricatorProjectQuery();
$query->withMemberPHIDs(array($user_phid));
$query->withStatus(PhabricatorProjectQuery::STATUS_ACTIVE);
$projects = $query->execute();
$phids = mpull($projects, 'getPHID') + array($user_phid);
return id(new PhabricatorOwnersOwner())->loadAllWhere(
'userPHID in (%Ls)',
$phids);
}
} }