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_DELETE = 'delete'; | |||||
const TYPE_MOVE_AWAY = 'move-away'; | 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'; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | public function shouldHideForFeed() { | ||||
} | } | ||||
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_DELETE: | |||||
return 1.5; | |||||
case self::TYPE_MOVE_AWAY: | case self::TYPE_MOVE_AWAY: | ||||
return 1.0; | 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_DELETE: | |||||
return pht('Deleted'); | |||||
case self::TYPE_MOVE_AWAY: | case self::TYPE_MOVE_AWAY: | ||||
return pht('Moved 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_DELETE: | |||||
return 'fa-times'; | |||||
case self::TYPE_MOVE_AWAY: | case self::TYPE_MOVE_AWAY: | ||||
return 'fa-arrows'; | 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_DELETE: | |||||
return pht( | |||||
'%s deleted this document.', | |||||
$this->renderHandleLink($author_phid)); | |||||
case self::TYPE_MOVE_AWAY: | case self::TYPE_MOVE_AWAY: | ||||
return pht( | return pht( | ||||
'%s moved this document to %s', | '%s moved this document to %s', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink($new['phid'])); | $this->renderHandleLink($new['phid'])); | ||||
} | } | ||||
Show All 10 Lines | public function getTitleForFeed() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_CONTENT: | case self::TYPE_CONTENT: | ||||
return pht( | return pht( | ||||
'%s edited the content of %s.', | '%s edited the content of %s.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
case self::TYPE_DELETE: | |||||
return pht( | |||||
'%s deleted %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($object_phid)); | |||||
} | } | ||||
return parent::getTitleForFeed(); | return parent::getTitleForFeed(); | ||||
} | } | ||||
public function hasChangeDetails() { | public function hasChangeDetails() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_CONTENT: | case self::TYPE_CONTENT: | ||||
return true; | return true; | ||||
Show All 12 Lines | 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 self::TYPE_CONTENT: | ||||
$tags[] = self::MAILTAG_CONTENT; | $tags[] = self::MAILTAG_CONTENT; | ||||
break; | break; | ||||
case self::TYPE_DELETE: | 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; | ||||
} | } | ||||
} | } |