Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/storage/PhrictionTransaction.php
<?php | <?php | ||||
final class PhrictionTransaction | final class PhrictionTransaction | ||||
extends PhabricatorModularTransaction { | extends PhabricatorModularTransaction { | ||||
const TYPE_CONTENT = 'content'; | const TYPE_CONTENT = 'content'; | ||||
const TYPE_MOVE_AWAY = 'move-away'; | |||||
const MAILTAG_TITLE = 'phriction-title'; | const MAILTAG_TITLE = 'phriction-title'; | ||||
const MAILTAG_CONTENT = 'phriction-content'; | const MAILTAG_CONTENT = 'phriction-content'; | ||||
const MAILTAG_DELETE = 'phriction-delete'; | const MAILTAG_DELETE = 'phriction-delete'; | ||||
const MAILTAG_SUBSCRIBERS = 'phriction-subscribers'; | const MAILTAG_SUBSCRIBERS = 'phriction-subscribers'; | ||||
const MAILTAG_OTHER = 'phriction-other'; | const MAILTAG_OTHER = 'phriction-other'; | ||||
public function getApplicationName() { | public function getApplicationName() { | ||||
Show All 12 Lines | public function getBaseTransactionClass() { | ||||
return 'PhrictionDocumentTransactionType'; | return 'PhrictionDocumentTransactionType'; | ||||
} | } | ||||
public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
$phids = parent::getRequiredHandlePHIDs(); | $phids = parent::getRequiredHandlePHIDs(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | ||||
case self::TYPE_MOVE_AWAY: | case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: | ||||
$phids[] = $new['phid']; | $phids[] = $new['phid']; | ||||
break; | break; | ||||
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | ||||
if ($this->getMetadataValue('stub:create:phid')) { | if ($this->getMetadataValue('stub:create:phid')) { | ||||
$phids[] = $this->getMetadataValue('stub:create:phid'); | $phids[] = $this->getMetadataValue('stub:create:phid'); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
Show All 25 Lines | public function shouldHide() { | ||||
} | } | ||||
return parent::shouldHide(); | return parent::shouldHide(); | ||||
} | } | ||||
public function shouldHideForMail(array $xactions) { | public function shouldHideForMail(array $xactions) { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | ||||
case self::TYPE_MOVE_AWAY: | case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: | ||||
return true; | return true; | ||||
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | ||||
return $this->getMetadataValue('stub:create:phid', false); | return $this->getMetadataValue('stub:create:phid', false); | ||||
} | } | ||||
return parent::shouldHideForMail($xactions); | return parent::shouldHideForMail($xactions); | ||||
} | } | ||||
public function shouldHideForFeed() { | public function shouldHideForFeed() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | ||||
case self::TYPE_MOVE_AWAY: | case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: | ||||
return true; | return true; | ||||
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | ||||
return $this->getMetadataValue('stub:create:phid', false); | return $this->getMetadataValue('stub:create:phid', false); | ||||
} | } | ||||
return parent::shouldHideForFeed(); | return parent::shouldHideForFeed(); | ||||
} | } | ||||
public function getActionStrength() { | public function getActionStrength() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_CONTENT: | case self::TYPE_CONTENT: | ||||
return 1.3; | return 1.3; | ||||
case self::TYPE_MOVE_AWAY: | |||||
return 1.0; | |||||
} | } | ||||
return parent::getActionStrength(); | return parent::getActionStrength(); | ||||
} | } | ||||
public function getActionName() { | public function getActionName() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_CONTENT: | case self::TYPE_CONTENT: | ||||
return pht('Edited'); | return pht('Edited'); | ||||
case self::TYPE_MOVE_AWAY: | |||||
return pht('Moved Away'); | |||||
} | } | ||||
return parent::getActionName(); | return parent::getActionName(); | ||||
} | } | ||||
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 self::TYPE_CONTENT: | case self::TYPE_CONTENT: | ||||
return 'fa-pencil'; | return 'fa-pencil'; | ||||
case self::TYPE_MOVE_AWAY: | |||||
return 'fa-arrows'; | |||||
} | } | ||||
return parent::getIcon(); | return parent::getIcon(); | ||||
} | } | ||||
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 self::TYPE_CONTENT: | case self::TYPE_CONTENT: | ||||
return pht( | return pht( | ||||
'%s edited the document content.', | '%s edited the document content.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_MOVE_AWAY: | |||||
return pht( | |||||
'%s moved this document to %s', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($new['phid'])); | |||||
} | } | ||||
return parent::getTitle(); | return parent::getTitle(); | ||||
} | } | ||||
public function getTitleForFeed() { | public function getTitleForFeed() { | ||||
$author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
$object_phid = $this->getObjectPHID(); | $object_phid = $this->getObjectPHID(); | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |