Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/herald/ManiphestTaskAssignHeraldAction.php
12256 views
1
<?php
2
3
abstract class ManiphestTaskAssignHeraldAction
4
extends HeraldAction {
5
6
const DO_ASSIGN = 'do.assign';
7
8
public function supportsObject($object) {
9
return ($object instanceof ManiphestTask);
10
}
11
12
public function getActionGroupKey() {
13
return HeraldApplicationActionGroup::ACTIONGROUPKEY;
14
}
15
16
protected function applyAssign(array $phids) {
17
$adapter = $this->getAdapter();
18
$object = $adapter->getObject();
19
20
$current = array($object->getOwnerPHID());
21
22
$allowed_types = array(
23
PhabricatorPeopleUserPHIDType::TYPECONST,
24
);
25
26
if (head($phids) == PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN) {
27
$phid = null;
28
29
if ($object->getOwnerPHID() == null) {
30
$this->logEffect(self::DO_STANDARD_NO_EFFECT);
31
return;
32
}
33
} else {
34
$targets = $this->loadStandardTargets($phids, $allowed_types, $current);
35
if (!$targets) {
36
return;
37
}
38
39
$phid = head_key($targets);
40
}
41
42
$xaction = $adapter->newTransaction()
43
->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE)
44
->setNewValue($phid);
45
46
$adapter->queueTransaction($xaction);
47
48
$this->logEffect(self::DO_ASSIGN, array($phid));
49
}
50
51
protected function getActionEffectMap() {
52
return array(
53
self::DO_ASSIGN => array(
54
'icon' => 'fa-user',
55
'color' => 'green',
56
'name' => pht('Assigned Task'),
57
),
58
);
59
}
60
61
protected function renderActionEffectDescription($type, $data) {
62
switch ($type) {
63
case self::DO_ASSIGN:
64
if (head($data) === null) {
65
return pht('Unassigned task.');
66
} else {
67
return pht(
68
'Assigned task to: %s.',
69
$this->renderHandleList($data));
70
}
71
}
72
}
73
74
}
75
76