3 final class PhabricatorProjectTransaction
4 extends PhabricatorModularTransaction
{
6 // NOTE: This is deprecated, members are just a normal edge now.
7 const TYPE_MEMBERS
= 'project:members';
9 const MAILTAG_METADATA
= 'project-metadata';
10 const MAILTAG_MEMBERS
= 'project-members';
11 const MAILTAG_WATCHERS
= 'project-watchers';
12 const MAILTAG_OTHER
= 'project-other';
14 public function getApplicationName() {
18 public function getApplicationTransactionType() {
19 return PhabricatorProjectProjectPHIDType
::TYPECONST
;
22 public function getBaseTransactionClass() {
23 return 'PhabricatorProjectTransactionType';
26 public function getRequiredHandlePHIDs() {
27 $old = $this->getOldValue();
28 $new = $this->getNewValue();
31 switch ($this->getTransactionType()) {
32 case self
::TYPE_MEMBERS
:
33 $add = array_diff($new, $old);
34 $rem = array_diff($old, $new);
35 $req_phids = array_merge($add, $rem);
39 return array_merge($req_phids, parent
::getRequiredHandlePHIDs());
42 public function shouldHide() {
43 switch ($this->getTransactionType()) {
44 case PhabricatorTransactions
::TYPE_EDGE
:
45 $edge_type = $this->getMetadataValue('edge:type');
47 case PhabricatorProjectSilencedEdgeType
::EDGECONST
:
54 return parent
::shouldHide();
57 public function shouldHideForMail(array $xactions) {
58 switch ($this->getTransactionType()) {
59 case PhabricatorProjectWorkboardTransaction
::TRANSACTIONTYPE
:
60 case PhabricatorProjectSortTransaction
::TRANSACTIONTYPE
:
61 case PhabricatorProjectFilterTransaction
::TRANSACTIONTYPE
:
62 case PhabricatorProjectWorkboardBackgroundTransaction
::TRANSACTIONTYPE
:
66 return parent
::shouldHideForMail($xactions);
69 public function getIcon() {
70 switch ($this->getTransactionType()) {
71 case self
::TYPE_MEMBERS
:
74 return parent
::getIcon();
77 public function getTitle() {
78 $old = $this->getOldValue();
79 $new = $this->getNewValue();
80 $author_phid = $this->getAuthorPHID();
81 $author_handle = $this->renderHandleLink($author_phid);
83 switch ($this->getTransactionType()) {
84 case PhabricatorTransactions
::TYPE_CREATE
:
86 '%s created this project.',
87 $this->renderHandleLink($author_phid));
89 case self
::TYPE_MEMBERS
:
90 $add = array_diff($new, $old);
91 $rem = array_diff($old, $new);
95 '%s changed project member(s), added %d: %s; removed %d: %s.',
98 $this->renderHandleList($add),
100 $this->renderHandleList($rem));
102 if (count($add) == 1 && (head($add) == $this->getAuthorPHID())) {
104 '%s joined this project.',
108 '%s added %d project member(s): %s.',
111 $this->renderHandleList($add));
114 if (count($rem) == 1 && (head($rem) == $this->getAuthorPHID())) {
116 '%s left this project.',
120 '%s removed %d project member(s): %s.',
123 $this->renderHandleList($rem));
129 return parent
::getTitle();
132 public function getMailTags() {
134 switch ($this->getTransactionType()) {
135 case PhabricatorProjectNameTransaction
::TRANSACTIONTYPE
:
136 case PhabricatorProjectSlugsTransaction
::TRANSACTIONTYPE
:
137 case PhabricatorProjectImageTransaction
::TRANSACTIONTYPE
:
138 case PhabricatorProjectIconTransaction
::TRANSACTIONTYPE
:
139 case PhabricatorProjectColorTransaction
::TRANSACTIONTYPE
:
140 $tags[] = self
::MAILTAG_METADATA
;
142 case PhabricatorTransactions
::TYPE_EDGE
:
143 $type = $this->getMetadata('edge:type');
145 $type_member = PhabricatorProjectProjectHasMemberEdgeType
::EDGECONST
;
146 $type_watcher = PhabricatorObjectHasWatcherEdgeType
::EDGECONST
;
147 if ($type == $type_member) {
148 $tags[] = self
::MAILTAG_MEMBERS
;
149 } else if ($type == $type_watcher) {
150 $tags[] = self
::MAILTAG_WATCHERS
;
152 $tags[] = self
::MAILTAG_OTHER
;
155 case PhabricatorProjectStatusTransaction
::TRANSACTIONTYPE
:
156 case PhabricatorProjectLockTransaction
::TRANSACTIONTYPE
:
158 $tags[] = self
::MAILTAG_OTHER
;