Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php
12256 views
1
<?php
2
3
final class ManiphestTaskUnblockTransaction
4
extends ManiphestTaskTransactionType {
5
6
const TRANSACTIONTYPE = 'unblock';
7
8
public function generateOldValue($object) {
9
return null;
10
}
11
12
public function getActionName() {
13
$old = $this->getOldValue();
14
$new = $this->getNewValue();
15
16
$old_status = head($old);
17
$new_status = head($new);
18
19
$old_closed = ManiphestTaskStatus::isClosedStatus($old_status);
20
$new_closed = ManiphestTaskStatus::isClosedStatus($new_status);
21
22
if ($old_closed && !$new_closed) {
23
return pht('Block');
24
} else if (!$old_closed && $new_closed) {
25
return pht('Unblock');
26
} else {
27
return pht('Blocker');
28
}
29
}
30
31
public function getTitle() {
32
$old = $this->getOldValue();
33
$new = $this->getNewValue();
34
35
$blocker_phid = key($new);
36
$old_status = head($old);
37
$new_status = head($new);
38
39
$old_closed = ManiphestTaskStatus::isClosedStatus($old_status);
40
$new_closed = ManiphestTaskStatus::isClosedStatus($new_status);
41
42
$old_name = ManiphestTaskStatus::getTaskStatusName($old_status);
43
$new_name = ManiphestTaskStatus::getTaskStatusName($new_status);
44
45
if ($this->getMetadataValue('blocker.new')) {
46
return pht(
47
'%s created subtask %s.',
48
$this->renderAuthor(),
49
$this->renderHandle($blocker_phid));
50
} else if ($old_closed && !$new_closed) {
51
return pht(
52
'%s reopened subtask %s as %s.',
53
$this->renderAuthor(),
54
$this->renderHandle($blocker_phid),
55
$this->renderValue($new_name));
56
} else if (!$old_closed && $new_closed) {
57
return pht(
58
'%s closed subtask %s as %s.',
59
$this->renderAuthor(),
60
$this->renderHandle($blocker_phid),
61
$this->renderValue($new_name));
62
} else {
63
return pht(
64
'%s changed the status of subtask %s from %s to %s.',
65
$this->renderAuthor(),
66
$this->renderHandle($blocker_phid),
67
$this->renderValue($old_name),
68
$this->renderValue($new_name));
69
}
70
}
71
72
public function getTitleForFeed() {
73
$old = $this->getOldValue();
74
$new = $this->getNewValue();
75
$blocker_phid = key($new);
76
$old_status = head($old);
77
$new_status = head($new);
78
79
$old_closed = ManiphestTaskStatus::isClosedStatus($old_status);
80
$new_closed = ManiphestTaskStatus::isClosedStatus($new_status);
81
82
$old_name = ManiphestTaskStatus::getTaskStatusName($old_status);
83
$new_name = ManiphestTaskStatus::getTaskStatusName($new_status);
84
85
if ($old_closed && !$new_closed) {
86
return pht(
87
'%s reopened %s, a subtask of %s, as %s.',
88
$this->renderAuthor(),
89
$this->renderHandle($blocker_phid),
90
$this->renderObject(),
91
$this->renderValue($new_name));
92
} else if (!$old_closed && $new_closed) {
93
return pht(
94
'%s closed %s, a subtask of %s, as %s.',
95
$this->renderAuthor(),
96
$this->renderHandle($blocker_phid),
97
$this->renderObject(),
98
$this->renderValue($new_name));
99
} else {
100
return pht(
101
'%s changed the status of %s, a subtask of %s, '.
102
'from %s to %s.',
103
$this->renderAuthor(),
104
$this->renderHandle($blocker_phid),
105
$this->renderObject(),
106
$this->renderValue($old_name),
107
$this->renderValue($new_name));
108
}
109
}
110
111
public function getIcon() {
112
return 'fa-shield';
113
}
114
115
public function shouldHideForFeed() {
116
// Hide "alice created X, a task blocking Y." from feed because it
117
// will almost always appear adjacent to "alice created Y".
118
$is_new = $this->getMetadataValue('blocker.new');
119
if ($is_new) {
120
return true;
121
}
122
123
return parent::shouldHideForFeed();
124
}
125
126
public function getRequiredCapabilities(
127
$object,
128
PhabricatorApplicationTransaction $xaction) {
129
130
// When you close a task, we want to apply this transaction to its parents
131
// even if you can not edit (or even see) those parents, so don't require
132
// any capabilities. See PHI1059.
133
134
return null;
135
}
136
}
137
138