2013-01-25 02:23:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
|
|
|
|
|
2015-06-08 01:54:53 +02:00
|
|
|
const TYPE_FILES = 'files';
|
|
|
|
const TYPE_TITLE = 'title';
|
|
|
|
const TYPE_PARTICIPANTS = 'participants';
|
|
|
|
const TYPE_DATE_MARKER = 'date-marker';
|
|
|
|
const TYPE_PICTURE = 'picture';
|
|
|
|
const TYPE_PICTURE_CROP = 'picture-crop';
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
public function getApplicationName() {
|
|
|
|
return 'conpherence';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
2014-07-24 00:05:46 +02:00
|
|
|
return PhabricatorConpherenceThreadPHIDType::TYPECONST;
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
|
|
return new ConpherenceTransactionComment();
|
|
|
|
}
|
|
|
|
|
2013-04-02 18:32:40 +02:00
|
|
|
public function getNoEffectDescription() {
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PARTICIPANTS:
|
2013-04-02 18:32:40 +02:00
|
|
|
return pht(
|
|
|
|
'You can not add a participant who has already been added.');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getNoEffectDescription();
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
public function shouldHide() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PARTICIPANTS:
|
2013-01-25 02:23:05 +01:00
|
|
|
return ($old === null);
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_TITLE:
|
|
|
|
case self::TYPE_PICTURE:
|
|
|
|
case self::TYPE_DATE_MARKER:
|
2013-01-25 02:23:05 +01:00
|
|
|
return false;
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_FILES:
|
2013-05-23 01:05:47 +02:00
|
|
|
return true;
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PICTURE_CROP:
|
2013-01-25 22:04:40 +01:00
|
|
|
return true;
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::shouldHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_TITLE:
|
2015-03-27 00:37:32 +01:00
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PICTURE:
|
2015-06-25 22:14:20 +02:00
|
|
|
return $this->getRoomTitle();
|
2015-03-27 00:37:32 +01:00
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_FILES:
|
2013-03-08 19:40:06 +01:00
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
|
|
|
|
|
|
|
if ($add && $rem) {
|
|
|
|
$title = pht(
|
|
|
|
'%s edited files(s), added %d and removed %d.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
count($rem));
|
|
|
|
} else if ($add) {
|
|
|
|
$title = pht(
|
|
|
|
'%s added %d files(s).',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add));
|
|
|
|
} else {
|
|
|
|
$title = pht(
|
|
|
|
'%s removed %d file(s).',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($rem));
|
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PARTICIPANTS:
|
2013-01-25 02:23:05 +01:00
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
|
|
|
|
|
|
|
if ($add && $rem) {
|
|
|
|
$title = pht(
|
|
|
|
'%s edited participant(s), added %d: %s; removed %d: %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
} else if ($add) {
|
|
|
|
$title = pht(
|
|
|
|
'%s added %d participant(s): %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add));
|
|
|
|
} else {
|
|
|
|
$title = pht(
|
2013-03-08 19:40:06 +01:00
|
|
|
'%s removed %d participant(s): %s.',
|
2013-01-25 02:23:05 +01:00
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
2015-03-27 00:37:32 +01:00
|
|
|
private function getRoomTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_TITLE:
|
2015-03-27 00:37:32 +01:00
|
|
|
if ($old && $new) {
|
|
|
|
$title = pht(
|
|
|
|
'%s renamed this room from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
} else if ($old) {
|
|
|
|
$title = pht(
|
|
|
|
'%s deleted the room name "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$old);
|
|
|
|
} else {
|
|
|
|
$title = pht(
|
|
|
|
'%s named this room "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$new);
|
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PICTURE:
|
2015-05-04 22:52:22 +02:00
|
|
|
return pht(
|
|
|
|
'%s updated the room image.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
break;
|
2015-03-27 00:37:32 +01:00
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the visibility of this room from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderPolicyName($old, 'old'),
|
|
|
|
$this->renderPolicyName($new, 'new'));
|
|
|
|
break;
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the edit policy of this room from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderPolicyName($old, 'old'),
|
|
|
|
$this->renderPolicyName($new, 'new'));
|
|
|
|
break;
|
|
|
|
case PhabricatorTransactions::TYPE_JOIN_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the join policy of this room from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderPolicyName($old, 'old'),
|
|
|
|
$this->renderPolicyName($new, 'new'));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = parent::getRequiredHandlePHIDs();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$phids[] = $this->getAuthorPHID();
|
|
|
|
switch ($this->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_TITLE:
|
|
|
|
case self::TYPE_PICTURE:
|
|
|
|
case self::TYPE_FILES:
|
|
|
|
case self::TYPE_DATE_MARKER:
|
2013-01-25 02:23:05 +01:00
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case self::TYPE_PARTICIPANTS:
|
2013-01-25 02:23:05 +01:00
|
|
|
$phids = array_merge($phids, $this->getOldValue());
|
|
|
|
$phids = array_merge($phids, $this->getNewValue());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
}
|