Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96940196
PhabricatorOwnersOwner.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Dec 31, 23:49
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Jan 2, 23:49 (2 d)
Engine
blob
Format
Raw Data
Handle
23295614
Attached To
rPH Phabricator
PhabricatorOwnersOwner.php
View Options
<?php
final
class
PhabricatorOwnersOwner
extends
PhabricatorOwnersDAO
{
protected
$packageID
;
// this can be a project or a user. We assume that all members of a project
// owner also own the package; use the loadAffiliatedUserPHIDs method if
// you want to recursively grab all user ids that own a package
protected
$userPHID
;
public
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_TIMESTAMPS
=>
false
,
)
+
parent
::
getConfiguration
();
}
public
static
function
loadAllForPackages
(
array
$packages
)
{
assert_instances_of
(
$packages
,
'PhabricatorOwnersPackage'
);
if
(!
$packages
)
{
return
array
();
}
return
id
(
new
PhabricatorOwnersOwner
())->
loadAllWhere
(
'packageID IN (%Ls)'
,
mpull
(
$packages
,
'getID'
));
}
// Loads all user phids affiliated with a set of packages. This includes both
// user owners and all members of any project owners
public
static
function
loadAffiliatedUserPHIDs
(
array
$package_ids
)
{
if
(!
$package_ids
)
{
return
array
();
}
$owners
=
id
(
new
PhabricatorOwnersOwner
())->
loadAllWhere
(
'packageID IN (%Ls)'
,
$package_ids
);
$all_phids
=
phid_group_by_type
(
mpull
(
$owners
,
'getUserPHID'
));
$user_phids
=
idx
(
$all_phids
,
PhabricatorPHIDConstants
::
PHID_TYPE_USER
,
array
());
$users_in_project_phids
=
array
();
$project_phids
=
idx
(
$all_phids
,
PhabricatorProjectPHIDTypeProject
::
TYPECONST
);
if
(
$project_phids
)
{
$query
=
id
(
new
PhabricatorEdgeQuery
())
->
withSourcePHIDs
(
$project_phids
)
->
withEdgeTypes
(
array
(
PhabricatorEdgeConfig
::
TYPE_PROJ_MEMBER
));
$query
->
execute
();
$users_in_project_phids
=
$query
->
getDestinationPHIDs
();
}
return
array_unique
(
array_merge
(
$users_in_project_phids
,
$user_phids
));
}
}
Event Timeline
Log In to Comment