mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 04:32:43 +01:00
70e7708aff
Summary: got some basics here -- - can create document - creates document object and document body object and cross-reference - can update document - creates document body object and updates reference from document object - contributors stored correctly - a contributor is anyone who has created or updated a legal document - can subscribe to documents - can flag documents - can comment on documents - can query for documents based on creator and create range - uses basically modern stuff Missing stuff -- - T3488 - T3483 - T3482 - T3481 - T3480 - T3479 Test Plan: TRUNCATED the database. From scratch made 3 legal docs. Verified versions and version were correct in document and document body database entries respectively. Left comments and verified versions and version did not update. Left updates and verified those updated versions and version. Flagged document and verified it showed up on homepage. Subscribed and verified transaction showed up. Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin Maniphest Tasks: T3116 Differential Revision: https://secure.phabricator.com/D6351
81 lines
2.1 KiB
PHP
81 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group legalpad
|
|
*/
|
|
final class LegalpadDocumentCommentController extends LegalpadController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
if (!$request->isFormPost()) {
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$document = id(new LegalpadDocumentQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($this->id))
|
|
->executeOne();
|
|
|
|
if (!$document) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$is_preview = $request->isPreviewRequest();
|
|
|
|
$draft = PhabricatorDraft::buildFromRequest($request);
|
|
|
|
$document_uri = $this->getApplicationURI('view/'.$document->getID());
|
|
|
|
$comment = $request->getStr('comment');
|
|
|
|
$xactions = array();
|
|
|
|
if (strlen($comment)) {
|
|
$xactions[] = id(new LegalpadTransaction())
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
->attachComment(
|
|
id(new LegalpadTransactionComment())
|
|
->setDocumentID($document->getID())
|
|
->setLineNumber(0)
|
|
->setLineLength(0)
|
|
->setContent($comment));
|
|
}
|
|
|
|
$editor = id(new LegalpadDocumentEditor())
|
|
->setActor($user)
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect($request->isContinueRequest())
|
|
->setIsPreview($is_preview);
|
|
|
|
try {
|
|
$xactions = $editor->applyTransactions($document, $xactions);
|
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
|
->setCancelURI($document_uri)
|
|
->setException($ex);
|
|
}
|
|
|
|
if ($draft) {
|
|
$draft->replaceOrDelete();
|
|
}
|
|
|
|
if ($request->isAjax()) {
|
|
return id(new PhabricatorApplicationTransactionResponse())
|
|
->setViewer($user)
|
|
->setTransactions($xactions)
|
|
->setIsPreview($is_preview)
|
|
->setAnchorOffset($request->getStr('anchor'));
|
|
} else {
|
|
return id(new AphrontRedirectResponse())->setURI($document_uri);
|
|
}
|
|
}
|
|
|
|
}
|