Path: blob/master/src/applications/auth/query/PhabricatorAuthSessionQuery.php
12262 views
<?php12final class PhabricatorAuthSessionQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $identityPHIDs;8private $sessionKeys;9private $sessionTypes;1011public function withIdentityPHIDs(array $identity_phids) {12$this->identityPHIDs = $identity_phids;13return $this;14}1516public function withSessionKeys(array $keys) {17$this->sessionKeys = $keys;18return $this;19}2021public function withSessionTypes(array $types) {22$this->sessionTypes = $types;23return $this;24}2526public function withIDs(array $ids) {27$this->ids = $ids;28return $this;29}3031public function withPHIDs(array $phids) {32$this->phids = $phids;33return $this;34}3536public function newResultObject() {37return new PhabricatorAuthSession();38}3940protected function willFilterPage(array $sessions) {41$identity_phids = mpull($sessions, 'getUserPHID');4243$identity_objects = id(new PhabricatorObjectQuery())44->setViewer($this->getViewer())45->setParentQuery($this)46->withPHIDs($identity_phids)47->execute();48$identity_objects = mpull($identity_objects, null, 'getPHID');4950foreach ($sessions as $key => $session) {51$identity_object = idx($identity_objects, $session->getUserPHID());52if (!$identity_object) {53unset($sessions[$key]);54} else {55$session->attachIdentityObject($identity_object);56}57}5859return $sessions;60}6162protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {63$where = parent::buildWhereClauseParts($conn);6465if ($this->ids !== null) {66$where[] = qsprintf(67$conn,68'id IN (%Ld)',69$this->ids);70}7172if ($this->phids !== null) {73$where[] = qsprintf(74$conn,75'phid IN (%Ls)',76$this->phids);77}7879if ($this->identityPHIDs !== null) {80$where[] = qsprintf(81$conn,82'userPHID IN (%Ls)',83$this->identityPHIDs);84}8586if ($this->sessionKeys !== null) {87$hashes = array();88foreach ($this->sessionKeys as $session_key) {89$hashes[] = PhabricatorAuthSession::newSessionDigest(90new PhutilOpaqueEnvelope($session_key));91}92$where[] = qsprintf(93$conn,94'sessionKey IN (%Ls)',95$hashes);96}9798if ($this->sessionTypes !== null) {99$where[] = qsprintf(100$conn,101'type IN (%Ls)',102$this->sessionTypes);103}104105return $where;106}107108public function getQueryApplicationClass() {109return 'PhabricatorAuthApplication';110}111112}113114115