2013-07-15 01:02:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorSlowvoteTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
2013-07-15 19:50:38 +02:00
|
|
|
const TYPE_QUESTION = 'vote:question';
|
2013-07-15 01:02:04 +02:00
|
|
|
const TYPE_DESCRIPTION = 'vote:description';
|
2013-07-15 19:50:38 +02:00
|
|
|
const TYPE_RESPONSES = 'vote:responses';
|
|
|
|
const TYPE_SHUFFLE = 'vote:shuffle';
|
2014-04-24 21:00:31 +02:00
|
|
|
const TYPE_CLOSE = 'vote:close';
|
2013-07-15 01:02:04 +02:00
|
|
|
|
|
|
|
public function getApplicationName() {
|
|
|
|
return 'slowvote';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
2014-07-24 00:05:46 +02:00
|
|
|
return PhabricatorSlowvotePollPHIDType::TYPECONST;
|
2013-07-15 01:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
2013-07-15 13:20:10 +02:00
|
|
|
return new PhabricatorSlowvoteTransactionComment();
|
2013-07-15 01:02:04 +02:00
|
|
|
}
|
|
|
|
|
2013-07-15 19:50:38 +02:00
|
|
|
public function shouldHide() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_DESCRIPTION:
|
|
|
|
case self::TYPE_RESPONSES:
|
|
|
|
case self::TYPE_SHUFFLE:
|
|
|
|
case self::TYPE_CLOSE:
|
2013-07-15 19:50:38 +02:00
|
|
|
return ($old === null);
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::shouldHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_QUESTION:
|
2013-07-15 19:50:38 +02:00
|
|
|
if ($old === null) {
|
|
|
|
return pht(
|
|
|
|
'%s created this poll.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s changed the poll question from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_DESCRIPTION:
|
2013-07-15 19:50:38 +02:00
|
|
|
return pht(
|
|
|
|
'%s updated the description for this poll.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_RESPONSES:
|
2013-07-15 19:50:38 +02:00
|
|
|
// TODO: This could be more detailed
|
|
|
|
return pht(
|
|
|
|
'%s changed who can see the responses.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_SHUFFLE:
|
2013-07-15 19:50:38 +02:00
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s made poll responses appear in a random order.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s made poll responses appear in a fixed order.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
2014-04-24 21:00:31 +02:00
|
|
|
break;
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_CLOSE:
|
2014-04-24 21:00:31 +02:00
|
|
|
if ($new) {
|
|
|
|
return pht(
|
|
|
|
'%s closed this poll.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s reopened this poll.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
|
2013-07-15 19:50:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_QUESTION:
|
2014-04-22 17:25:54 +02:00
|
|
|
if ($old === null) {
|
|
|
|
return 'fa-plus';
|
|
|
|
} else {
|
|
|
|
return 'fa-pencil';
|
|
|
|
}
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_DESCRIPTION:
|
|
|
|
case self::TYPE_RESPONSES:
|
2014-04-22 17:25:54 +02:00
|
|
|
return 'fa-pencil';
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_SHUFFLE:
|
2014-04-22 17:25:54 +02:00
|
|
|
return 'fa-refresh';
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_CLOSE:
|
2014-04-24 21:00:31 +02:00
|
|
|
if ($new) {
|
|
|
|
return 'fa-ban';
|
|
|
|
} else {
|
|
|
|
return 'fa-pencil';
|
|
|
|
}
|
2013-07-15 19:50:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_QUESTION:
|
|
|
|
case self::TYPE_DESCRIPTION:
|
|
|
|
case self::TYPE_RESPONSES:
|
|
|
|
case self::TYPE_SHUFFLE:
|
|
|
|
case self::TYPE_CLOSE:
|
2013-07-15 19:50:38 +02:00
|
|
|
return PhabricatorTransactions::COLOR_BLUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getColor();
|
|
|
|
}
|
|
|
|
|
2013-07-15 20:07:37 +02:00
|
|
|
public function hasChangeDetails() {
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-05-13 22:50:28 +02:00
|
|
|
case self::TYPE_DESCRIPTION:
|
2013-07-15 20:07:37 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return parent::hasChangeDetails();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
2015-01-12 16:20:20 +01:00
|
|
|
return $this->renderTextCorpusChangeDetails(
|
|
|
|
$viewer,
|
|
|
|
$this->getOldValue(),
|
|
|
|
$this->getNewValue());
|
2013-07-15 20:07:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-15 01:02:04 +02:00
|
|
|
}
|