mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 13:39:08 +01:00
Summary: Ref T7689. Modernize all callsites of these methods. Test Plan: - Poked at dashboards. - Pretty sure this code is technically unreachable right now. - Viewed commit; viewed "Audit Status". - Viewed a fund; viewed "Payable to"; viewed "Owner". - Viewed herald rules; viewed "Author"; viewed "Applies To". - Viewed a Legalpad document; viewed "Contributors". - Viewed Phame post list; viewed blog; viewed post (viewed "Blog", viewed "Blogger"). - Viewed a macro; viewed "Audio". - Viewed a Phriction page; viewed "Last Author". - Viewed a Ponder question; viewed "Author". - Viewed a Ponder answer; viewed header. - Behavior changed very slightly here; whatevs. - Viewed a Countdown; viewed "Author". Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7689 Differential Revision: https://secure.phabricator.com/D12210
116 lines
2.7 KiB
PHP
116 lines
2.7 KiB
PHP
<?php
|
|
|
|
final class PhabricatorCountdownViewController
|
|
extends PhabricatorCountdownController {
|
|
|
|
private $id;
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$countdown = id(new PhabricatorCountdownQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($this->id))
|
|
->executeOne();
|
|
if (!$countdown) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$countdown_view = id(new PhabricatorCountdownView())
|
|
->setUser($user)
|
|
->setCountdown($countdown)
|
|
->setHeadless(true);
|
|
|
|
$id = $countdown->getID();
|
|
$title = $countdown->getTitle();
|
|
|
|
$crumbs = $this
|
|
->buildApplicationCrumbs()
|
|
->addTextCrumb("C{$id}");
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setHeader($title)
|
|
->setUser($user)
|
|
->setPolicyObject($countdown);
|
|
|
|
$actions = $this->buildActionListView($countdown);
|
|
$properties = $this->buildPropertyListView($countdown, $actions);
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
->setHeader($header)
|
|
->addPropertyList($properties);
|
|
|
|
$content = array(
|
|
$crumbs,
|
|
$object_box,
|
|
$countdown_view,
|
|
);
|
|
|
|
return $this->buildApplicationPage(
|
|
$content,
|
|
array(
|
|
'title' => $title,
|
|
));
|
|
}
|
|
|
|
private function buildActionListView(PhabricatorCountdown $countdown) {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$id = $countdown->getID();
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
->setUser($viewer);
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
$viewer,
|
|
$countdown,
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setIcon('fa-pencil')
|
|
->setName(pht('Edit Countdown'))
|
|
->setHref($this->getApplicationURI("edit/{$id}/"))
|
|
->setDisabled(!$can_edit)
|
|
->setWorkflow(!$can_edit));
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setIcon('fa-times')
|
|
->setName(pht('Delete Countdown'))
|
|
->setHref($this->getApplicationURI("delete/{$id}/"))
|
|
->setDisabled(!$can_edit)
|
|
->setWorkflow(true));
|
|
|
|
return $view;
|
|
}
|
|
|
|
private function buildPropertyListView(
|
|
PhabricatorCountdown $countdown,
|
|
PhabricatorActionListView $actions) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
->setUser($viewer)
|
|
->setActionList($actions);
|
|
|
|
$view->addProperty(
|
|
pht('Author'),
|
|
$viewer->renderHandle($countdown->getAuthorPHID()));
|
|
|
|
return $view;
|
|
}
|
|
|
|
}
|