2013-08-02 17:28:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HeraldRuleTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
|
|
|
const TYPE_EDIT = 'herald:edit';
|
2013-10-07 02:10:29 +02:00
|
|
|
const TYPE_DISABLE = 'herald:disable';
|
2013-08-02 17:28:55 +02:00
|
|
|
|
|
|
|
public function getApplicationName() {
|
|
|
|
return 'herald';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
|
|
|
return HeraldPHIDTypeRule::TYPECONST;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
|
|
return new HeraldRuleTransactionComment();
|
|
|
|
}
|
|
|
|
|
2013-10-07 02:10:29 +02:00
|
|
|
public function getColor() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_DISABLE:
|
|
|
|
if ($new) {
|
|
|
|
return 'red';
|
|
|
|
} else {
|
|
|
|
return 'green';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getActionName() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_DISABLE:
|
|
|
|
if ($new) {
|
|
|
|
return pht('Disabled');
|
|
|
|
} else {
|
|
|
|
return pht('Enabled');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getActionName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_DISABLE:
|
|
|
|
if ($new) {
|
|
|
|
return 'disable';
|
|
|
|
} else {
|
|
|
|
return 'enable';
|
|
|
|
}
|
|
|
|
}
|
2013-08-02 17:28:55 +02:00
|
|
|
|
2013-10-07 02:10:29 +02:00
|
|
|
return parent::getIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_DISABLE:
|
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s disabled this rule.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s enabled this rule.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|