Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/PhabricatorOwnersOwner.php
Show All 39 Lines | 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')); | $type_user = PhabricatorPeopleUserPHIDType::TYPECONST; | ||||
$type_project = PhabricatorProjectProjectPHIDType::TYPECONST; | |||||
$user_phids = idx($all_phids, | $user_phids = array(); | ||||
PhabricatorPeopleUserPHIDType::TYPECONST, | $project_phids = array(); | ||||
array()); | foreach ($owners as $owner) { | ||||
$owner_phid = $owner->getUserPHID(); | |||||
switch (phid_get_type($owner_phid)) { | |||||
case PhabricatorPeopleUserPHIDType::TYPECONST: | |||||
$user_phids[] = $owner_phid; | |||||
break; | |||||
case PhabricatorProjectProjectPHIDType::TYPECONST: | |||||
$project_phids[] = $owner_phid; | |||||
break; | |||||
} | |||||
} | |||||
if ($user_phids) { | if ($project_phids) { | ||||
$projects = id(new PhabricatorProjectQuery()) | $projects = id(new PhabricatorProjectQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withMemberPHIDs($user_phids) | ->withPHIDs($project_phids) | ||||
->withIsMilestone(false) | ->needMembers(true) | ||||
->execute(); | ->execute(); | ||||
$project_phids = mpull($projects, 'getPHID'); | foreach ($projects as $project) { | ||||
} else { | foreach ($project->getMemberPHIDs() as $member_phid) { | ||||
$project_phids = array(); | $user_phids[] = $member_phid; | ||||
} | |||||
} | |||||
} | } | ||||
$all_phids = array_fuse($user_phids) + array_fuse($project_phids); | $user_phids = array_fuse($user_phids); | ||||
return array_values($user_phids); | |||||
return array_values($all_phids); | |||||
} | } | ||||
} | } |