Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/query/NuanceItemQuery.php
| Show All 11 Lines | public function withIDs(array $ids) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
| $this->phids = $phids; | $this->phids = $phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withSourcePHIDs($source_phids) { | public function withSourcePHIDs(array $source_phids) { | ||||
| $this->sourcePHIDs = $source_phids; | $this->sourcePHIDs = $source_phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function newResultObject() { | |||||
| return new NuanceItem(); | |||||
| } | |||||
| protected function loadPage() { | protected function loadPage() { | ||||
| $table = new NuanceItem(); | return $this->loadStandardPage($this->newResultObject()); | ||||
| $conn = $table->establishConnection('r'); | } | ||||
| $data = queryfx_all( | protected function willFilterPage(array $items) { | ||||
| $conn, | $source_phids = mpull($items, 'getSourcePHID'); | ||||
| '%Q FROM %T %Q %Q %Q', | |||||
| $this->buildSelectClause($conn), | // NOTE: We always load sources, even if the viewer can't formally see | ||||
| $table->getTableName(), | // them. If they can see the item, they're allowed to be aware of the | ||||
| $this->buildWhereClause($conn), | // source in some sense. | ||||
| $this->buildOrderClause($conn), | $sources = id(new NuanceSourceQuery()) | ||||
| $this->buildLimitClause($conn)); | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
| ->withPHIDs($source_phids) | |||||
| ->execute(); | |||||
| $sources = mpull($sources, null, 'getPHID'); | |||||
| foreach ($items as $key => $item) { | |||||
| $source = idx($sources, $item->getSourcePHID()); | |||||
| if (!$source) { | |||||
| $this->didRejectResult($items[$key]); | |||||
| unset($items[$key]); | |||||
| continue; | |||||
| } | |||||
| $item->attachSource($source); | |||||
| } | |||||
| return $table->loadAllFromArray($data); | return $items; | ||||
| } | } | ||||
| protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| $where = parent::buildWhereClauseParts($conn); | $where = parent::buildWhereClauseParts($conn); | ||||
| if ($this->sourcePHIDs !== null) { | if ($this->sourcePHIDs !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| Show All 22 Lines | |||||