@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DiffusionCommitConcernTransaction
4 extends DiffusionCommitAuditTransaction {
5
6 const TRANSACTIONTYPE = 'diffusion.commit.concern';
7 const ACTIONKEY = 'concern';
8
9 protected function getCommitActionLabel() {
10 return pht('Raise Concern');
11 }
12
13 protected function getCommitActionDescription() {
14 return pht('This commit will be returned to the author for consideration.');
15 }
16
17 /**
18 * @return string Transaction icon
19 */
20 public function getIcon() {
21 return 'fa-times-circle-o';
22 }
23
24 /**
25 * @return string Transaction color
26 */
27 public function getColor() {
28 return 'red';
29 }
30
31 protected function getCommitActionOrder() {
32 return 600;
33 }
34
35 public function getActionName() {
36 return pht('Raised Concern');
37 }
38
39 public function applyInternalEffects($object, $value) {
40 // NOTE: We force the commit directly into "Concern Raised" so that we
41 // override a possible "Needs Verification" state.
42 $object->setAuditStatus(DiffusionCommitAuditStatus::CONCERN_RAISED);
43 }
44
45 public function applyExternalEffects($object, $value) {
46 $status = PhabricatorAuditRequestStatus::CONCERNED;
47 $actor = $this->getActor();
48 $this->applyAuditorEffect($object, $actor, $value, $status);
49 }
50
51 protected function validateAction($object, PhabricatorUser $viewer) {
52 if ($this->isViewerCommitAuthor($object, $viewer)) {
53 throw new Exception(
54 pht(
55 'You can not raise a concern with this commit because you are '.
56 'the commit author. You can only raise concerns with commits '.
57 'you did not author.'));
58 }
59
60 // Even if you've already raised a concern, you can raise again as long
61 // as the author requested you verify.
62 if ($this->isViewerFullyRejected($object, $viewer)) {
63 if (!$object->isAuditStatusNeedsVerification()) {
64 throw new Exception(
65 pht(
66 'You can not raise a concern with this commit because you have '.
67 'already raised a concern with it.'));
68 }
69 }
70 }
71
72 public function getTitle() {
73 return pht(
74 '%s raised a concern with this commit.',
75 $this->renderAuthor());
76 }
77
78 public function getTitleForFeed() {
79 return pht(
80 '%s raised a concern with %s.',
81 $this->renderAuthor(),
82 $this->renderObject());
83 }
84
85 public function getTransactionTypeForConduit($xaction) {
86 return 'concern';
87 }
88
89 public function getFieldValuesForConduit($object, $data) {
90 return array();
91 }
92
93}