1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 07:42:40 +01:00
phorge-phorge/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php
Chad Little 77ababadcb Update Legalpad for handleRequest
Summary: Updates Legalpad for handleRequest instead of processRequest

Test Plan: New Document, Sign Document, Add exemption, view signatures.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13756
2015-07-29 17:02:10 -07:00

80 lines
2 KiB
PHP

<?php
final class LegalpadDocumentSignatureListController extends LegalpadController {
private $document;
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$querykey = $request->getURIData('queryKey');
if ($id) {
$document = id(new LegalpadDocumentQuery())
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$document) {
return new Aphront404Response();
}
$this->document = $document;
}
$engine = id(new LegalpadDocumentSignatureSearchEngine());
if ($this->document) {
$engine->setDocument($this->document);
}
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($querykey)
->setSearchEngine($engine)
->setNavigation($this->buildSideNav());
return $this->delegateToController($controller);
}
public function buildSideNav($for_app = false) {
$viewer = $this->getViewer();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$engine = id(new LegalpadDocumentSignatureSearchEngine())
->setViewer($viewer);
if ($this->document) {
$engine->setDocument($this->document);
}
$engine->addNavigationItems($nav->getMenu());
return $nav;
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
if ($this->document) {
$crumbs->addTextCrumb(
$this->document->getMonogram(),
'/'.$this->document->getMonogram());
$crumbs->addTextCrumb(
pht('Manage'),
$this->getApplicationURI('view/'.$this->document->getID().'/'));
} else {
$crumbs->addTextCrumb(
pht('Signatures'),
'/legalpad/signatures/');
}
return $crumbs;
}
}