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

Restore Slowvote commenting with ApplicationTransactions

Summary: Now it works like everything else does.

Test Plan: {F50168}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+151
+4
src/__phutil_library_map__.php
··· 1527 1527 'PhabricatorSetupIssueView' => 'applications/config/view/PhabricatorSetupIssueView.php', 1528 1528 'PhabricatorSlowvoteChoice' => 'applications/slowvote/storage/PhabricatorSlowvoteChoice.php', 1529 1529 'PhabricatorSlowvoteComment' => 'applications/slowvote/storage/PhabricatorSlowvoteComment.php', 1530 + 'PhabricatorSlowvoteCommentController' => 'applications/slowvote/controller/PhabricatorSlowvoteCommentController.php', 1530 1531 'PhabricatorSlowvoteController' => 'applications/slowvote/controller/PhabricatorSlowvoteController.php', 1531 1532 'PhabricatorSlowvoteCreateController' => 'applications/slowvote/controller/PhabricatorSlowvoteCreateController.php', 1532 1533 'PhabricatorSlowvoteDAO' => 'applications/slowvote/storage/PhabricatorSlowvoteDAO.php', 1534 + 'PhabricatorSlowvoteEditor' => 'applications/slowvote/editor/PhabricatorSlowvoteEditor.php', 1533 1535 'PhabricatorSlowvoteListController' => 'applications/slowvote/controller/PhabricatorSlowvoteListController.php', 1534 1536 'PhabricatorSlowvoteOption' => 'applications/slowvote/storage/PhabricatorSlowvoteOption.php', 1535 1537 'PhabricatorSlowvotePoll' => 'applications/slowvote/storage/PhabricatorSlowvotePoll.php', ··· 3486 3488 'PhabricatorSetupIssueView' => 'AphrontView', 3487 3489 'PhabricatorSlowvoteChoice' => 'PhabricatorSlowvoteDAO', 3488 3490 'PhabricatorSlowvoteComment' => 'PhabricatorSlowvoteDAO', 3491 + 'PhabricatorSlowvoteCommentController' => 'PhabricatorSlowvoteController', 3489 3492 'PhabricatorSlowvoteController' => 'PhabricatorController', 3490 3493 'PhabricatorSlowvoteCreateController' => 'PhabricatorSlowvoteController', 3491 3494 'PhabricatorSlowvoteDAO' => 'PhabricatorLiskDAO', 3495 + 'PhabricatorSlowvoteEditor' => 'PhabricatorApplicationTransactionEditor', 3492 3496 'PhabricatorSlowvoteListController' => 3493 3497 array( 3494 3498 0 => 'PhabricatorSlowvoteController',
+1
src/applications/slowvote/application/PhabricatorApplicationSlowvote.php
··· 44 44 => 'PhabricatorSlowvoteListController', 45 45 'create/' => 'PhabricatorSlowvoteCreateController', 46 46 '(?P<id>[1-9]\d*)/' => 'PhabricatorSlowvoteVoteController', 47 + 'comment/(?P<id>[1-9]\d*)/' => 'PhabricatorSlowvoteCommentController', 47 48 ), 48 49 ); 49 50 }
+70
src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php
··· 1 + <?php 2 + 3 + final class PhabricatorSlowvoteCommentController 4 + extends PhabricatorSlowvoteController { 5 + 6 + private $id; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $user = $request->getUser(); 15 + 16 + if (!$request->isFormPost()) { 17 + return new Aphront400Response(); 18 + } 19 + 20 + $poll = id(new PhabricatorSlowvoteQuery()) 21 + ->setViewer($user) 22 + ->withIDs(array($this->id)) 23 + ->executeOne(); 24 + if (!$poll) { 25 + return new Aphront404Response(); 26 + } 27 + 28 + $is_preview = $request->isPreviewRequest(); 29 + $draft = PhabricatorDraft::buildFromRequest($request); 30 + 31 + $view_uri = '/V'.$poll->getID(); 32 + 33 + $xactions = array(); 34 + $xactions[] = id(new PhabricatorSlowvoteTransaction()) 35 + ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 36 + ->attachComment( 37 + id(new PhabricatorSlowvoteTransactionComment()) 38 + ->setContent($request->getStr('comment'))); 39 + 40 + $editor = id(new PhabricatorSlowvoteEditor()) 41 + ->setActor($user) 42 + ->setContinueOnNoEffect($request->isContinueRequest()) 43 + ->setContentSourceFromRequest($request) 44 + ->setIsPreview($is_preview); 45 + 46 + try { 47 + $xactions = $editor->applyTransactions($poll, $xactions); 48 + } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 49 + return id(new PhabricatorApplicationTransactionNoEffectResponse()) 50 + ->setCancelURI($view_uri) 51 + ->setException($ex); 52 + } 53 + 54 + if ($draft) { 55 + $draft->replaceOrDelete(); 56 + } 57 + 58 + if ($request->isAjax()) { 59 + return id(new PhabricatorApplicationTransactionResponse()) 60 + ->setViewer($user) 61 + ->setTransactions($xactions) 62 + ->setIsPreview($is_preview) 63 + ->setAnchorOffset($request->getStr('anchor')); 64 + } else { 65 + return id(new AphrontRedirectResponse()) 66 + ->setURI($view_uri); 67 + } 68 + } 69 + 70 + }
+32
src/applications/slowvote/controller/PhabricatorSlowvotePollController.php
··· 140 140 $panel); 141 141 142 142 $xactions = $this->buildTransactions($poll); 143 + $add_comment = $this->buildCommentForm($poll); 143 144 144 145 return $this->buildApplicationPage( 145 146 array( ··· 147 148 $header, 148 149 $content, 149 150 $xactions, 151 + $add_comment, 150 152 ), 151 153 array( 152 154 'title' => 'V'.$poll->getID().' '.$poll->getQuestion(), ··· 383 385 384 386 return $timeline; 385 387 } 388 + 389 + private function buildCommentForm(PhabricatorSlowvotePoll $poll) { 390 + $viewer = $this->getRequest()->getUser(); 391 + 392 + $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 393 + 394 + $add_comment_header = id(new PhabricatorHeaderView()) 395 + ->setHeader( 396 + $is_serious 397 + ? pht('Add Comment') 398 + : pht('Enter Deliberations')); 399 + 400 + $submit_button_name = $is_serious 401 + ? pht('Add Comment') 402 + : pht('Perhaps'); 403 + 404 + $draft = PhabricatorDraft::newFromUserAndKey($viewer, $poll->getPHID()); 405 + 406 + $add_comment_form = id(new PhabricatorApplicationTransactionCommentView()) 407 + ->setUser($viewer) 408 + ->setDraft($draft) 409 + ->setAction($this->getApplicationURI('/comment/'.$poll->getID().'/')) 410 + ->setSubmitButtonName($submit_button_name); 411 + 412 + return array( 413 + $add_comment_header, 414 + $add_comment_form, 415 + ); 416 + } 417 + 386 418 387 419 }
+44
src/applications/slowvote/editor/PhabricatorSlowvoteEditor.php
··· 1 + <?php 2 + 3 + final class PhabricatorSlowvoteEditor 4 + extends PhabricatorApplicationTransactionEditor { 5 + 6 + public function getTransactionTypes() { 7 + $types = parent::getTransactionTypes(); 8 + 9 + $types[] = PhabricatorTransactions::TYPE_COMMENT; 10 + 11 + return $types; 12 + } 13 + 14 + protected function getCustomTransactionOldValue( 15 + PhabricatorLiskDAO $object, 16 + PhabricatorApplicationTransaction $xaction) { 17 + 18 + switch ($xaction->getTransactionType()) { 19 + } 20 + } 21 + 22 + protected function getCustomTransactionNewValue( 23 + PhabricatorLiskDAO $object, 24 + PhabricatorApplicationTransaction $xaction) { 25 + 26 + switch ($xaction->getTransactionType()) { 27 + } 28 + } 29 + 30 + protected function applyCustomInternalTransaction( 31 + PhabricatorLiskDAO $object, 32 + PhabricatorApplicationTransaction $xaction) { 33 + 34 + switch ($xaction->getTransactionType()) { 35 + } 36 + } 37 + 38 + protected function applyCustomExternalTransaction( 39 + PhabricatorLiskDAO $object, 40 + PhabricatorApplicationTransaction $xaction) { 41 + return; 42 + } 43 + 44 + }