Differential D17252 Diff 41494 src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php
| Show All 24 Lines | final class DiffusionCommitAcceptTransaction | ||||
| protected function getCommitActionOrder() { | protected function getCommitActionOrder() { | ||||
| return 500; | return 500; | ||||
| } | } | ||||
| public function getActionName() { | public function getActionName() { | ||||
| return pht('Accepted'); | return pht('Accepted'); | ||||
| } | } | ||||
| public function generateOldValue($object) { | |||||
| $actor = $this->getActor(); | |||||
| return $this->isViewerAcceptingAuditor($object, $actor); | |||||
| } | |||||
| public function applyExternalEffects($object, $value) { | public function applyExternalEffects($object, $value) { | ||||
| $status = PhabricatorAuditStatusConstants::ACCEPTED; | $status = PhabricatorAuditStatusConstants::ACCEPTED; | ||||
| $actor = $this->getActor(); | $actor = $this->getActor(); | ||||
| $this->applyAuditorEffect($object, $actor, $value, $status); | $this->applyAuditorEffect($object, $actor, $value, $status); | ||||
| } | } | ||||
| protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
| $config_key = 'audit.can-author-close-audit'; | $config_key = 'audit.can-author-close-audit'; | ||||
| if (!PhabricatorEnv::getEnvConfig($config_key)) { | if (!PhabricatorEnv::getEnvConfig($config_key)) { | ||||
| if ($this->isViewerCommitAuthor($object, $viewer)) { | if ($this->isViewerCommitAuthor($object, $viewer)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not accept this commit because you are the commit '. | 'You can not accept this commit because you are the commit '. | ||||
| 'author. You can only accept commits you did not author. You can '. | 'author. You can only accept commits you did not author. You can '. | ||||
| 'change this behavior by adjusting the "%s" setting in Config.', | 'change this behavior by adjusting the "%s" setting in Config.', | ||||
| $config_key)); | $config_key)); | ||||
| } | } | ||||
| } | } | ||||
| if ($this->isViewerAcceptingAuditor($object, $viewer)) { | if ($this->isViewerFullyAccepted($object, $viewer)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not accept this commit because you have already '. | 'You can not accept this commit because you have already '. | ||||
| 'accepted it.')); | 'accepted it.')); | ||||
| } | } | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| Show All 13 Lines | |||||