Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/storage/PhabricatorSlowvoteTransaction.php
| Show All 20 Lines | public function getApplicationTransactionCommentObject() { | ||||
| return new PhabricatorSlowvoteTransactionComment(); | return new PhabricatorSlowvoteTransactionComment(); | ||||
| } | } | ||||
| public function shouldHide() { | public function shouldHide() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_RESPONSES: | case self::TYPE_RESPONSES: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE: | case self::TYPE_SHUFFLE: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_CLOSE: | case self::TYPE_CLOSE: | ||||
| return ($old === null); | return ($old === null); | ||||
| } | } | ||||
| return parent::shouldHide(); | return parent::shouldHide(); | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| $author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorSlowvoteTransaction::TYPE_QUESTION: | case self::TYPE_QUESTION: | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return pht( | return pht( | ||||
| '%s created this poll.', | '%s created this poll.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s changed the poll question from "%s" to "%s".', | '%s changed the poll question from "%s" to "%s".', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $old, | $old, | ||||
| $new); | $new); | ||||
| } | } | ||||
| break; | break; | ||||
| case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| return pht( | return pht( | ||||
| '%s updated the description for this poll.', | '%s updated the description for this poll.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case PhabricatorSlowvoteTransaction::TYPE_RESPONSES: | case self::TYPE_RESPONSES: | ||||
| // TODO: This could be more detailed | // TODO: This could be more detailed | ||||
| return pht( | return pht( | ||||
| '%s changed who can see the responses.', | '%s changed who can see the responses.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE: | case self::TYPE_SHUFFLE: | ||||
| if ($new) { | if ($new) { | ||||
| return pht( | return pht( | ||||
| '%s made poll responses appear in a random order.', | '%s made poll responses appear in a random order.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s made poll responses appear in a fixed order.', | '%s made poll responses appear in a fixed order.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } | } | ||||
| break; | break; | ||||
| case PhabricatorSlowvoteTransaction::TYPE_CLOSE: | case self::TYPE_CLOSE: | ||||
| if ($new) { | if ($new) { | ||||
| return pht( | return pht( | ||||
| '%s closed this poll.', | '%s closed this poll.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s reopened this poll.', | '%s reopened this poll.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| return parent::getTitle(); | return parent::getTitle(); | ||||
| } | } | ||||
| public function getIcon() { | public function getIcon() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorSlowvoteTransaction::TYPE_QUESTION: | case self::TYPE_QUESTION: | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return 'fa-plus'; | return 'fa-plus'; | ||||
| } else { | } else { | ||||
| return 'fa-pencil'; | return 'fa-pencil'; | ||||
| } | } | ||||
| case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_RESPONSES: | case self::TYPE_RESPONSES: | ||||
| return 'fa-pencil'; | return 'fa-pencil'; | ||||
| case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE: | case self::TYPE_SHUFFLE: | ||||
| return 'fa-refresh'; | return 'fa-refresh'; | ||||
| case PhabricatorSlowvoteTransaction::TYPE_CLOSE: | case self::TYPE_CLOSE: | ||||
| if ($new) { | if ($new) { | ||||
| return 'fa-ban'; | return 'fa-ban'; | ||||
| } else { | } else { | ||||
| return 'fa-pencil'; | return 'fa-pencil'; | ||||
| } | } | ||||
| } | } | ||||
| return parent::getIcon(); | return parent::getIcon(); | ||||
| } | } | ||||
| public function getColor() { | public function getColor() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorSlowvoteTransaction::TYPE_QUESTION: | case self::TYPE_QUESTION: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_RESPONSES: | case self::TYPE_RESPONSES: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE: | case self::TYPE_SHUFFLE: | ||||
| case PhabricatorSlowvoteTransaction::TYPE_CLOSE: | case self::TYPE_CLOSE: | ||||
| return PhabricatorTransactions::COLOR_BLUE; | return PhabricatorTransactions::COLOR_BLUE; | ||||
| } | } | ||||
| return parent::getColor(); | return parent::getColor(); | ||||
| } | } | ||||
| public function hasChangeDetails() { | public function hasChangeDetails() { | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| return true; | return true; | ||||
| } | } | ||||
| return parent::hasChangeDetails(); | return parent::hasChangeDetails(); | ||||
| } | } | ||||
| public function renderChangeDetails(PhabricatorUser $viewer) { | public function renderChangeDetails(PhabricatorUser $viewer) { | ||||
| return $this->renderTextCorpusChangeDetails( | return $this->renderTextCorpusChangeDetails( | ||||
| $viewer, | $viewer, | ||||
| $this->getOldValue(), | $this->getOldValue(), | ||||
| $this->getNewValue()); | $this->getNewValue()); | ||||
| } | } | ||||
| } | } | ||||