2013-07-03 20:15:45 +02:00
|
|
|
<?php
|
|
|
|
|
2014-06-26 03:38:07 +02:00
|
|
|
final class LegalpadDocumentManageController extends LegalpadController {
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2015-07-30 02:02:10 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2014-06-26 03:38:07 +02:00
|
|
|
// NOTE: We require CAN_EDIT to view this page.
|
|
|
|
|
2013-07-03 20:15:45 +02:00
|
|
|
$document = id(new LegalpadDocumentQuery())
|
2015-07-30 02:02:10 +02:00
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($id))
|
2013-07-03 20:15:45 +02:00
|
|
|
->needDocumentBodies(true)
|
|
|
|
->needContributors(true)
|
2014-06-26 03:38:07 +02:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
2013-07-03 20:15:45 +02:00
|
|
|
->executeOne();
|
|
|
|
if (!$document) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
|
|
|
$document->getPHID());
|
|
|
|
|
|
|
|
$document_body = $document->getDocumentBody();
|
|
|
|
|
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
2015-07-30 02:02:10 +02:00
|
|
|
->setViewer($viewer);
|
2013-07-03 20:15:45 +02:00
|
|
|
$engine->addObject(
|
|
|
|
$document_body,
|
|
|
|
LegalpadDocumentBody::MARKUP_FIELD_TEXT);
|
Transactions - deploy buildTransactionTimeline to remaining applications
Summary:
Ref T4712. Specifically...
- Differential
- needed getApplicationTransactionViewObject() implemented
- Audit
- needed getApplicationTransactionViewObject() implemented
- Repository
- one object needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true)
- Ponder
- BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI
- both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true) on both "history" controllers
- left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually
- Phortune
- BONUS BUG FIX - fix new user "createNewAccount" code to not fatal
- PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true) on Account view, merchant view, and cart view controller
- Fund
- Legalpad
- Nuance
- NuanceSource needed PhabricatorApplicationTransactionInterface implemented
- Releeph (this product is kind of a mess...)
- HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...!
- BONUS BUG FIX - make sure to "setName" on product edit
- ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented
- Harbormaster
- HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true) all over the place
Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T4712
Differential Revision: https://secure.phabricator.com/D10925
2014-12-04 00:35:47 +01:00
|
|
|
$timeline = $this->buildTransactionTimeline(
|
|
|
|
$document,
|
|
|
|
new LegalpadTransactionQuery(),
|
|
|
|
$engine);
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
$title = $document_body->getTitle();
|
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-09-18 23:50:39 +02:00
|
|
|
->setHeader($title)
|
2015-07-30 02:02:10 +02:00
|
|
|
->setUser($viewer)
|
2016-04-03 02:25:03 +02:00
|
|
|
->setPolicyObject($document)
|
|
|
|
->setHeaderIcon('fa-gavel');
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$curtain = $this->buildCurtainView($document);
|
|
|
|
$properties = $this->buildPropertyView($document, $engine);
|
|
|
|
$document_view = $this->buildDocumentView($document, $engine);
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
$comment_form_id = celerity_generate_unique_node_id();
|
|
|
|
|
|
|
|
$add_comment = $this->buildAddCommentView($document, $comment_form_id);
|
|
|
|
|
2017-02-17 11:10:15 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs->addTextCrumb(
|
2014-01-16 23:36:57 +01:00
|
|
|
$document->getMonogram(),
|
2014-06-26 03:38:07 +02:00
|
|
|
'/'.$document->getMonogram());
|
|
|
|
$crumbs->addTextCrumb(pht('Manage'));
|
2016-04-03 02:25:03 +02:00
|
|
|
$crumbs->setBorder(true);
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
|
|
|
|
$view = id(new PHUITwoColumnView())
|
2013-09-29 00:55:38 +02:00
|
|
|
->setHeader($header)
|
2016-04-03 02:25:03 +02:00
|
|
|
->setCurtain($curtain)
|
|
|
|
->setMainColumn(array(
|
|
|
|
$properties,
|
|
|
|
$document_view,
|
|
|
|
$timeline,
|
|
|
|
$add_comment,
|
2013-07-03 20:15:45 +02:00
|
|
|
));
|
2016-04-03 02:25:03 +02:00
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->setPageObjectPHIDs(array($document->getPHID()))
|
|
|
|
->appendChild($view);
|
2013-07-03 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
private function buildDocumentView(
|
|
|
|
LegalpadDocument $document,
|
|
|
|
PhabricatorMarkupEngine $engine) {
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$viewer = $this->getViewer();
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
$document_body = $document->getDocumentBody();
|
|
|
|
$document_text = $engine->getOutput(
|
|
|
|
$document_body, LegalpadDocumentBody::MARKUP_FIELD_TEXT);
|
|
|
|
|
|
|
|
$preamble_box = null;
|
|
|
|
if (strlen($document->getPreamble())) {
|
|
|
|
$preamble_text = new PHUIRemarkupView($viewer, $document->getPreamble());
|
|
|
|
$view->addTextContent($preamble_text);
|
|
|
|
$view->addSectionHeader('');
|
|
|
|
$view->addTextContent($document_text);
|
|
|
|
} else {
|
|
|
|
$view->addTextContent($document_text);
|
|
|
|
}
|
2013-10-30 20:45:13 +01:00
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('DOCUMENT'))
|
|
|
|
->addPropertyList($view)
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
2013-07-03 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
private function buildCurtainView(LegalpadDocument $document) {
|
2015-07-30 02:02:10 +02:00
|
|
|
$viewer = $this->getViewer();
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$curtain = $this->newCurtainView($document);
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
2015-07-30 02:02:10 +02:00
|
|
|
$viewer,
|
2013-07-03 20:15:45 +02:00
|
|
|
$document,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
2014-01-17 20:40:26 +01:00
|
|
|
$doc_id = $document->getID();
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$curtain->addAction(
|
2014-06-26 03:38:07 +02:00
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setIcon('fa-pencil-square')
|
|
|
|
->setName(pht('View/Sign Document'))
|
|
|
|
->setHref('/'.$document->getMonogram()));
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$curtain->addAction(
|
2013-07-03 20:15:45 +02:00
|
|
|
id(new PhabricatorActionView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-pencil')
|
2013-07-03 20:15:45 +02:00
|
|
|
->setName(pht('Edit Document'))
|
2014-01-17 20:40:26 +01:00
|
|
|
->setHref($this->getApplicationURI('/edit/'.$doc_id.'/'))
|
2013-07-03 20:15:45 +02:00
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit));
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
$curtain->addAction(
|
2014-01-17 20:40:26 +01:00
|
|
|
id(new PhabricatorActionView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-terminal')
|
2014-01-17 20:40:26 +01:00
|
|
|
->setName(pht('View Signatures'))
|
|
|
|
->setHref($this->getApplicationURI('/signatures/'.$doc_id.'/')));
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
return $curtain;
|
2013-07-03 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(
|
|
|
|
LegalpadDocument $document,
|
2016-04-03 02:25:03 +02:00
|
|
|
PhabricatorMarkupEngine $engine) {
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2015-07-30 02:02:10 +02:00
|
|
|
$viewer = $this->getViewer();
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$properties = id(new PHUIPropertyListView())
|
2016-04-03 02:25:03 +02:00
|
|
|
->setUser($viewer);
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2014-07-04 17:04:28 +02:00
|
|
|
$properties->addProperty(
|
|
|
|
pht('Signature Type'),
|
|
|
|
$document->getSignatureTypeName());
|
|
|
|
|
2013-07-03 20:15:45 +02:00
|
|
|
$properties->addProperty(
|
|
|
|
pht('Last Updated'),
|
2015-07-30 02:02:10 +02:00
|
|
|
phabricator_datetime($document->getDateModified(), $viewer));
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Updated By'),
|
2015-07-30 02:02:10 +02:00
|
|
|
$viewer->renderHandle($document->getDocumentBody()->getCreatorPHID()));
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Versions'),
|
|
|
|
$document->getVersions());
|
|
|
|
|
2015-03-30 16:55:33 +02:00
|
|
|
if ($document->getContributors()) {
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Contributors'),
|
2015-07-30 02:02:10 +02:00
|
|
|
$viewer
|
2015-03-30 16:55:33 +02:00
|
|
|
->renderHandleList($document->getContributors())
|
|
|
|
->setAsInline(true));
|
2013-07-03 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
2016-04-03 02:25:03 +02:00
|
|
|
return id(new PHUIObjectBoxView())
|
2016-04-07 00:20:53 +02:00
|
|
|
->setHeaderText(pht('Properties'))
|
2016-04-03 02:25:03 +02:00
|
|
|
->addPropertyList($properties)
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
2013-07-03 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildAddCommentView(
|
|
|
|
LegalpadDocument $document,
|
|
|
|
$comment_form_id) {
|
2015-07-30 02:02:10 +02:00
|
|
|
$viewer = $this->getViewer();
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2015-07-30 02:02:10 +02:00
|
|
|
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $document->getPHID());
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
|
|
|
|
|
|
|
$title = $is_serious
|
|
|
|
? pht('Add Comment')
|
|
|
|
: pht('Debate Legislation');
|
|
|
|
|
|
|
|
$form = id(new PhabricatorApplicationTransactionCommentView())
|
2015-07-30 02:02:10 +02:00
|
|
|
->setUser($viewer)
|
2013-07-29 03:21:22 +02:00
|
|
|
->setObjectPHID($document->getPHID())
|
2013-07-03 20:15:45 +02:00
|
|
|
->setFormID($comment_form_id)
|
2013-11-22 01:09:04 +01:00
|
|
|
->setHeaderText($title)
|
2013-07-03 20:15:45 +02:00
|
|
|
->setDraft($draft)
|
2014-04-19 02:51:46 +02:00
|
|
|
->setSubmitButtonName(pht('Add Comment'))
|
2013-07-03 20:15:45 +02:00
|
|
|
->setAction($this->getApplicationURI('/comment/'.$document->getID().'/'))
|
|
|
|
->setRequestURI($this->getRequest()->getRequestURI());
|
|
|
|
|
2013-11-22 01:09:04 +01:00
|
|
|
return $form;
|
2013-09-29 00:55:38 +02:00
|
|
|
|
2013-07-03 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|