Differential D8284 Diff 19725 src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
| Show First 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | public function getIcon() { | ||||
| return 'edit'; | return 'edit'; | ||||
| } | } | ||||
| public function getColor() { | public function getColor() { | ||||
| return null; | return null; | ||||
| } | } | ||||
| protected function getTransactionCustomField() { | |||||
| switch ($this->getTransactionType()) { | |||||
| case PhabricatorTransactions::TYPE_CUSTOMFIELD: | |||||
| $key = $this->getMetadataValue('customfield:key'); | |||||
| if (!$key) { | |||||
| return null; | |||||
| } | |||||
| $field = PhabricatorCustomField::getObjectField( | |||||
| $this->getObject(), | |||||
| PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS, | |||||
| $key); | |||||
| if (!$field) { | |||||
| return null; | |||||
| } | |||||
| $field->setViewer($this->getViewer()); | |||||
| return $field; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public function shouldHide() { | public function shouldHide() { | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorTransactions::TYPE_VIEW_POLICY: | case PhabricatorTransactions::TYPE_VIEW_POLICY: | ||||
| case PhabricatorTransactions::TYPE_EDIT_POLICY: | case PhabricatorTransactions::TYPE_EDIT_POLICY: | ||||
| case PhabricatorTransactions::TYPE_JOIN_POLICY: | case PhabricatorTransactions::TYPE_JOIN_POLICY: | ||||
| if ($this->getOldValue() === null) { | if ($this->getOldValue() === null) { | ||||
| return true; | return true; | ||||
| } else { | } else { | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | switch ($this->getTransactionType()) { | ||||
| return pht( | return pht( | ||||
| $string, | $string, | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| count($rem), | count($rem), | ||||
| $this->renderHandleList($rem)); | $this->renderHandleList($rem)); | ||||
| } | } | ||||
| case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
| $key = $this->getMetadataValue('customfield:key'); | $field = $this->getTransactionCustomField(); | ||||
| $field = PhabricatorCustomField::getObjectField( | |||||
| $this->getObject(), | |||||
| PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS, | |||||
| $key); | |||||
| if ($field) { | if ($field) { | ||||
| $field->setViewer($this->getViewer()); | |||||
| return $field->getApplicationTransactionTitle($this); | return $field->getApplicationTransactionTitle($this); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s edited a custom field.', | '%s edited a custom field.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } | } | ||||
| default: | default: | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | switch ($this->getTransactionType()) { | ||||
| $type = $this->getMetadata('edge:type'); | $type = $this->getMetadata('edge:type'); | ||||
| $type = head($type); | $type = head($type); | ||||
| $string = PhabricatorEdgeConfig::getFeedStringForEdgeType($type); | $string = PhabricatorEdgeConfig::getFeedStringForEdgeType($type); | ||||
| return pht( | return pht( | ||||
| $string, | $string, | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
| $key = $this->getMetadataValue('customfield:key'); | $field = $this->getTransactionCustomField(); | ||||
| $field = PhabricatorCustomField::getObjectField( | |||||
| $this->getObject(), | |||||
| PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS, | |||||
| $key); | |||||
| if ($field) { | if ($field) { | ||||
| $field->setViewer($this->getViewer()); | |||||
| return $field->getApplicationTransactionTitleForFeed($this, $story); | return $field->getApplicationTransactionTitleForFeed($this, $story); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s edited a custom field on %s.', | '%s edited a custom field on %s.', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($object_phid)); | $this->renderHandleLink($object_phid)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function getActionName() { | ||||
| } | } | ||||
| } | } | ||||
| public function getMailTags() { | public function getMailTags() { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| public function hasChangeDetails() { | public function hasChangeDetails() { | ||||
| switch ($this->getTransactionType()) { | |||||
| case PhabricatorTransactions::TYPE_CUSTOMFIELD: | |||||
| $field = $this->getTransactionCustomField(); | |||||
| if ($field) { | |||||
| return $field->getApplicationTransactionHasChangeDetails($this); | |||||
| } | |||||
| break; | |||||
| } | |||||
| return false; | return false; | ||||
| } | } | ||||
| public function renderChangeDetails(PhabricatorUser $viewer) { | public function renderChangeDetails(PhabricatorUser $viewer) { | ||||
| return null; | switch ($this->getTransactionType()) { | ||||
| case PhabricatorTransactions::TYPE_CUSTOMFIELD: | |||||
| $field = $this->getTransactionCustomField(); | |||||
| if ($field) { | |||||
| return $field->getApplicationTransactionChangeDetails($this, $viewer); | |||||
| } | |||||
| break; | |||||
| } | |||||
| return $this->renderTextCorpusChangeDetails(); | |||||
| } | |||||
| public function renderTextCorpusChangeDetails( | |||||
| PhabricatorUser $viewer, | |||||
| $old, | |||||
| $new) { | |||||
| require_celerity_resource('differential-changeset-view-css'); | |||||
| $view = id(new PhabricatorApplicationTransactionTextDiffDetailView()) | |||||
| ->setUser($viewer) | |||||
| ->setOldText($old) | |||||
| ->setNewText($new); | |||||
| return $view->render(); | |||||
| } | } | ||||
| public function attachTransactionGroup(array $group) { | public function attachTransactionGroup(array $group) { | ||||
| assert_instances_of($group, 'PhabricatorApplicationTransaction'); | assert_instances_of($group, 'PhabricatorApplicationTransaction'); | ||||
| $this->transactionGroup = $group; | $this->transactionGroup = $group; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines | |||||