@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.

Add new-style transaction editor to Maniphest and switch priority edits to it

Summary: Ref T2217. All the reads route through new code already, start swapping writes over. This is the simplest writer, used when the user drag-and-drops stuff on the task list.

Test Plan: Dragged and dropped stuff across priorities. Got a transaction and some email. Verified the email and transaction looked OK, threaded properly, etc.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

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

+133 -13
+2
src/__phutil_library_map__.php
··· 734 734 'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php', 735 735 'ManiphestTransactionComment' => 'applications/maniphest/storage/ManiphestTransactionComment.php', 736 736 'ManiphestTransactionEditor' => 'applications/maniphest/editor/ManiphestTransactionEditor.php', 737 + 'ManiphestTransactionEditorPro' => 'applications/maniphest/editor/ManiphestTransactionEditorPro.php', 737 738 'ManiphestTransactionPreviewController' => 'applications/maniphest/controller/ManiphestTransactionPreviewController.php', 738 739 'ManiphestTransactionPro' => 'applications/maniphest/storage/ManiphestTransactionPro.php', 739 740 'ManiphestTransactionQuery' => 'applications/maniphest/query/ManiphestTransactionQuery.php', ··· 2824 2825 'ManiphestTaskSubscriber' => 'ManiphestDAO', 2825 2826 'ManiphestTransactionComment' => 'PhabricatorApplicationTransactionComment', 2826 2827 'ManiphestTransactionEditor' => 'PhabricatorEditor', 2828 + 'ManiphestTransactionEditorPro' => 'PhabricatorApplicationTransactionEditor', 2827 2829 'ManiphestTransactionPreviewController' => 'ManiphestController', 2828 2830 'ManiphestTransactionPro' => 'PhabricatorApplicationTransaction', 2829 2831 'ManiphestTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+13 -12
src/applications/maniphest/controller/ManiphestSubpriorityController.php
··· 34 34 $after_pri, 35 35 $after_sub); 36 36 37 + $task->setSubpriority($new_sub); 38 + 37 39 if ($after_pri != $task->getPriority()) { 38 - $xaction = new ManiphestTransaction(); 39 - $xaction->setAuthorPHID($request->getUser()->getPHID()); 40 + $xactions = array(); 41 + $xactions[] = id(new ManiphestTransactionPro()) 42 + ->setTransactionType(ManiphestTransactionPro::TYPE_PRIORITY) 43 + ->setNewValue($after_pri); 40 44 41 - // TODO: Content source? 45 + $editor = id(new ManiphestTransactionEditorPro()) 46 + ->setActor($user) 47 + ->setContinueOnNoEffect($request->isContinueRequest()) 48 + ->setContentSourceFromRequest($request); 42 49 43 - $xaction->setTransactionType(ManiphestTransactionType::TYPE_PRIORITY); 44 - $xaction->setNewValue($after_pri); 45 - 46 - $editor = new ManiphestTransactionEditor(); 47 - $editor->setActor($request->getUser()); 48 - $editor->applyTransactions($task, array($xaction)); 50 + $editor->applyTransactions($task, $xactions); 51 + } else { 52 + $task->save(); 49 53 } 50 - 51 - $task->setSubpriority($new_sub); 52 - $task->save(); 53 54 54 55 return id(new AphrontAjaxResponse())->setContent( 55 56 array(
+113
src/applications/maniphest/editor/ManiphestTransactionEditorPro.php
··· 1 + <?php 2 + 3 + final class ManiphestTransactionEditorPro 4 + extends PhabricatorApplicationTransactionEditor { 5 + 6 + public function getTransactionTypes() { 7 + $types = parent::getTransactionTypes(); 8 + 9 + $types[] = PhabricatorTransactions::TYPE_COMMENT; 10 + $types[] = ManiphestTransactionPro::TYPE_PRIORITY; 11 + 12 + return $types; 13 + } 14 + 15 + protected function getCustomTransactionOldValue( 16 + PhabricatorLiskDAO $object, 17 + PhabricatorApplicationTransaction $xaction) { 18 + 19 + switch ($xaction->getTransactionType()) { 20 + case ManiphestTransactionPro::TYPE_PRIORITY: 21 + return $object->getPriority(); 22 + } 23 + 24 + } 25 + 26 + protected function getCustomTransactionNewValue( 27 + PhabricatorLiskDAO $object, 28 + PhabricatorApplicationTransaction $xaction) { 29 + 30 + switch ($xaction->getTransactionType()) { 31 + case ManiphestTransactionPro::TYPE_PRIORITY: 32 + return $xaction->getNewValue(); 33 + } 34 + 35 + } 36 + 37 + protected function applyCustomInternalTransaction( 38 + PhabricatorLiskDAO $object, 39 + PhabricatorApplicationTransaction $xaction) { 40 + 41 + switch ($xaction->getTransactionType()) { 42 + case ManiphestTransactionPro::TYPE_PRIORITY: 43 + return $object->setPriority($xaction->getNewValue()); 44 + } 45 + 46 + } 47 + 48 + protected function applyCustomExternalTransaction( 49 + PhabricatorLiskDAO $object, 50 + PhabricatorApplicationTransaction $xaction) { 51 + } 52 + 53 + protected function shouldSendMail( 54 + PhabricatorLiskDAO $object, 55 + array $xactions) { 56 + return true; 57 + } 58 + 59 + protected function getMailSubjectPrefix() { 60 + return PhabricatorEnv::getEnvConfig('metamta.maniphest.subject-prefix'); 61 + } 62 + 63 + protected function getMailThreadID(PhabricatorLiskDAO $object) { 64 + return 'maniphest-task-'.$object->getPHID(); 65 + } 66 + 67 + protected function getMailTo(PhabricatorLiskDAO $object) { 68 + return array( 69 + $object->getOwnerPHID(), 70 + $this->requireActor()->getPHID(), 71 + ); 72 + } 73 + 74 + protected function getMailCC(PhabricatorLiskDAO $object) { 75 + return $object->getCCPHIDs(); 76 + } 77 + 78 + protected function buildReplyHandler(PhabricatorLiskDAO $object) { 79 + return id(new ManiphestReplyHandler()) 80 + ->setMailReceiver($object); 81 + } 82 + 83 + protected function buildMailTemplate(PhabricatorLiskDAO $object) { 84 + $id = $object->getID(); 85 + $title = $object->getTitle(); 86 + 87 + return id(new PhabricatorMetaMTAMail()) 88 + ->setSubject("T{$id}: {$title}") 89 + ->addHeader('Thread-Topic', "T{$id}: ".$object->getOriginalTitle()); 90 + } 91 + 92 + protected function buildMailBody( 93 + PhabricatorLiskDAO $object, 94 + array $xactions) { 95 + 96 + $body = parent::buildMailBody($object, $xactions); 97 + 98 + $body->addTextSection( 99 + pht('TASK DETAIL'), 100 + PhabricatorEnv::getProductionURI('/T'.$object->getID())); 101 + 102 + return $body; 103 + } 104 + 105 + protected function supportsFeed() { 106 + return true; 107 + } 108 + 109 + protected function supportsSearch() { 110 + return true; 111 + } 112 + 113 + }
+5 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1176 1176 ->setFrom($this->requireActor()->getPHID()) 1177 1177 ->setSubjectPrefix($this->getMailSubjectPrefix()) 1178 1178 ->setVarySubjectPrefix('['.$action.']') 1179 - ->setThreadID($object->getPHID(), $this->getIsNewObject()) 1179 + ->setThreadID($this->getMailThreadID($object), $this->getIsNewObject()) 1180 1180 ->setRelatedPHID($object->getPHID()) 1181 1181 ->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()) 1182 1182 ->setMailTags($mail_tags) ··· 1202 1202 $template->addCCs($email_cc); 1203 1203 1204 1204 return $template; 1205 + } 1206 + 1207 + protected function getMailThreadID(PhabricatorLiskDAO $object) { 1208 + return $object->getPHID(); 1205 1209 } 1206 1210 1207 1211