Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / maniphest / xaction / ManiphestTaskStatusTransaction.php
blobf16315013d4454cbd424491bcff4040a5e2297be
1 <?php
3 final class ManiphestTaskStatusTransaction
4 extends ManiphestTaskTransactionType {
6 const TRANSACTIONTYPE = 'status';
8 public function generateOldValue($object) {
9 return $object->getStatus();
12 public function applyInternalEffects($object, $value) {
13 $this->updateStatus($object, $value);
16 public function shouldHide() {
17 if ($this->getOldValue() === null) {
18 return true;
19 } else {
20 return false;
24 public function getActionStrength() {
25 return 130;
28 public function getActionName() {
29 $old = $this->getOldValue();
30 $new = $this->getNewValue();
32 $action = ManiphestTaskStatus::getStatusActionName($new);
33 if ($action) {
34 return $action;
37 $old_closed = ManiphestTaskStatus::isClosedStatus($old);
38 $new_closed = ManiphestTaskStatus::isClosedStatus($new);
40 if ($new_closed && !$old_closed) {
41 return pht('Closed');
42 } else if (!$new_closed && $old_closed) {
43 return pht('Reopened');
44 } else {
45 return pht('Changed Status');
49 public function getTitle() {
50 $old = $this->getOldValue();
51 $new = $this->getNewValue();
53 $old_closed = ManiphestTaskStatus::isClosedStatus($old);
54 $new_closed = ManiphestTaskStatus::isClosedStatus($new);
56 $old_name = ManiphestTaskStatus::getTaskStatusName($old);
57 $new_name = ManiphestTaskStatus::getTaskStatusName($new);
59 $commit_phid = $this->getMetadataValue('commitPHID');
61 if ($new_closed && !$old_closed) {
62 if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
63 if ($commit_phid) {
64 return pht(
65 '%s closed this task as a duplicate by committing %s.',
66 $this->renderAuthor(),
67 $this->renderHandle($commit_phid));
68 } else {
69 return pht(
70 '%s closed this task as a duplicate.',
71 $this->renderAuthor());
73 } else {
74 if ($commit_phid) {
75 return pht(
76 '%s closed this task as %s by committing %s.',
77 $this->renderAuthor(),
78 $this->renderValue($new_name),
79 $this->renderHandle($commit_phid));
80 } else {
81 return pht(
82 '%s closed this task as %s.',
83 $this->renderAuthor(),
84 $this->renderValue($new_name));
87 } else if (!$new_closed && $old_closed) {
88 if ($commit_phid) {
89 return pht(
90 '%s reopened this task as %s by committing %s.',
91 $this->renderAuthor(),
92 $this->renderValue($new_name),
93 $this->renderHandle($commit_phid));
94 } else {
95 return pht(
96 '%s reopened this task as %s.',
97 $this->renderAuthor(),
98 $this->renderValue($new_name));
100 } else {
101 if ($commit_phid) {
102 return pht(
103 '%s changed the task status from %s to %s by committing %s.',
104 $this->renderAuthor(),
105 $this->renderValue($old_name),
106 $this->renderValue($new_name),
107 $this->renderHandle($commit_phid));
108 } else {
109 return pht(
110 '%s changed the task status from %s to %s.',
111 $this->renderAuthor(),
112 $this->renderValue($old_name),
113 $this->renderValue($new_name));
119 public function getTitleForFeed() {
120 $old = $this->getOldValue();
121 $new = $this->getNewValue();
123 $old_closed = ManiphestTaskStatus::isClosedStatus($old);
124 $new_closed = ManiphestTaskStatus::isClosedStatus($new);
126 $old_name = ManiphestTaskStatus::getTaskStatusName($old);
127 $new_name = ManiphestTaskStatus::getTaskStatusName($new);
129 $commit_phid = $this->getMetadataValue('commitPHID');
131 if ($new_closed && !$old_closed) {
132 if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
133 if ($commit_phid) {
134 return pht(
135 '%s closed %s as a duplicate by committing %s.',
136 $this->renderAuthor(),
137 $this->renderObject(),
138 $this->renderHandle($commit_phid));
139 } else {
140 return pht(
141 '%s closed %s as a duplicate.',
142 $this->renderAuthor(),
143 $this->renderObject());
145 } else {
146 if ($commit_phid) {
147 return pht(
148 '%s closed %s as %s by committing %s.',
149 $this->renderAuthor(),
150 $this->renderObject(),
151 $this->renderValue($new_name),
152 $this->renderHandle($commit_phid));
153 } else {
154 return pht(
155 '%s closed %s as %s.',
156 $this->renderAuthor(),
157 $this->renderObject(),
158 $this->renderValue($new_name));
161 } else if (!$new_closed && $old_closed) {
162 if ($commit_phid) {
163 return pht(
164 '%s reopened %s as %s by committing %s.',
165 $this->renderAuthor(),
166 $this->renderObject(),
167 $this->renderValue($new_name),
168 $this->renderHandle($commit_phid));
169 } else {
170 return pht(
171 '%s reopened %s as "%s".',
172 $this->renderAuthor(),
173 $this->renderObject(),
174 $new_name);
176 } else {
177 if ($commit_phid) {
178 return pht(
179 '%s changed the status of %s from %s to %s by committing %s.',
180 $this->renderAuthor(),
181 $this->renderObject(),
182 $this->renderValue($old_name),
183 $this->renderValue($new_name),
184 $this->renderHandle($commit_phid));
185 } else {
186 return pht(
187 '%s changed the status of %s from %s to %s.',
188 $this->renderAuthor(),
189 $this->renderObject(),
190 $this->renderValue($old_name),
191 $this->renderValue($new_name));
196 public function getIcon() {
197 $old = $this->getOldValue();
198 $new = $this->getNewValue();
200 $action = ManiphestTaskStatus::getStatusIcon($new);
201 if ($action !== null) {
202 return $action;
205 if (ManiphestTaskStatus::isClosedStatus($new)) {
206 return 'fa-check';
207 } else {
208 return 'fa-pencil';
212 public function getColor() {
213 $old = $this->getOldValue();
214 $new = $this->getNewValue();
216 $color = ManiphestTaskStatus::getStatusColor($new);
217 if ($color !== null) {
218 return $color;
221 if (ManiphestTaskStatus::isOpenStatus($new)) {
222 return 'green';
223 } else {
224 return 'indigo';
229 public function getTransactionTypeForConduit($xaction) {
230 return 'status';
233 public function getFieldValuesForConduit($xaction, $data) {
234 return array(
235 'old' => $xaction->getOldValue(),
236 'new' => $xaction->getNewValue(),