@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update Legalpad to use modular transactions

Summary: Update Legalpad for modular transactions

Test Plan:
- New Document (no sign)
- New Document (individual)
- New Document (corp)
- Require Signature - get prompted to sign before I can do anything.
- Edit Documents
- Sign Documents
- Comment on Documents

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D17826

+307 -196
+13 -1
src/__phutil_library_map__.php
··· 1400 1400 'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php', 1401 1401 'LegalpadDocumentListController' => 'applications/legalpad/controller/LegalpadDocumentListController.php', 1402 1402 'LegalpadDocumentManageController' => 'applications/legalpad/controller/LegalpadDocumentManageController.php', 1403 + 'LegalpadDocumentPreambleTransaction' => 'applications/legalpad/xaction/LegalpadDocumentPreambleTransaction.php', 1403 1404 'LegalpadDocumentQuery' => 'applications/legalpad/query/LegalpadDocumentQuery.php', 1404 1405 'LegalpadDocumentRemarkupRule' => 'applications/legalpad/remarkup/LegalpadDocumentRemarkupRule.php', 1406 + 'LegalpadDocumentRequireSignatureTransaction' => 'applications/legalpad/xaction/LegalpadDocumentRequireSignatureTransaction.php', 1405 1407 'LegalpadDocumentSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSearchEngine.php', 1406 1408 'LegalpadDocumentSignController' => 'applications/legalpad/controller/LegalpadDocumentSignController.php', 1407 1409 'LegalpadDocumentSignature' => 'applications/legalpad/storage/LegalpadDocumentSignature.php', ··· 1409 1411 'LegalpadDocumentSignatureListController' => 'applications/legalpad/controller/LegalpadDocumentSignatureListController.php', 1410 1412 'LegalpadDocumentSignatureQuery' => 'applications/legalpad/query/LegalpadDocumentSignatureQuery.php', 1411 1413 'LegalpadDocumentSignatureSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php', 1414 + 'LegalpadDocumentSignatureTypeTransaction' => 'applications/legalpad/xaction/LegalpadDocumentSignatureTypeTransaction.php', 1412 1415 'LegalpadDocumentSignatureVerificationController' => 'applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php', 1413 1416 'LegalpadDocumentSignatureViewController' => 'applications/legalpad/controller/LegalpadDocumentSignatureViewController.php', 1417 + 'LegalpadDocumentTextTransaction' => 'applications/legalpad/xaction/LegalpadDocumentTextTransaction.php', 1418 + 'LegalpadDocumentTitleTransaction' => 'applications/legalpad/xaction/LegalpadDocumentTitleTransaction.php', 1419 + 'LegalpadDocumentTransactionType' => 'applications/legalpad/xaction/LegalpadDocumentTransactionType.php', 1414 1420 'LegalpadMailReceiver' => 'applications/legalpad/mail/LegalpadMailReceiver.php', 1415 1421 'LegalpadObjectNeedsSignatureEdgeType' => 'applications/legalpad/edge/LegalpadObjectNeedsSignatureEdgeType.php', 1416 1422 'LegalpadReplyHandler' => 'applications/legalpad/mail/LegalpadReplyHandler.php', ··· 6395 6401 'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor', 6396 6402 'LegalpadDocumentListController' => 'LegalpadController', 6397 6403 'LegalpadDocumentManageController' => 'LegalpadController', 6404 + 'LegalpadDocumentPreambleTransaction' => 'LegalpadDocumentTransactionType', 6398 6405 'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6399 6406 'LegalpadDocumentRemarkupRule' => 'PhabricatorObjectRemarkupRule', 6407 + 'LegalpadDocumentRequireSignatureTransaction' => 'LegalpadDocumentTransactionType', 6400 6408 'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', 6401 6409 'LegalpadDocumentSignController' => 'LegalpadController', 6402 6410 'LegalpadDocumentSignature' => array( ··· 6407 6415 'LegalpadDocumentSignatureListController' => 'LegalpadController', 6408 6416 'LegalpadDocumentSignatureQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6409 6417 'LegalpadDocumentSignatureSearchEngine' => 'PhabricatorApplicationSearchEngine', 6418 + 'LegalpadDocumentSignatureTypeTransaction' => 'LegalpadDocumentTransactionType', 6410 6419 'LegalpadDocumentSignatureVerificationController' => 'LegalpadController', 6411 6420 'LegalpadDocumentSignatureViewController' => 'LegalpadController', 6421 + 'LegalpadDocumentTextTransaction' => 'LegalpadDocumentTransactionType', 6422 + 'LegalpadDocumentTitleTransaction' => 'LegalpadDocumentTransactionType', 6423 + 'LegalpadDocumentTransactionType' => 'PhabricatorModularTransactionType', 6412 6424 'LegalpadMailReceiver' => 'PhabricatorObjectMailReceiver', 6413 6425 'LegalpadObjectNeedsSignatureEdgeType' => 'PhabricatorEdgeType', 6414 6426 'LegalpadReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 6415 6427 'LegalpadRequireSignatureHeraldAction' => 'HeraldAction', 6416 6428 'LegalpadSchemaSpec' => 'PhabricatorConfigSchemaSpec', 6417 6429 'LegalpadSignatureNeededByObjectEdgeType' => 'PhabricatorEdgeType', 6418 - 'LegalpadTransaction' => 'PhabricatorApplicationTransaction', 6430 + 'LegalpadTransaction' => 'PhabricatorModularTransaction', 6419 6431 'LegalpadTransactionComment' => 'PhabricatorApplicationTransactionComment', 6420 6432 'LegalpadTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6421 6433 'LegalpadTransactionView' => 'PhabricatorApplicationTransactionView',
+10 -5
src/applications/legalpad/controller/LegalpadDocumentEditController.php
··· 57 57 $errors[] = pht('The document title may not be blank.'); 58 58 } else { 59 59 $xactions[] = id(new LegalpadTransaction()) 60 - ->setTransactionType(LegalpadTransaction::TYPE_TITLE) 60 + ->setTransactionType( 61 + LegalpadDocumentTitleTransaction::TRANSACTIONTYPE) 61 62 ->setNewValue($title); 62 63 } 63 64 ··· 67 68 $errors[] = pht('The document may not be blank.'); 68 69 } else { 69 70 $xactions[] = id(new LegalpadTransaction()) 70 - ->setTransactionType(LegalpadTransaction::TYPE_TEXT) 71 + ->setTransactionType( 72 + LegalpadDocumentTextTransaction::TRANSACTIONTYPE) 71 73 ->setNewValue($text); 72 74 } 73 75 ··· 83 85 if ($is_create) { 84 86 $v_signature_type = $request->getStr('signatureType'); 85 87 $xactions[] = id(new LegalpadTransaction()) 86 - ->setTransactionType(LegalpadTransaction::TYPE_SIGNATURE_TYPE) 88 + ->setTransactionType( 89 + LegalpadDocumentSignatureTypeTransaction::TRANSACTIONTYPE) 87 90 ->setNewValue($v_signature_type); 88 91 } 89 92 90 93 $v_preamble = $request->getStr('preamble'); 91 94 $xactions[] = id(new LegalpadTransaction()) 92 - ->setTransactionType(LegalpadTransaction::TYPE_PREAMBLE) 95 + ->setTransactionType( 96 + LegalpadDocumentPreambleTransaction::TRANSACTIONTYPE) 93 97 ->setNewValue($v_preamble); 94 98 95 99 $v_require_signature = $request->getBool('requireSignature', 0); ··· 106 110 } 107 111 if ($viewer->getIsAdmin()) { 108 112 $xactions[] = id(new LegalpadTransaction()) 109 - ->setTransactionType(LegalpadTransaction::TYPE_REQUIRE_SIGNATURE) 113 + ->setTransactionType( 114 + LegalpadDocumentRequireSignatureTransaction::TRANSACTIONTYPE) 110 115 ->setNewValue($v_require_signature); 111 116 } 112 117
+15 -116
src/applications/legalpad/editor/LegalpadDocumentEditor.php
··· 3 3 final class LegalpadDocumentEditor 4 4 extends PhabricatorApplicationTransactionEditor { 5 5 6 - private $isContribution = false; 7 - 8 6 public function getEditorApplicationClass() { 9 7 return 'PhabricatorLegalpadApplication'; 10 8 } ··· 13 11 return pht('Legalpad Documents'); 14 12 } 15 13 16 - private function setIsContribution($is_contribution) { 17 - $this->isContribution = $is_contribution; 18 - return $this; 19 - } 20 - 21 - private function isContribution() { 22 - return $this->isContribution; 23 - } 24 - 25 14 public function getTransactionTypes() { 26 15 $types = parent::getTransactionTypes(); 27 16 28 17 $types[] = PhabricatorTransactions::TYPE_COMMENT; 29 18 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 30 19 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 31 - 32 - $types[] = LegalpadTransaction::TYPE_TITLE; 33 - $types[] = LegalpadTransaction::TYPE_TEXT; 34 - $types[] = LegalpadTransaction::TYPE_SIGNATURE_TYPE; 35 - $types[] = LegalpadTransaction::TYPE_PREAMBLE; 36 - $types[] = LegalpadTransaction::TYPE_REQUIRE_SIGNATURE; 37 20 38 21 return $types; 39 22 } 40 23 41 - protected function getCustomTransactionOldValue( 24 + protected function applyFinalEffects( 42 25 PhabricatorLiskDAO $object, 43 - PhabricatorApplicationTransaction $xaction) { 44 - 45 - switch ($xaction->getTransactionType()) { 46 - case LegalpadTransaction::TYPE_TITLE: 47 - return $object->getDocumentBody()->getTitle(); 48 - case LegalpadTransaction::TYPE_TEXT: 49 - return $object->getDocumentBody()->getText(); 50 - case LegalpadTransaction::TYPE_SIGNATURE_TYPE: 51 - return $object->getSignatureType(); 52 - case LegalpadTransaction::TYPE_PREAMBLE: 53 - return $object->getPreamble(); 54 - case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: 55 - return (bool)$object->getRequireSignature(); 56 - } 57 - } 26 + array $xactions) { 58 27 59 - protected function getCustomTransactionNewValue( 60 - PhabricatorLiskDAO $object, 61 - PhabricatorApplicationTransaction $xaction) { 28 + $is_contribution = false; 62 29 63 - switch ($xaction->getTransactionType()) { 64 - case LegalpadTransaction::TYPE_TITLE: 65 - case LegalpadTransaction::TYPE_TEXT: 66 - case LegalpadTransaction::TYPE_SIGNATURE_TYPE: 67 - case LegalpadTransaction::TYPE_PREAMBLE: 68 - return $xaction->getNewValue(); 69 - case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: 70 - return (bool)$xaction->getNewValue(); 30 + foreach ($xactions as $xaction) { 31 + switch ($xaction->getTransactionType()) { 32 + case LegalpadDocumentTitleTransaction::TRANSACTIONTYPE: 33 + case LegalpadDocumentTextTransaction::TRANSACTIONTYPE: 34 + $is_contribution = true; 35 + break; 36 + } 71 37 } 72 - } 73 38 74 - protected function applyCustomInternalTransaction( 75 - PhabricatorLiskDAO $object, 76 - PhabricatorApplicationTransaction $xaction) { 77 - 78 - switch ($xaction->getTransactionType()) { 79 - case LegalpadTransaction::TYPE_TITLE: 80 - $object->setTitle($xaction->getNewValue()); 81 - $body = $object->getDocumentBody(); 82 - $body->setTitle($xaction->getNewValue()); 83 - $this->setIsContribution(true); 84 - break; 85 - case LegalpadTransaction::TYPE_TEXT: 86 - $body = $object->getDocumentBody(); 87 - $body->setText($xaction->getNewValue()); 88 - $this->setIsContribution(true); 89 - break; 90 - case LegalpadTransaction::TYPE_SIGNATURE_TYPE: 91 - $object->setSignatureType($xaction->getNewValue()); 92 - break; 93 - case LegalpadTransaction::TYPE_PREAMBLE: 94 - $object->setPreamble($xaction->getNewValue()); 95 - break; 96 - case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: 97 - $object->setRequireSignature((int)$xaction->getNewValue()); 98 - break; 99 - } 100 - } 101 - 102 - protected function applyCustomExternalTransaction( 103 - PhabricatorLiskDAO $object, 104 - PhabricatorApplicationTransaction $xaction) { 105 - 106 - switch ($xaction->getTransactionType()) { 107 - case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: 108 - if ($xaction->getNewValue()) { 109 - $session = new PhabricatorAuthSession(); 110 - queryfx( 111 - $session->establishConnection('w'), 112 - 'UPDATE %T SET signedLegalpadDocuments = 0', 113 - $session->getTableName()); 114 - } 115 - break; 116 - } 117 - return; 118 - } 119 - 120 - protected function applyFinalEffects( 121 - PhabricatorLiskDAO $object, 122 - array $xactions) { 123 - 124 - if ($this->isContribution()) { 39 + if ($is_contribution) { 125 40 $object->setVersions($object->getVersions() + 1); 126 41 $body = $object->getDocumentBody(); 127 42 $body->setVersion($object->getVersions()); ··· 149 64 return $xactions; 150 65 } 151 66 152 - protected function mergeTransactions( 153 - PhabricatorApplicationTransaction $u, 154 - PhabricatorApplicationTransaction $v) { 155 - 156 - $type = $u->getTransactionType(); 157 - switch ($type) { 158 - case LegalpadTransaction::TYPE_TITLE: 159 - case LegalpadTransaction::TYPE_TEXT: 160 - case LegalpadTransaction::TYPE_SIGNATURE_TYPE: 161 - case LegalpadTransaction::TYPE_PREAMBLE: 162 - case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: 163 - return $v; 164 - } 165 - 166 - return parent::mergeTransactions($u, $v); 167 - } 168 67 169 68 /* -( Sending Mail )------------------------------------------------------- */ 170 69 ··· 201 100 PhabricatorApplicationTransaction $xaction) { 202 101 203 102 switch ($xaction->getTransactionType()) { 204 - case LegalpadTransaction::TYPE_TEXT: 205 - case LegalpadTransaction::TYPE_TITLE: 206 - case LegalpadTransaction::TYPE_PREAMBLE: 207 - case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: 103 + case LegalpadDocumentTextTransaction::TRANSACTIONTYPE: 104 + case LegalpadDocumentTitleTransaction::TRANSACTIONTYPE: 105 + case LegalpadDocumentPreambleTransaction::TRANSACTIONTYPE: 106 + case LegalpadDocumentRequireSignatureTransaction::TRANSACTIONTYPE: 208 107 return true; 209 108 } 210 109
+3 -74
src/applications/legalpad/storage/LegalpadTransaction.php
··· 1 1 <?php 2 2 3 - final class LegalpadTransaction extends PhabricatorApplicationTransaction { 4 - 5 - const TYPE_TITLE = 'title'; 6 - const TYPE_TEXT = 'text'; 7 - const TYPE_SIGNATURE_TYPE = 'legalpad:signature-type'; 8 - const TYPE_PREAMBLE = 'legalpad:premable'; 9 - const TYPE_REQUIRE_SIGNATURE = 'legalpad:require-signature'; 3 + final class LegalpadTransaction extends PhabricatorModularTransaction { 10 4 11 5 public function getApplicationName() { 12 6 return 'legalpad'; ··· 24 18 return new LegalpadTransactionView(); 25 19 } 26 20 27 - public function shouldHide() { 28 - $old = $this->getOldValue(); 29 - 30 - switch ($this->getTransactionType()) { 31 - case self::TYPE_TITLE: 32 - case self::TYPE_TEXT: 33 - return ($old === null); 34 - case self::TYPE_SIGNATURE_TYPE: 35 - return true; 36 - } 37 - 38 - return parent::shouldHide(); 39 - } 40 - 41 - public function getTitle() { 42 - $author_phid = $this->getAuthorPHID(); 43 - 44 - $old = $this->getOldValue(); 45 - $new = $this->getNewValue(); 46 - 47 - $type = $this->getTransactionType(); 48 - switch ($type) { 49 - case self::TYPE_TITLE: 50 - return pht( 51 - '%s renamed this document from "%s" to "%s".', 52 - $this->renderHandleLink($author_phid), 53 - $old, 54 - $new); 55 - case self::TYPE_TEXT: 56 - return pht( 57 - "%s updated the document's text.", 58 - $this->renderHandleLink($author_phid)); 59 - case self::TYPE_PREAMBLE: 60 - return pht( 61 - '%s updated the preamble.', 62 - $this->renderHandleLink($author_phid)); 63 - case self::TYPE_REQUIRE_SIGNATURE: 64 - if ($new) { 65 - $text = pht( 66 - '%s set the document to require signatures.', 67 - $this->renderHandleLink($author_phid)); 68 - } else { 69 - $text = pht( 70 - '%s set the document to not require signatures.', 71 - $this->renderHandleLink($author_phid)); 72 - } 73 - return $text; 74 - } 75 - 76 - return parent::getTitle(); 77 - } 78 - 79 - public function hasChangeDetails() { 80 - switch ($this->getTransactionType()) { 81 - case self::TYPE_TITLE: 82 - case self::TYPE_TEXT: 83 - case self::TYPE_PREAMBLE: 84 - return true; 85 - } 86 - return parent::hasChangeDetails(); 87 - } 88 - 89 - public function renderChangeDetails(PhabricatorUser $viewer) { 90 - return $this->renderTextCorpusChangeDetails( 91 - $viewer, 92 - $this->getOldValue(), 93 - $this->getNewValue()); 21 + public function getBaseTransactionClass() { 22 + return 'LegalpadDocumentTransactionType'; 94 23 } 95 24 96 25 }
+57
src/applications/legalpad/xaction/LegalpadDocumentPreambleTransaction.php
··· 1 + <?php 2 + 3 + final class LegalpadDocumentPreambleTransaction 4 + extends LegalpadDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'legalpad:premable'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getPreamble(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setPreamble($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s updated the document preamble.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s updated the document preamble for %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + public function hasChangeDetailView() { 30 + return true; 31 + } 32 + 33 + public function getMailDiffSectionHeader() { 34 + return pht('CHANGES TO DOCUMENT PREAMBLE'); 35 + } 36 + 37 + public function newChangeDetailView() { 38 + $viewer = $this->getViewer(); 39 + 40 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 41 + ->setViewer($viewer) 42 + ->setOldText($this->getOldValue()) 43 + ->setNewText($this->getNewValue()); 44 + } 45 + 46 + public function newRemarkupChanges() { 47 + $changes = array(); 48 + 49 + $changes[] = $this->newRemarkupChange() 50 + ->setOldValue($this->getOldValue()) 51 + ->setNewValue($this->getNewValue()); 52 + 53 + return $changes; 54 + } 55 + 56 + 57 + }
+58
src/applications/legalpad/xaction/LegalpadDocumentRequireSignatureTransaction.php
··· 1 + <?php 2 + 3 + final class LegalpadDocumentRequireSignatureTransaction 4 + extends LegalpadDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'legalpad:require-signature'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getRequireSignature(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setRequireSignature($value); 14 + } 15 + 16 + public function applyExternalEffects($object, $value) { 17 + if (strlen($value)) { 18 + $session = new PhabricatorAuthSession(); 19 + queryfx( 20 + $session->establishConnection('w'), 21 + 'UPDATE %T SET signedLegalpadDocuments = 0', 22 + $session->getTableName()); 23 + } 24 + } 25 + 26 + public function getTitle() { 27 + $new = $this->getNewValue(); 28 + if ($new) { 29 + return pht( 30 + '%s set the document to require signatures.', 31 + $this->renderAuthor()); 32 + } else { 33 + return pht( 34 + '%s set the document to not require signatures.', 35 + $this->renderAuthor()); 36 + } 37 + } 38 + 39 + public function getTitleForFeed() { 40 + $new = $this->getNewValue(); 41 + if ($new) { 42 + return pht( 43 + '%s set the document %s to require signatures.', 44 + $this->renderAuthor(), 45 + $this->renderObject()); 46 + } else { 47 + return pht( 48 + '%s set the document %s to not require signatures.', 49 + $this->renderAuthor(), 50 + $this->renderObject()); 51 + } 52 + } 53 + 54 + public function getIcon() { 55 + return 'fa-pencil-square'; 56 + } 57 + 58 + }
+29
src/applications/legalpad/xaction/LegalpadDocumentSignatureTypeTransaction.php
··· 1 + <?php 2 + 3 + final class LegalpadDocumentSignatureTypeTransaction 4 + extends LegalpadDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'legalpad:signature-type'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getSignatureType(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setSignatureType($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s set the document signature type.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s set the document signature type for %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + }
+60
src/applications/legalpad/xaction/LegalpadDocumentTextTransaction.php
··· 1 + <?php 2 + 3 + final class LegalpadDocumentTextTransaction 4 + extends LegalpadDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'text'; 7 + 8 + public function generateOldValue($object) { 9 + $body = $object->getDocumentBody(); 10 + return $body->getText(); 11 + } 12 + 13 + public function applyInternalEffects($object, $value) { 14 + $body = $object->getDocumentBody(); 15 + $body->setText($value); 16 + $object->attachDocumentBody($body); 17 + } 18 + 19 + public function getTitle() { 20 + return pht( 21 + '%s updated the document text.', 22 + $this->renderAuthor()); 23 + } 24 + 25 + public function getTitleForFeed() { 26 + return pht( 27 + '%s updated the document text for %s.', 28 + $this->renderAuthor(), 29 + $this->renderObject()); 30 + } 31 + 32 + public function hasChangeDetailView() { 33 + return true; 34 + } 35 + 36 + public function getMailDiffSectionHeader() { 37 + return pht('CHANGES TO DOCUMENT TEXT'); 38 + } 39 + 40 + public function newChangeDetailView() { 41 + $viewer = $this->getViewer(); 42 + 43 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 44 + ->setViewer($viewer) 45 + ->setOldText($this->getOldValue()) 46 + ->setNewText($this->getNewValue()); 47 + } 48 + 49 + public function newRemarkupChanges() { 50 + $changes = array(); 51 + 52 + $changes[] = $this->newRemarkupChange() 53 + ->setOldValue($this->getOldValue()) 54 + ->setNewValue($this->getNewValue()); 55 + 56 + return $changes; 57 + } 58 + 59 + 60 + }
+58
src/applications/legalpad/xaction/LegalpadDocumentTitleTransaction.php
··· 1 + <?php 2 + 3 + final class LegalpadDocumentTitleTransaction 4 + extends LegalpadDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'title'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getTitle(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setTitle($value); 14 + $body = $object->getDocumentBody(); 15 + $body->setTitle($value); 16 + $object->attachDocumentBody($body); 17 + } 18 + 19 + public function getTitle() { 20 + return pht( 21 + '%s renamed this document from %s to %s.', 22 + $this->renderAuthor(), 23 + $this->renderOldValue(), 24 + $this->renderNewValue()); 25 + } 26 + 27 + public function getTitleForFeed() { 28 + return pht( 29 + '%s renamed document %s from %s to %s.', 30 + $this->renderAuthor(), 31 + $this->renderObject(), 32 + $this->renderOldValue(), 33 + $this->renderNewValue()); 34 + } 35 + 36 + public function validateTransactions($object, array $xactions) { 37 + $errors = array(); 38 + 39 + if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) { 40 + $errors[] = $this->newRequiredError( 41 + pht('Documents must have a title.')); 42 + } 43 + 44 + $max_length = $object->getColumnMaximumByteLength('title'); 45 + foreach ($xactions as $xaction) { 46 + $new_value = $xaction->getNewValue(); 47 + $new_length = strlen($new_value); 48 + if ($new_length > $max_length) { 49 + $errors[] = $this->newInvalidError( 50 + pht('The title can be no longer than %s characters.', 51 + new PhutilNumber($max_length))); 52 + } 53 + } 54 + 55 + return $errors; 56 + } 57 + 58 + }
+4
src/applications/legalpad/xaction/LegalpadDocumentTransactionType.php
··· 1 + <?php 2 + 3 + abstract class LegalpadDocumentTransactionType 4 + extends PhabricatorModularTransactionType {}