2012-01-24 16:11:37 +01:00
|
|
|
<?php
|
|
|
|
|
2013-10-22 22:49:28 +02:00
|
|
|
final class PhabricatorProjectTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
2012-01-24 16:11:37 +01:00
|
|
|
|
2013-10-22 22:49:28 +02:00
|
|
|
const TYPE_NAME = 'project:name';
|
2014-05-22 20:19:03 +02:00
|
|
|
const TYPE_SLUGS = 'project:slugs';
|
2013-10-22 22:49:28 +02:00
|
|
|
const TYPE_STATUS = 'project:status';
|
2014-02-10 23:32:30 +01:00
|
|
|
const TYPE_IMAGE = 'project:image';
|
2014-05-23 19:41:24 +02:00
|
|
|
const TYPE_ICON = 'project:icon';
|
2014-06-26 07:01:58 +02:00
|
|
|
const TYPE_COLOR = 'project:color';
|
2014-02-10 23:32:30 +01:00
|
|
|
|
|
|
|
// NOTE: This is deprecated, members are just a normal edge now.
|
|
|
|
const TYPE_MEMBERS = 'project:members';
|
2012-01-24 16:11:37 +01:00
|
|
|
|
2013-10-22 22:49:28 +02:00
|
|
|
public function getApplicationName() {
|
|
|
|
return 'project';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
|
|
|
return PhabricatorProjectPHIDTypeProject::TYPECONST;
|
2012-01-24 16:11:37 +01:00
|
|
|
}
|
|
|
|
|
2013-10-22 22:49:37 +02:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$req_phids = array();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorProjectTransaction::TYPE_MEMBERS:
|
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
|
|
|
$req_phids = array_merge($add, $rem);
|
|
|
|
break;
|
2014-02-10 23:32:30 +01:00
|
|
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
|
|
|
$req_phids[] = $old;
|
|
|
|
$req_phids[] = $new;
|
|
|
|
break;
|
2013-10-22 22:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
$author_handle = $this->renderHandleLink($this->getAuthorPHID());
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorProjectTransaction::TYPE_NAME:
|
|
|
|
if ($old === null) {
|
|
|
|
return pht(
|
|
|
|
'%s created this project.',
|
|
|
|
$author_handle);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s renamed this project from "%s" to "%s".',
|
|
|
|
$author_handle,
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
|
|
|
case PhabricatorProjectTransaction::TYPE_STATUS:
|
|
|
|
if ($old == 0) {
|
|
|
|
return pht(
|
|
|
|
'%s closed this project.',
|
|
|
|
$author_handle);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s reopened this project.',
|
|
|
|
$author_handle);
|
|
|
|
}
|
2014-02-10 23:32:30 +01:00
|
|
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
|
|
|
// TODO: Some day, it would be nice to show the images.
|
|
|
|
if (!$old) {
|
|
|
|
return pht(
|
|
|
|
'%s set this project\'s image to %s.',
|
|
|
|
$author_handle,
|
|
|
|
$this->renderHandleLink($new));
|
|
|
|
} else if (!$new) {
|
|
|
|
return pht(
|
|
|
|
'%s removed this project\'s image.',
|
|
|
|
$author_handle);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s updated this project\'s image from %s to %s.',
|
|
|
|
$author_handle,
|
|
|
|
$this->renderHandleLink($old),
|
|
|
|
$this->renderHandleLink($new));
|
|
|
|
}
|
2014-05-22 20:19:03 +02:00
|
|
|
|
2014-05-23 19:41:24 +02:00
|
|
|
case PhabricatorProjectTransaction::TYPE_ICON:
|
|
|
|
return pht(
|
|
|
|
'%s set this project\'s icon to %s.',
|
|
|
|
$author_handle,
|
|
|
|
PhabricatorProjectIcon::getLabel($new));
|
|
|
|
|
2014-06-26 07:01:58 +02:00
|
|
|
case PhabricatorProjectTransaction::TYPE_COLOR:
|
|
|
|
return pht(
|
|
|
|
'%s set this project\'s color to %s.',
|
|
|
|
$author_handle,
|
|
|
|
PHUITagView::getShadeName($new));
|
|
|
|
|
2014-05-22 20:19:03 +02:00
|
|
|
case PhabricatorProjectTransaction::TYPE_SLUGS:
|
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
|
|
|
|
|
|
|
if ($add && $rem) {
|
|
|
|
return pht(
|
|
|
|
'%s changed project hashtag(s), added %d: %s; removed %d: %s',
|
|
|
|
$author_handle,
|
|
|
|
count($add),
|
|
|
|
$this->renderSlugList($add),
|
|
|
|
count($rem),
|
|
|
|
$this->renderSlugList($rem));
|
|
|
|
} else if ($add) {
|
|
|
|
return pht(
|
|
|
|
'%s added %d project hashtag(s): %s',
|
|
|
|
$author_handle,
|
|
|
|
count($add),
|
|
|
|
$this->renderSlugList($add));
|
|
|
|
} else if ($rem) {
|
|
|
|
return pht(
|
|
|
|
'%s removed %d project hashtag(s): %s',
|
|
|
|
$author_handle,
|
|
|
|
count($rem),
|
|
|
|
$this->renderSlugList($rem));
|
|
|
|
}
|
|
|
|
|
2013-10-22 22:49:37 +02:00
|
|
|
case PhabricatorProjectTransaction::TYPE_MEMBERS:
|
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
|
|
|
|
|
|
|
if ($add && $rem) {
|
|
|
|
return pht(
|
|
|
|
'%s changed project member(s), added %d: %s; removed %d: %s',
|
|
|
|
$author_handle,
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
} else if ($add) {
|
|
|
|
if (count($add) == 1 && (head($add) == $this->getAuthorPHID())) {
|
|
|
|
return pht(
|
|
|
|
'%s joined this project.',
|
|
|
|
$author_handle);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s added %d project member(s): %s',
|
|
|
|
$author_handle,
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add));
|
|
|
|
}
|
|
|
|
} else if ($rem) {
|
|
|
|
if (count($rem) == 1 && (head($rem) == $this->getAuthorPHID())) {
|
|
|
|
return pht(
|
|
|
|
'%s left this project.',
|
|
|
|
$author_handle);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s removed %d project member(s): %s',
|
|
|
|
$author_handle,
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
2014-05-22 20:19:03 +02:00
|
|
|
private function renderSlugList($slugs) {
|
|
|
|
return implode(', ', $slugs);
|
|
|
|
}
|
2013-10-22 22:49:37 +02:00
|
|
|
|
2012-01-24 16:11:37 +01:00
|
|
|
}
|