Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93532265
PhabricatorAuthSSHKeyQuery.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
Fri, Nov 29, 12:34
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Dec 1, 12:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22658525
Attached To
rPH Phabricator
PhabricatorAuthSSHKeyQuery.php
View Options
<?php
final
class
PhabricatorAuthSSHKeyQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$ids
;
private
$objectPHIDs
;
private
$keys
;
public
function
withIDs
(
array
$ids
)
{
$this
->
ids
=
$ids
;
return
$this
;
}
public
function
withObjectPHIDs
(
array
$object_phids
)
{
$this
->
objectPHIDs
=
$object_phids
;
return
$this
;
}
public
function
withKeys
(
array
$keys
)
{
assert_instances_of
(
$keys
,
'PhabricatorAuthSSHPublicKey'
);
$this
->
keys
=
$keys
;
return
$this
;
}
protected
function
loadPage
()
{
$table
=
new
PhabricatorAuthSSHKey
();
$conn_r
=
$table
->
establishConnection
(
'r'
);
$data
=
queryfx_all
(
$conn_r
,
'SELECT * FROM %T %Q %Q %Q'
,
$table
->
getTableName
(),
$this
->
buildWhereClause
(
$conn_r
),
$this
->
buildOrderClause
(
$conn_r
),
$this
->
buildLimitClause
(
$conn_r
));
return
$table
->
loadAllFromArray
(
$data
);
}
protected
function
willFilterPage
(
array
$keys
)
{
$object_phids
=
mpull
(
$keys
,
'getObjectPHID'
);
$objects
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$this
->
getViewer
())
->
setParentQuery
(
$this
)
->
withPHIDs
(
$object_phids
)
->
execute
();
$objects
=
mpull
(
$objects
,
null
,
'getPHID'
);
foreach
(
$keys
as
$key
=>
$ssh_key
)
{
$object
=
idx
(
$objects
,
$ssh_key
->
getObjectPHID
());
if
(!
$object
)
{
unset
(
$keys
[
$key
]);
continue
;
}
$ssh_key
->
attachObject
(
$object
);
}
return
$keys
;
}
protected
function
buildWhereClause
(
AphrontDatabaseConnection
$conn_r
)
{
$where
=
array
();
if
(
$this
->
ids
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'id IN (%Ld)'
,
$this
->
ids
);
}
if
(
$this
->
objectPHIDs
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'userPHID IN (%Ls)'
,
$this
->
objectPHIDs
);
}
if
(
$this
->
keys
!==
null
)
{
// TODO: This could take advantage of a better key, and the hashing
// scheme for this table is a bit nonstandard and questionable.
$sql
=
array
();
foreach
(
$this
->
keys
as
$key
)
{
$sql
[]
=
qsprintf
(
$conn_r
,
'(keyType = %s AND keyBody = %s)'
,
$key
->
getType
(),
$key
->
getBody
());
}
$where
[]
=
implode
(
' OR '
,
$sql
);
}
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
return
$this
->
formatWhereClause
(
$where
);
}
public
function
getQueryApplicationClass
()
{
return
'PhabricatorAuthApplication'
;
}
}
Event Timeline
Log In to Comment