@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 ability to hide answers in Ponder

Summary: Ref T9173, adds basic hide support for answers. Answer authors and Moderators can hide answers, unhide them.

Test Plan: Hide answer, log into other account, see hidden message. Mark as visible, see answer again.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9173

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

+132 -4
+2
resources/sql/autopatches/20150812.ponder.answer.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_ponder.ponder_answer 2 + ADD status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+2
resources/sql/autopatches/20150812.ponder.answer.2.sql
··· 1 + UPDATE {$NAMESPACE}_ponder.ponder_answer 2 + SET status = 'visible' WHERE status = '';
+2
src/__phutil_library_map__.php
··· 3395 3395 'PonderAnswerPHIDType' => 'applications/ponder/phid/PonderAnswerPHIDType.php', 3396 3396 'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php', 3397 3397 'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php', 3398 + 'PonderAnswerStatus' => 'applications/ponder/constants/PonderAnswerStatus.php', 3398 3399 'PonderAnswerTransaction' => 'applications/ponder/storage/PonderAnswerTransaction.php', 3399 3400 'PonderAnswerTransactionComment' => 'applications/ponder/storage/PonderAnswerTransactionComment.php', 3400 3401 'PonderAnswerTransactionQuery' => 'applications/ponder/query/PonderAnswerTransactionQuery.php', ··· 7581 7582 'PonderAnswerPHIDType' => 'PhabricatorPHIDType', 7582 7583 'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 7583 7584 'PonderAnswerSaveController' => 'PonderController', 7585 + 'PonderAnswerStatus' => 'PonderConstants', 7584 7586 'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction', 7585 7587 'PonderAnswerTransactionComment' => 'PhabricatorApplicationTransactionComment', 7586 7588 'PonderAnswerTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+24
src/applications/ponder/constants/PonderAnswerStatus.php
··· 1 + <?php 2 + 3 + final class PonderAnswerStatus extends PonderConstants { 4 + 5 + const ANSWER_STATUS_VISIBLE = 'visible'; 6 + const ANSWER_STATUS_HIDDEN = 'hidden'; 7 + 8 + public static function getAnswerStatusMap() { 9 + return array( 10 + self::ANSWER_STATUS_VISIBLE => pht('Visible'), 11 + self::ANSWER_STATUS_HIDDEN => pht('Hidden'), 12 + ); 13 + } 14 + 15 + public static function getAnswerStatusName($status) { 16 + $map = array( 17 + self::ANSWER_STATUS_VISIBLE => pht('Visible'), 18 + self::ANSWER_STATUS_HIDDEN => pht('Hidden'), 19 + ); 20 + return idx($map, $status, pht('Unknown')); 21 + } 22 + 23 + 24 + }
+18
src/applications/ponder/constants/PonderQuestionStatus.php
··· 7 7 const STATUS_CLOSED_OBSOLETE = 'obsolete'; 8 8 const STATUS_CLOSED_DUPLICATE = 'duplicate'; 9 9 10 + const ANSWER_STATUS_VISIBLE = 'visible'; 11 + const ANSWER_STATUS_HIDDEN = 'hidden'; 12 + 10 13 public static function getQuestionStatusMap() { 11 14 return array( 12 15 self::STATUS_OPEN => pht('Open'), ··· 84 87 self::STATUS_CLOSED_OBSOLETE, 85 88 self::STATUS_CLOSED_DUPLICATE, 86 89 ); 90 + } 91 + 92 + public static function getAnswerStatusMap() { 93 + return array( 94 + self::ANSWER_STATUS_VISIBLE => pht('Visible'), 95 + self::ANSWER_STATUS_HIDDEN => pht('Hidden'), 96 + ); 97 + } 98 + 99 + public static function getAnswerStatusName($status) { 100 + $map = array( 101 + self::ANSWER_STATUS_VISIBLE => pht('Visible'), 102 + self::ANSWER_STATUS_HIDDEN => pht('Hidden'), 103 + ); 104 + return idx($map, $status, pht('Unknown')); 87 105 } 88 106 89 107
+13 -1
src/applications/ponder/controller/PonderAnswerEditController.php
··· 20 20 } 21 21 22 22 $v_content = $answer->getContent(); 23 + $v_status = $answer->getStatus(); 23 24 $e_content = true; 24 25 25 26 ··· 31 32 $errors = array(); 32 33 if ($request->isFormPost()) { 33 34 $v_content = $request->getStr('content'); 35 + $v_status = $request->getStr('status'); 34 36 35 37 if (!strlen($v_content)) { 36 38 $errors[] = pht('You must provide some substance in your answer.'); ··· 43 45 ->setTransactionType(PonderAnswerTransaction::TYPE_CONTENT) 44 46 ->setNewValue($v_content); 45 47 48 + $xactions[] = id(new PonderAnswerTransaction()) 49 + ->setTransactionType(PonderAnswerTransaction::TYPE_STATUS) 50 + ->setNewValue($v_status); 51 + 46 52 $editor = id(new PonderAnswerEditor()) 47 53 ->setActor($viewer) 48 54 ->setContentSourceFromRequest($request) ··· 64 70 ->setLabel(pht('Question')) 65 71 ->setValue($question->getTitle())) 66 72 ->appendChild( 73 + id(new AphrontFormSelectControl()) 74 + ->setLabel(pht('Status')) 75 + ->setName('status') 76 + ->setValue($v_status) 77 + ->setOptions(PonderAnswerStatus::getAnswerStatusMap())) 78 + ->appendChild( 67 79 id(new PhabricatorRemarkupControl()) 68 80 ->setUser($viewer) 69 81 ->setLabel(pht('Answer')) ··· 73 85 ->setError($e_content)) 74 86 ->appendChild( 75 87 id(new AphrontFormSubmitControl()) 76 - ->setValue(pht('Update Answer')) 88 + ->setValue(pht('Submit')) 77 89 ->addCancelButton($answer_uri)); 78 90 79 91 $crumbs = $this->buildApplicationCrumbs();
+6
src/applications/ponder/editor/PonderAnswerEditor.php
··· 12 12 $types[] = PhabricatorTransactions::TYPE_COMMENT; 13 13 14 14 $types[] = PonderAnswerTransaction::TYPE_CONTENT; 15 + $types[] = PonderAnswerTransaction::TYPE_STATUS; 15 16 $types[] = PonderAnswerTransaction::TYPE_QUESTION_ID; 16 17 17 18 return $types; ··· 23 24 24 25 switch ($xaction->getTransactionType()) { 25 26 case PonderAnswerTransaction::TYPE_CONTENT: 27 + case PonderAnswerTransaction::TYPE_STATUS: 26 28 return $object->getContent(); 27 29 case PonderAnswerTransaction::TYPE_QUESTION_ID: 28 30 return $object->getQuestionID(); ··· 35 37 36 38 switch ($xaction->getTransactionType()) { 37 39 case PonderAnswerTransaction::TYPE_CONTENT: 40 + case PonderAnswerTransaction::TYPE_STATUS: 38 41 case PonderAnswerTransaction::TYPE_QUESTION_ID: 39 42 return $xaction->getNewValue(); 40 43 } ··· 47 50 switch ($xaction->getTransactionType()) { 48 51 case PonderAnswerTransaction::TYPE_CONTENT: 49 52 $object->setContent($xaction->getNewValue()); 53 + break; 54 + case PonderAnswerTransaction::TYPE_STATUS: 55 + $object->setStatus($xaction->getNewValue()); 50 56 break; 51 57 case PonderAnswerTransaction::TYPE_QUESTION_ID: 52 58 $object->setQuestionID($xaction->getNewValue());
+8 -2
src/applications/ponder/storage/PonderAnswer.php
··· 17 17 18 18 protected $content; 19 19 protected $mailKey; 20 + protected $status; 21 + protected $voteCount; 20 22 21 - protected $voteCount; 22 23 private $vote; 23 24 private $question = self::ATTACHABLE; 24 25 private $comments; ··· 35 36 ->setQuestionID(0) 36 37 ->setContent('') 37 38 ->setAuthorPHID($actor->getPHID()) 38 - ->setVoteCount(0); 39 + ->setVoteCount(0) 40 + ->setStatus(PonderAnswerStatus::ANSWER_STATUS_VISIBLE); 39 41 40 42 } 41 43 ··· 84 86 self::CONFIG_COLUMN_SCHEMA => array( 85 87 'voteCount' => 'sint32', 86 88 'content' => 'text', 89 + 'status' => 'text32', 87 90 'mailKey' => 'bytes20', 88 91 ), 89 92 self::CONFIG_KEY_SCHEMA => array( ··· 101 104 ), 102 105 'authorPHID' => array( 103 106 'columns' => array('authorPHID'), 107 + ), 108 + 'status' => array( 109 + 'columns' => array('status'), 104 110 ), 105 111 ), 106 112 ) + parent::getConfiguration();
+28
src/applications/ponder/storage/PonderAnswerTransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_CONTENT = 'ponder.answer:content'; 7 + const TYPE_STATUS = 'ponder.answer:status'; 7 8 const TYPE_QUESTION_ID = 'ponder.answer:question-id'; 8 9 9 10 public function getApplicationName() { ··· 27 28 28 29 switch ($this->getTransactionType()) { 29 30 case self::TYPE_CONTENT: 31 + case self::TYPE_STATUS: 30 32 $phids[] = $this->getObjectPHID(); 31 33 break; 32 34 } ··· 75 77 $this->renderHandleLink($object_phid)); 76 78 } 77 79 break; 80 + case self::TYPE_STATUS: 81 + if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) { 82 + return pht( 83 + '%s marked %s as visible.', 84 + $this->renderHandleLink($author_phid), 85 + $this->renderHandleLink($object_phid)); 86 + } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) { 87 + return pht( 88 + '%s marked %s as hidden.', 89 + $this->renderHandleLink($author_phid), 90 + $this->renderHandleLink($object_phid)); 91 + } 92 + break; 78 93 } 79 94 80 95 return parent::getTitle(); ··· 97 112 } else { 98 113 return pht( 99 114 '%s updated %s.', 115 + $this->renderHandleLink($author_phid), 116 + $this->renderHandleLink($object_phid)); 117 + } 118 + break; 119 + case self::TYPE_STATUS: 120 + if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) { 121 + return pht( 122 + '%s marked %s as visible.', 123 + $this->renderHandleLink($author_phid), 124 + $this->renderHandleLink($object_phid)); 125 + } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) { 126 + return pht( 127 + '%s marked %s as hidden.', 100 128 $this->renderHandleLink($author_phid), 101 129 $this->renderHandleLink($object_phid)); 102 130 }
+29 -1
src/applications/ponder/view/PonderAnswerView.php
··· 31 31 require_celerity_resource('ponder-view-css'); 32 32 $answer = $this->answer; 33 33 $viewer = $this->getUser(); 34 + $status = $answer->getStatus(); 34 35 $author_phid = $answer->getAuthorPHID(); 35 36 $actions = $this->buildAnswerActions(); 37 + $id = $answer->getID(); 38 + 39 + if ($status == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) { 40 + $can_edit = PhabricatorPolicyFilter::hasCapability( 41 + $viewer, 42 + $answer, 43 + PhabricatorPolicyCapability::CAN_EDIT); 44 + 45 + $message = array(); 46 + $message[] = phutil_tag( 47 + 'em', 48 + array(), 49 + pht('This answer has been hidden.')); 50 + 51 + if ($can_edit) { 52 + $message[] = phutil_tag( 53 + 'a', 54 + array( 55 + 'href' => "/ponder/answer/edit/{$id}/", 56 + ), 57 + pht('Edit Answer')); 58 + } 59 + $message = phutil_implode_html(' ', $message); 60 + 61 + return id(new PHUIInfoView()) 62 + ->setSeverity(PHUIInfoView::SEVERITY_NODATA) 63 + ->appendChild($message); 64 + } 36 65 37 66 $action_button = id(new PHUIButtonView()) 38 67 ->setTag('a') ··· 57 86 $answer->getMarkupField(), 58 87 $viewer)); 59 88 60 - $id = $answer->getID(); 61 89 $anchor = id(new PhabricatorAnchorView()) 62 90 ->setAnchorName("A$id"); 63 91