1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 19:32:40 +01:00
phorge-phorge/src/applications/nuance/query/NuanceItemQuery.php
epriestley c69d465891 Add basic "View" and "Edit" features to Nuance
Summary:
Ref T8783.

The "View" UI is where a user would check their request for feedback or a resolution, if it's something that makes sense for them to interact with from the web UI.

The "Edit" UI is the manage/admin UI where you'd respond to a request. It's similar to the view UI but will have actions and eventually some queue UI, etc.

(I don't think items need a normal "Edit" UI -- it doesn't make sense to "Edit" a tweet or inbound email -- but maybe this will shuffle around a little eventually.)

Test Plan:
View

{F747218}

Edit

{F747219}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8783

Differential Revision: https://secure.phabricator.com/D13980
2015-08-23 08:34:52 -07:00

85 lines
1.9 KiB
PHP

<?php
final class NuanceItemQuery
extends NuanceQuery {
private $ids;
private $phids;
private $sourcePHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function withPHIDs(array $phids) {
$this->phids = $phids;
return $this;
}
public function withSourcePHIDs(array $source_phids) {
$this->sourcePHIDs = $source_phids;
return $this;
}
public function newResultObject() {
return new NuanceItem();
}
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $items) {
$source_phids = mpull($items, 'getSourcePHID');
// NOTE: We always load sources, even if the viewer can't formally see
// them. If they can see the item, they're allowed to be aware of the
// source in some sense.
$sources = id(new NuanceSourceQuery())
->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 $items;
}
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->sourcePHIDs !== null) {
$where[] = qsprintf(
$conn,
'sourcePHID IN (%Ls)',
$this->sourcePHIDs);
}
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
$conn,
'phid IN (%Ls)',
$this->phids);
}
return $where;
}
}