Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99641161
PhabricatorOwnersPackageQuery.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
Sat, Jan 25, 22:42
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Jan 27, 22:42 (2 d)
Engine
blob
Format
Raw Data
Handle
23837363
Attached To
rPH Phabricator
PhabricatorOwnersPackageQuery.php
View Options
<?php
final
class
PhabricatorOwnersPackageQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$phids
;
private
$ownerPHIDs
;
/**
* Owners are direct owners, and members of owning projects.
*/
public
function
withOwnerPHIDs
(
array
$phids
)
{
$this
->
ownerPHIDs
=
$phids
;
return
$this
;
}
public
function
withPHIDs
(
array
$phids
)
{
$this
->
phids
=
$phids
;
return
$this
;
}
protected
function
loadPage
()
{
$table
=
new
PhabricatorOwnersPackage
();
$conn_r
=
$table
->
establishConnection
(
'r'
);
$data
=
queryfx_all
(
$conn_r
,
'SELECT p.* FROM %T p %Q %Q %Q %Q'
,
$table
->
getTableName
(),
$this
->
buildJoinClause
(
$conn_r
),
$this
->
buildWhereClause
(
$conn_r
),
$this
->
buildOrderClause
(
$conn_r
),
$this
->
buildLimitClause
(
$conn_r
));
return
$table
->
loadAllFromArray
(
$data
);
}
private
function
buildJoinClause
(
AphrontDatabaseConnection
$conn_r
)
{
$joins
=
array
();
if
(
$this
->
ownerPHIDs
)
{
$joins
[]
=
qsprintf
(
$conn_r
,
'JOIN %T o ON o.packageID = p.id'
,
id
(
new
PhabricatorOwnersOwner
())->
getTableName
());
}
return
implode
(
' '
,
$joins
);
}
private
function
buildWhereClause
(
AphrontDatabaseConnection
$conn_r
)
{
$where
=
array
();
if
(
$this
->
phids
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'p.phid IN (%Ls)'
,
$this
->
phids
);
}
if
(
$this
->
ownerPHIDs
)
{
$base_phids
=
$this
->
ownerPHIDs
;
$query
=
new
PhabricatorProjectQuery
();
$query
->
setViewer
(
$this
->
getViewer
());
$query
->
withMemberPHIDs
(
$base_phids
);
$projects
=
$query
->
execute
();
$project_phids
=
mpull
(
$projects
,
'getPHID'
);
$all_phids
=
array_merge
(
$base_phids
,
$project_phids
);
$where
[]
=
qsprintf
(
$conn_r
,
'o.userPHID IN (%Ls)'
,
$all_phids
);
}
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
return
$this
->
formatWhereClause
(
$where
);
}
public
function
getQueryApplicationClass
()
{
return
'PhabricatorApplicationOwners'
;
}
}
Event Timeline
Log In to Comment