Path: blob/master/src/applications/auth/query/PhabricatorAuthInviteQuery.php
12262 views
<?php12final class PhabricatorAuthInviteQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $emailAddresses;8private $verificationCodes;9private $authorPHIDs;1011public function withIDs(array $ids) {12$this->ids = $ids;13return $this;14}1516public function withPHIDs(array $phids) {17$this->phids = $phids;18return $this;19}2021public function withEmailAddresses(array $addresses) {22$this->emailAddresses = $addresses;23return $this;24}2526public function withVerificationCodes(array $codes) {27$this->verificationCodes = $codes;28return $this;29}3031public function withAuthorPHIDs(array $phids) {32$this->authorPHIDs = $phids;33return $this;34}3536protected function loadPage() {37$table = new PhabricatorAuthInvite();38$conn_r = $table->establishConnection('r');3940$data = queryfx_all(41$conn_r,42'SELECT * FROM %T %Q %Q %Q',43$table->getTableName(),44$this->buildWhereClause($conn_r),45$this->buildOrderClause($conn_r),46$this->buildLimitClause($conn_r));4748$invites = $table->loadAllFromArray($data);4950// If the objects were loaded via verification code, set a flag to make51// sure the viewer can see them.52if ($this->verificationCodes !== null) {53foreach ($invites as $invite) {54$invite->setViewerHasVerificationCode(true);55}56}5758return $invites;59}6061protected function buildWhereClause(AphrontDatabaseConnection $conn) {62$where = array();6364if ($this->ids !== null) {65$where[] = qsprintf(66$conn,67'id IN (%Ld)',68$this->ids);69}7071if ($this->phids !== null) {72$where[] = qsprintf(73$conn,74'phid IN (%Ls)',75$this->phids);76}7778if ($this->emailAddresses !== null) {79$where[] = qsprintf(80$conn,81'emailAddress IN (%Ls)',82$this->emailAddresses);83}8485if ($this->verificationCodes !== null) {86$hashes = array();87foreach ($this->verificationCodes as $code) {88$hashes[] = PhabricatorHash::digestForIndex($code);89}9091$where[] = qsprintf(92$conn,93'verificationHash IN (%Ls)',94$hashes);95}9697if ($this->authorPHIDs !== null) {98$where[] = qsprintf(99$conn,100'authorPHID IN (%Ls)',101$this->authorPHIDs);102}103104$where[] = $this->buildPagingClause($conn);105106return $this->formatWhereClause($conn, $where);107}108109public function getQueryApplicationClass() {110// NOTE: This query is issued by logged-out users, who often will not be111// able to see applications. They still need to be able to see invites.112return null;113}114115}116117118