Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskAttachTransaction.php
12256 views
1
<?php
2
3
final class ManiphestTaskAttachTransaction
4
extends ManiphestTaskTransactionType {
5
6
// NOTE: this type is deprecated. Keep it around for legacy installs
7
// so any transactions render correctly.
8
9
const TRANSACTIONTYPE = 'attach';
10
11
public function getActionName() {
12
return pht('Attached');
13
}
14
15
public function getTitle() {
16
$old = $this->getOldValue();
17
$new = $this->getNewValue();
18
19
$old = nonempty($old, array());
20
$new = nonempty($new, array());
21
$new = array_keys(idx($new, 'FILE', array()));
22
$old = array_keys(idx($old, 'FILE', array()));
23
24
$added = array_diff($new, $old);
25
$removed = array_diff($old, $new);
26
if ($added && !$removed) {
27
return pht(
28
'%s attached %s file(s): %s.',
29
$this->renderAuthor(),
30
phutil_count($added),
31
$this->renderHandleList($added));
32
} else if ($removed && !$added) {
33
return pht(
34
'%s detached %s file(s): %s.',
35
$this->renderAuthor(),
36
phutil_count($removed),
37
$this->renderHandleList($removed));
38
} else {
39
return pht(
40
'%s changed file(s), attached %s: %s; detached %s: %s.',
41
$this->renderAuthor(),
42
phutil_count($added),
43
$this->renderHandleList($added),
44
phutil_count($removed),
45
$this->renderHandleList($removed));
46
}
47
48
}
49
50
public function getTitleForFeed() {
51
$old = $this->getOldValue();
52
$new = $this->getNewValue();
53
54
$old = nonempty($old, array());
55
$new = nonempty($new, array());
56
$new = array_keys(idx($new, 'FILE', array()));
57
$old = array_keys(idx($old, 'FILE', array()));
58
59
$added = array_diff($new, $old);
60
$removed = array_diff($old, $new);
61
if ($added && !$removed) {
62
return pht(
63
'%s attached %d file(s) of %s: %s',
64
$this->renderAuthor(),
65
$this->renderObject(),
66
count($added),
67
$this->renderHandleList($added));
68
} else if ($removed && !$added) {
69
return pht(
70
'%s detached %d file(s) of %s: %s',
71
$this->renderAuthor(),
72
$this->renderObject(),
73
count($removed),
74
$this->renderHandleList($removed));
75
} else {
76
return pht(
77
'%s changed file(s) for %s, attached %d: %s; detached %d: %s',
78
$this->renderAuthor(),
79
$this->renderObject(),
80
count($added),
81
$this->renderHandleList($added),
82
count($removed),
83
$this->renderHandleList($removed));
84
}
85
}
86
87
public function getIcon() {
88
return 'fa-thumb-tack';
89
}
90
91
}
92
93