Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fund/storage/FundInitiativeTransaction.php
| Show All 32 Lines | final class FundInitiativeTransaction | ||||
| public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
| $phids = parent::getRequiredHandlePHIDs(); | $phids = parent::getRequiredHandlePHIDs(); | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| $type = $this->getTransactionType(); | $type = $this->getTransactionType(); | ||||
| switch ($type) { | switch ($type) { | ||||
| case FundInitiativeTransaction::TYPE_MERCHANT: | case self::TYPE_MERCHANT: | ||||
| if ($old) { | if ($old) { | ||||
| $phids[] = $old; | $phids[] = $old; | ||||
| } | } | ||||
| if ($new) { | if ($new) { | ||||
| $phids[] = $new; | $phids[] = $new; | ||||
| } | } | ||||
| break; | break; | ||||
| case FundInitiativeTransaction::TYPE_REFUND: | case self::TYPE_REFUND: | ||||
| $phids[] = $this->getMetadataValue(self::PROPERTY_BACKER); | $phids[] = $this->getMetadataValue(self::PROPERTY_BACKER); | ||||
| break; | break; | ||||
| } | } | ||||
| return $phids; | return $phids; | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| $author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
| $object_phid = $this->getObjectPHID(); | $object_phid = $this->getObjectPHID(); | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| $type = $this->getTransactionType(); | $type = $this->getTransactionType(); | ||||
| switch ($type) { | switch ($type) { | ||||
| case FundInitiativeTransaction::TYPE_NAME: | case self::TYPE_NAME: | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return pht( | return pht( | ||||
| '%s created this initiative.', | '%s created this initiative.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s renamed this initiative from "%s" to "%s".', | '%s renamed this initiative from "%s" to "%s".', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $old, | $old, | ||||
| $new); | $new); | ||||
| } | } | ||||
| break; | break; | ||||
| case FundInitiativeTransaction::TYPE_RISKS: | case self::TYPE_RISKS: | ||||
| return pht( | return pht( | ||||
| '%s edited the risks for this initiative.', | '%s edited the risks for this initiative.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case FundInitiativeTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| return pht( | return pht( | ||||
| '%s edited the description of this initiative.', | '%s edited the description of this initiative.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case FundInitiativeTransaction::TYPE_STATUS: | case self::TYPE_STATUS: | ||||
| switch ($new) { | switch ($new) { | ||||
| case FundInitiative::STATUS_OPEN: | case FundInitiative::STATUS_OPEN: | ||||
| return pht( | return pht( | ||||
| '%s reopened this initiative.', | '%s reopened this initiative.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case FundInitiative::STATUS_CLOSED: | case FundInitiative::STATUS_CLOSED: | ||||
| return pht( | return pht( | ||||
| '%s closed this initiative.', | '%s closed this initiative.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } | } | ||||
| break; | break; | ||||
| case FundInitiativeTransaction::TYPE_BACKER: | case self::TYPE_BACKER: | ||||
| $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | ||||
| $amount = PhortuneCurrency::newFromString($amount); | $amount = PhortuneCurrency::newFromString($amount); | ||||
| return pht( | return pht( | ||||
| '%s backed this initiative with %s.', | '%s backed this initiative with %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $amount->formatForDisplay()); | $amount->formatForDisplay()); | ||||
| case FundInitiativeTransaction::TYPE_REFUND: | case self::TYPE_REFUND: | ||||
| $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | ||||
| $amount = PhortuneCurrency::newFromString($amount); | $amount = PhortuneCurrency::newFromString($amount); | ||||
| $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); | $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); | ||||
| return pht( | return pht( | ||||
| '%s refunded %s to %s.', | '%s refunded %s to %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $amount->formatForDisplay(), | $amount->formatForDisplay(), | ||||
| $this->renderHandleLink($backer_phid)); | $this->renderHandleLink($backer_phid)); | ||||
| case FundInitiativeTransaction::TYPE_MERCHANT: | case self::TYPE_MERCHANT: | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return pht( | return pht( | ||||
| '%s set this initiative to pay to %s.', | '%s set this initiative to pay to %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($new)); | $this->renderHandleLink($new)); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s changed the merchant receiving funds from this '. | '%s changed the merchant receiving funds from this '. | ||||
| Show All 11 Lines | public function getTitleForFeed() { | ||||
| $author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
| $object_phid = $this->getObjectPHID(); | $object_phid = $this->getObjectPHID(); | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| $type = $this->getTransactionType(); | $type = $this->getTransactionType(); | ||||
| switch ($type) { | switch ($type) { | ||||
| case FundInitiativeTransaction::TYPE_NAME: | case self::TYPE_NAME: | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return pht( | return pht( | ||||
| '%s created %s.', | '%s created %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s renamed %s.', | '%s renamed %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| } | } | ||||
| break; | break; | ||||
| case FundInitiativeTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| return pht( | return pht( | ||||
| '%s updated the description for %s.', | '%s updated the description for %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| case FundInitiativeTransaction::TYPE_STATUS: | case self::TYPE_STATUS: | ||||
| switch ($new) { | switch ($new) { | ||||
| case FundInitiative::STATUS_OPEN: | case FundInitiative::STATUS_OPEN: | ||||
| return pht( | return pht( | ||||
| '%s reopened %s.', | '%s reopened %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| case FundInitiative::STATUS_CLOSED: | case FundInitiative::STATUS_CLOSED: | ||||
| return pht( | return pht( | ||||
| '%s closed %s.', | '%s closed %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| } | } | ||||
| break; | break; | ||||
| case FundInitiativeTransaction::TYPE_BACKER: | case self::TYPE_BACKER: | ||||
| $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | ||||
| $amount = PhortuneCurrency::newFromString($amount); | $amount = PhortuneCurrency::newFromString($amount); | ||||
| return pht( | return pht( | ||||
| '%s backed %s with %s.', | '%s backed %s with %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid), | $this->renderHandleLink($object_phid), | ||||
| $amount->formatForDisplay()); | $amount->formatForDisplay()); | ||||
| case FundInitiativeTransaction::TYPE_REFUND: | case self::TYPE_REFUND: | ||||
| $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); | ||||
| $amount = PhortuneCurrency::newFromString($amount); | $amount = PhortuneCurrency::newFromString($amount); | ||||
| $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); | $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); | ||||
| return pht( | return pht( | ||||
| '%s refunded %s to %s for %s.', | '%s refunded %s to %s for %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| Show All 23 Lines | public function getMailTags() { | ||||
| return $tags; | return $tags; | ||||
| } | } | ||||
| public function shouldHide() { | public function shouldHide() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case FundInitiativeTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| case FundInitiativeTransaction::TYPE_RISKS: | case self::TYPE_RISKS: | ||||
| return ($old === null); | return ($old === null); | ||||
| } | } | ||||
| return parent::shouldHide(); | return parent::shouldHide(); | ||||
| } | } | ||||
| public function hasChangeDetails() { | public function hasChangeDetails() { | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case FundInitiativeTransaction::TYPE_DESCRIPTION: | case self::TYPE_DESCRIPTION: | ||||
| case FundInitiativeTransaction::TYPE_RISKS: | case self::TYPE_RISKS: | ||||
| return ($this->getOldValue() !== null); | return ($this->getOldValue() !== null); | ||||
| } | } | ||||
| 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()); | ||||
| } | } | ||||
| } | } | ||||