Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php
12256 views
1
<?php
2
3
final class ManiphestTaskStatusTransaction
4
extends ManiphestTaskTransactionType {
5
6
const TRANSACTIONTYPE = 'status';
7
8
public function generateOldValue($object) {
9
return $object->getStatus();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$this->updateStatus($object, $value);
14
}
15
16
public function shouldHide() {
17
if ($this->getOldValue() === null) {
18
return true;
19
} else {
20
return false;
21
}
22
}
23
24
public function getActionStrength() {
25
return 130;
26
}
27
28
public function getActionName() {
29
$old = $this->getOldValue();
30
$new = $this->getNewValue();
31
32
$action = ManiphestTaskStatus::getStatusActionName($new);
33
if ($action) {
34
return $action;
35
}
36
37
$old_closed = ManiphestTaskStatus::isClosedStatus($old);
38
$new_closed = ManiphestTaskStatus::isClosedStatus($new);
39
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');
46
}
47
}
48
49
public function getTitle() {
50
$old = $this->getOldValue();
51
$new = $this->getNewValue();
52
53
$old_closed = ManiphestTaskStatus::isClosedStatus($old);
54
$new_closed = ManiphestTaskStatus::isClosedStatus($new);
55
56
$old_name = ManiphestTaskStatus::getTaskStatusName($old);
57
$new_name = ManiphestTaskStatus::getTaskStatusName($new);
58
59
$commit_phid = $this->getMetadataValue('commitPHID');
60
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());
72
}
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));
85
}
86
}
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));
99
}
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));
114
}
115
}
116
117
}
118
119
public function getTitleForFeed() {
120
$old = $this->getOldValue();
121
$new = $this->getNewValue();
122
123
$old_closed = ManiphestTaskStatus::isClosedStatus($old);
124
$new_closed = ManiphestTaskStatus::isClosedStatus($new);
125
126
$old_name = ManiphestTaskStatus::getTaskStatusName($old);
127
$new_name = ManiphestTaskStatus::getTaskStatusName($new);
128
129
$commit_phid = $this->getMetadataValue('commitPHID');
130
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());
144
}
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));
159
}
160
}
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);
175
}
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));
192
}
193
}
194
}
195
196
public function getIcon() {
197
$old = $this->getOldValue();
198
$new = $this->getNewValue();
199
200
$action = ManiphestTaskStatus::getStatusIcon($new);
201
if ($action !== null) {
202
return $action;
203
}
204
205
if (ManiphestTaskStatus::isClosedStatus($new)) {
206
return 'fa-check';
207
} else {
208
return 'fa-pencil';
209
}
210
}
211
212
public function getColor() {
213
$old = $this->getOldValue();
214
$new = $this->getNewValue();
215
216
$color = ManiphestTaskStatus::getStatusColor($new);
217
if ($color !== null) {
218
return $color;
219
}
220
221
if (ManiphestTaskStatus::isOpenStatus($new)) {
222
return 'green';
223
} else {
224
return 'indigo';
225
}
226
227
}
228
229
public function getTransactionTypeForConduit($xaction) {
230
return 'status';
231
}
232
233
public function getFieldValuesForConduit($xaction, $data) {
234
return array(
235
'old' => $xaction->getOldValue(),
236
'new' => $xaction->getNewValue(),
237
);
238
}
239
240
}
241
242