diff --git a/resources/sql/autopatches/20150829.ponder.dupe.1.sql b/resources/sql/autopatches/20150829.ponder.dupe.1.sql new file mode 100644 index 0000000000..b5ba7f6538 --- /dev/null +++ b/resources/sql/autopatches/20150829.ponder.dupe.1.sql @@ -0,0 +1,2 @@ +UPDATE {$NAMESPACE}_ponder.ponder_question + SET status = 'invalid' WHERE status = 'duplicate'; diff --git a/src/applications/ponder/constants/PonderQuestionStatus.php b/src/applications/ponder/constants/PonderQuestionStatus.php index 61a446353e..55e433bf25 100644 --- a/src/applications/ponder/constants/PonderQuestionStatus.php +++ b/src/applications/ponder/constants/PonderQuestionStatus.php @@ -1,89 +1,89 @@ pht('Open'), self::STATUS_CLOSED_RESOLVED => pht('Closed, Resolved'), self::STATUS_CLOSED_OBSOLETE => pht('Closed, Obsolete'), - self::STATUS_CLOSED_DUPLICATE => pht('Closed, Duplicate'), + self::STATUS_CLOSED_INVALID => pht('Closed, Invalid'), ); } public static function getQuestionStatusFullName($status) { $map = array( self::STATUS_OPEN => pht('Open'), self::STATUS_CLOSED_RESOLVED => pht('Closed, Resolved'), self::STATUS_CLOSED_OBSOLETE => pht('Closed, Obsolete'), - self::STATUS_CLOSED_DUPLICATE => pht('Closed, Duplicate'), + self::STATUS_CLOSED_INVALID => pht('Closed, Invalid'), ); return idx($map, $status, pht('Unknown')); } public static function getQuestionStatusName($status) { $map = array( self::STATUS_OPEN => pht('Open'), self::STATUS_CLOSED_RESOLVED => pht('Resolved'), self::STATUS_CLOSED_OBSOLETE => pht('Obsolete'), - self::STATUS_CLOSED_DUPLICATE => pht('Duplicate'), + self::STATUS_CLOSED_INVALID => pht('Invalid'), ); return idx($map, $status, pht('Unknown')); } public static function getQuestionStatusDescription($status) { $map = array( self::STATUS_OPEN => pht('This question is open for answers.'), self::STATUS_CLOSED_RESOLVED => pht('This question has been answered or resolved.'), self::STATUS_CLOSED_OBSOLETE => - pht('This question is no longer valid or out of date.'), - self::STATUS_CLOSED_DUPLICATE => - pht('This question is a duplicate of another question.'), + pht('This question is out of date.'), + self::STATUS_CLOSED_INVALID => + pht('This question is invalid.'), ); return idx($map, $status, pht('Unknown')); } public static function getQuestionStatusTagColor($status) { $map = array( self::STATUS_OPEN => PHUITagView::COLOR_BLUE, self::STATUS_CLOSED_RESOLVED => PHUITagView::COLOR_BLACK, self::STATUS_CLOSED_OBSOLETE => PHUITagView::COLOR_BLACK, - self::STATUS_CLOSED_DUPLICATE => PHUITagView::COLOR_BLACK, + self::STATUS_CLOSED_INVALID => PHUITagView::COLOR_BLACK, ); return idx($map, $status); } public static function getQuestionStatusIcon($status) { $map = array( self::STATUS_OPEN => 'fa-question-circle', self::STATUS_CLOSED_RESOLVED => 'fa-check', self::STATUS_CLOSED_OBSOLETE => 'fa-ban', - self::STATUS_CLOSED_DUPLICATE => 'fa-clone', + self::STATUS_CLOSED_INVALID => 'fa-ban', ); return idx($map, $status); } public static function getQuestionStatusOpenMap() { return array( self::STATUS_OPEN, ); } public static function getQuestionStatusClosedMap() { return array( self::STATUS_CLOSED_RESOLVED, self::STATUS_CLOSED_OBSOLETE, - self::STATUS_CLOSED_DUPLICATE, + self::STATUS_CLOSED_INVALID, ); } } diff --git a/src/applications/ponder/storage/PonderQuestionTransaction.php b/src/applications/ponder/storage/PonderQuestionTransaction.php index 9fb4edbf05..7b7188b448 100644 --- a/src/applications/ponder/storage/PonderQuestionTransaction.php +++ b/src/applications/ponder/storage/PonderQuestionTransaction.php @@ -1,339 +1,339 @@ getTransactionType()) { case self::TYPE_ANSWERS: $phids[] = $this->getNewAnswerPHID(); $phids[] = $this->getObjectPHID(); break; } return $phids; } public function getRemarkupBlocks() { $blocks = parent::getRemarkupBlocks(); switch ($this->getTransactionType()) { case self::TYPE_CONTENT: $blocks[] = $this->getNewValue(); break; } return $blocks; } public function getTitle() { $author_phid = $this->getAuthorPHID(); $object_phid = $this->getObjectPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_TITLE: if ($old === null) { return pht( '%s asked this question.', $this->renderHandleLink($author_phid)); } else { return pht( '%s edited the question title from "%s" to "%s".', $this->renderHandleLink($author_phid), $old, $new); } case self::TYPE_CONTENT: return pht( '%s edited the question description.', $this->renderHandleLink($author_phid)); case self::TYPE_ANSWERS: $answer_handle = $this->getHandle($this->getNewAnswerPHID()); $question_handle = $this->getHandle($object_phid); return pht( '%s answered %s', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); case self::TYPE_STATUS: switch ($new) { case PonderQuestionStatus::STATUS_OPEN: return pht( '%s reopened this question.', $this->renderHandleLink($author_phid)); case PonderQuestionStatus::STATUS_CLOSED_RESOLVED: return pht( '%s closed this question as resolved.', $this->renderHandleLink($author_phid)); case PonderQuestionStatus::STATUS_CLOSED_OBSOLETE: return pht( '%s closed this question as obsolete.', $this->renderHandleLink($author_phid)); - case PonderQuestionStatus::STATUS_CLOSED_DUPLICATE: + case PonderQuestionStatus::STATUS_CLOSED_INVALID: return pht( - '%s closed this question as a duplicate.', + '%s closed this question as invalid.', $this->renderHandleLink($author_phid)); } } return parent::getTitle(); } public function getMailTags() { $tags = parent::getMailTags(); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_COMMENT: $tags[] = self::MAILTAG_COMMENT; break; case self::TYPE_TITLE: case self::TYPE_CONTENT: case self::TYPE_STATUS: $tags[] = self::MAILTAG_DETAILS; break; case self::TYPE_ANSWERS: $tags[] = self::MAILTAG_ANSWERS; break; default: $tags[] = self::MAILTAG_OTHER; break; } return $tags; } public function getIcon() { $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_TITLE: case self::TYPE_CONTENT: return 'fa-pencil'; case self::TYPE_STATUS: return PonderQuestionStatus::getQuestionStatusIcon($new); case self::TYPE_ANSWERS: return 'fa-plus'; } return parent::getIcon(); } public function getColor() { $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_TITLE: case self::TYPE_CONTENT: return PhabricatorTransactions::COLOR_BLUE; case self::TYPE_ANSWERS: return PhabricatorTransactions::COLOR_GREEN; case self::TYPE_STATUS: return PonderQuestionStatus::getQuestionStatusTagColor($new); } } public function hasChangeDetails() { switch ($this->getTransactionType()) { case self::TYPE_CONTENT: return true; } return parent::hasChangeDetails(); } public function renderChangeDetails(PhabricatorUser $viewer) { return $this->renderTextCorpusChangeDetails( $viewer, $this->getOldValue(), $this->getNewValue()); } public function getActionStrength() { $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_TITLE: if ($old === null) { return 3; } break; case self::TYPE_ANSWERS: return 2; } return parent::getActionStrength(); } public function getActionName() { $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_TITLE: if ($old === null) { return pht('Asked'); } break; case self::TYPE_ANSWERS: return pht('Answered'); } return parent::getActionName(); } public function shouldHide() { switch ($this->getTransactionType()) { case self::TYPE_CONTENT: if ($this->getOldValue() === null) { return true; } else { return false; } break; } return parent::shouldHide(); } public function getTitleForFeed() { $author_phid = $this->getAuthorPHID(); $object_phid = $this->getObjectPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_TITLE: if ($old === null) { return pht( '%s asked a question: %s', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); } else { return pht( '%s edited the title of %s (was "%s")', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid), $old); } case self::TYPE_CONTENT: return pht( '%s edited the description of %s', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); case self::TYPE_ANSWERS: $answer_handle = $this->getHandle($this->getNewAnswerPHID()); $question_handle = $this->getHandle($object_phid); return pht( '%s answered %s', $this->renderHandleLink($author_phid), $answer_handle->renderLink($question_handle->getFullName())); case self::TYPE_STATUS: switch ($new) { case PonderQuestionStatus::STATUS_OPEN: return pht( '%s reopened %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); case PonderQuestionStatus::STATUS_CLOSED_RESOLVED: return pht( '%s closed %s as resolved.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); - case PonderQuestionStatus::STATUS_CLOSED_DUPLICATE: + case PonderQuestionStatus::STATUS_CLOSED_INVALID: return pht( - '%s closed %s as duplicate.', + '%s closed %s as invalid.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); case PonderQuestionStatus::STATUS_CLOSED_OBSOLETE: return pht( '%s closed %s as obsolete.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); } } return parent::getTitleForFeed(); } public function getBodyForFeed(PhabricatorFeedStory $story) { $new = $this->getNewValue(); $old = $this->getOldValue(); $body = null; switch ($this->getTransactionType()) { case self::TYPE_TITLE: if ($old === null) { $question = $story->getObject($this->getObjectPHID()); return phutil_escape_html_newlines( id(new PhutilUTF8StringTruncator()) ->setMaximumGlyphs(128) ->truncateString($question->getContent())); } break; case self::TYPE_ANSWERS: $answer = $this->getNewAnswerObject($story); if ($answer) { return phutil_escape_html_newlines( id(new PhutilUTF8StringTruncator()) ->setMaximumGlyphs(128) ->truncateString($answer->getContent())); } break; } return parent::getBodyForFeed($story); } /** * Currently the application only supports adding answers one at a time. * This data is stored as a list of phids. Use this function to get the * new phid. */ private function getNewAnswerPHID() { $new = $this->getNewValue(); $old = $this->getOldValue(); $add = array_diff($new, $old); if (count($add) != 1) { throw new Exception( pht('There should be only one answer added at a time.')); } return reset($add); } }