Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/PhabricatorOwnersOwner.php
Show All 34 Lines | final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO { | ||||
} | } | ||||
// Loads all user phids affiliated with a set of packages. This includes both | // Loads all user phids affiliated with a set of packages. This includes both | ||||
// user owners and all members of any project owners | // user owners and all members of any project owners | ||||
public static function loadAffiliatedUserPHIDs(array $package_ids) { | public static function loadAffiliatedUserPHIDs(array $package_ids) { | ||||
if (!$package_ids) { | if (!$package_ids) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$owners = id(new PhabricatorOwnersOwner())->loadAllWhere( | $owners = id(new PhabricatorOwnersOwner())->loadAllWhere( | ||||
'packageID IN (%Ls)', | 'packageID IN (%Ls)', | ||||
$package_ids); | $package_ids); | ||||
$all_phids = phid_group_by_type(mpull($owners, 'getUserPHID')); | $all_phids = phid_group_by_type(mpull($owners, 'getUserPHID')); | ||||
$user_phids = idx($all_phids, | $user_phids = idx($all_phids, | ||||
PhabricatorPeopleUserPHIDType::TYPECONST, | PhabricatorPeopleUserPHIDType::TYPECONST, | ||||
array()); | array()); | ||||
$users_in_project_phids = array(); | if ($user_phids) { | ||||
$project_phids = idx( | $projects = id(new PhabricatorProjectQuery()) | ||||
$all_phids, | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
PhabricatorProjectProjectPHIDType::TYPECONST); | ->withMemberPHIDs($user_phids) | ||||
if ($project_phids) { | ->withIsMilestone(false) | ||||
$query = id(new PhabricatorEdgeQuery()) | ->execute(); | ||||
->withSourcePHIDs($project_phids) | $project_phids = mpull($projects, 'getPHID'); | ||||
->withEdgeTypes(array( | } else { | ||||
PhabricatorProjectProjectHasMemberEdgeType::EDGECONST, | $project_phids = array(); | ||||
)); | |||||
$query->execute(); | |||||
$users_in_project_phids = $query->getDestinationPHIDs(); | |||||
} | } | ||||
return array_unique(array_merge($users_in_project_phids, $user_phids)); | $all_phids = array_fuse($user_phids) + array_fuse($project_phids); | ||||
return array_values($all_phids); | |||||
} | } | ||||
} | } |