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 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() { | ||||
return 'phriction'; | return 'phriction'; | ||||
Show All 24 Lines | switch ($this->getTransactionType()) { | ||||
$phids[] = $this->getMetadataValue('stub:create:phid'); | $phids[] = $this->getMetadataValue('stub:create:phid'); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
return $phids; | return $phids; | ||||
} | } | ||||
public function getRemarkupBlocks() { | |||||
$blocks = parent::getRemarkupBlocks(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CONTENT: | |||||
$blocks[] = $this->getNewValue(); | |||||
break; | |||||
} | |||||
return $blocks; | |||||
} | |||||
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 shouldHideForMail(array $xactions) { | public function shouldHideForMail(array $xactions) { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: | ||||
case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: | 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 PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: | 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() { | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CONTENT: | |||||
return 1.3; | |||||
} | |||||
return parent::getActionStrength(); | |||||
} | |||||
public function getActionName() { | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CONTENT: | |||||
return pht('Edited'); | |||||
} | |||||
return parent::getActionName(); | |||||
} | |||||
public function getIcon() { | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CONTENT: | |||||
return 'fa-pencil'; | |||||
} | |||||
return parent::getIcon(); | |||||
} | |||||
public function getTitle() { | |||||
$author_phid = $this->getAuthorPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CONTENT: | |||||
return pht( | |||||
'%s edited the document content.', | |||||
$this->renderHandleLink($author_phid)); | |||||
} | |||||
return parent::getTitle(); | |||||
} | |||||
public function getTitleForFeed() { | |||||
$author_phid = $this->getAuthorPHID(); | |||||
$object_phid = $this->getObjectPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CONTENT: | |||||
return pht( | |||||
'%s edited the content of %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($object_phid)); | |||||
} | |||||
return parent::getTitleForFeed(); | |||||
} | |||||
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 getMailTags() { | public function getMailTags() { | ||||
$tags = array(); | $tags = array(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: | ||||
$tags[] = self::MAILTAG_TITLE; | $tags[] = self::MAILTAG_TITLE; | ||||
break; | break; | ||||
case self::TYPE_CONTENT: | case PhrictionDocumentContentTransaction::TRANSACTIONTYPE: | ||||
$tags[] = self::MAILTAG_CONTENT; | $tags[] = self::MAILTAG_CONTENT; | ||||
break; | break; | ||||
case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: | case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: | ||||
$tags[] = self::MAILTAG_DELETE; | $tags[] = self::MAILTAG_DELETE; | ||||
break; | break; | ||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS: | case PhabricatorTransactions::TYPE_SUBSCRIBERS: | ||||
$tags[] = self::MAILTAG_SUBSCRIBERS; | $tags[] = self::MAILTAG_SUBSCRIBERS; | ||||
break; | break; | ||||
default: | default: | ||||
$tags[] = self::MAILTAG_OTHER; | $tags[] = self::MAILTAG_OTHER; | ||||
break; | break; | ||||
} | } | ||||
return $tags; | return $tags; | ||||
} | } | ||||
} | } |