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';
|
2013-07-15 01:02:04 +02:00
|
|
|
|
|
|
|
public function getApplicationName() {
|
|
|
|
return 'slowvote';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
|
|
|
return PhabricatorPHIDConstants::PHID_TYPE_POLL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
2013-07-15 13:20:10 +02:00
|
|
|
return new PhabricatorSlowvoteTransactionComment();
|
2013-07-15 01:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationObjectTypeName() {
|
|
|
|
return pht('vote');
|
|
|
|
}
|
|
|
|
|
2013-07-15 19:50:38 +02:00
|
|
|
public function shouldHide() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_RESPONSES:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE:
|
|
|
|
return ($old === null);
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::shouldHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_QUESTION:
|
|
|
|
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;
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION:
|
|
|
|
return pht(
|
|
|
|
'%s updated the description for this poll.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_RESPONSES:
|
|
|
|
// TODO: This could be more detailed
|
|
|
|
return pht(
|
|
|
|
'%s changed who can see the responses.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE:
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_QUESTION:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_RESPONSES:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE:
|
|
|
|
return 'edit';
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_QUESTION:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_DESCRIPTION:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_RESPONSES:
|
|
|
|
case PhabricatorSlowvoteTransaction::TYPE_SHUFFLE:
|
|
|
|
return PhabricatorTransactions::COLOR_BLUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getColor();
|
|
|
|
}
|
|
|
|
|
2013-07-15 01:02:04 +02:00
|
|
|
}
|
|
|
|
|