2013-01-25 02:23:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
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()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
return ($old === null);
|
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
2013-05-30 23:24:50 +02:00
|
|
|
case ConpherenceTransactionType::TYPE_DATE_MARKER:
|
2013-01-25 02:23:05 +01:00
|
|
|
return false;
|
2013-01-25 22:04:40 +01:00
|
|
|
case ConpherenceTransactionType::TYPE_FILES:
|
2013-05-23 01:05:47 +02:00
|
|
|
return true;
|
|
|
|
// we used to have them so just always hide
|
|
|
|
case ConpherenceTransactionType::TYPE_PICTURE:
|
2013-02-06 23:03:52 +01:00
|
|
|
case ConpherenceTransactionType::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()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
2013-02-07 20:17:20 +01:00
|
|
|
if ($old && $new) {
|
2013-01-25 02:23:05 +01:00
|
|
|
$title = pht(
|
2015-03-12 19:21:12 +01:00
|
|
|
'%s renamed this Thread from "%s" to "%s".',
|
2013-01-25 02:23:05 +01:00
|
|
|
$this->renderHandleLink($author_phid),
|
2013-02-13 23:50:15 +01:00
|
|
|
$old,
|
|
|
|
$new);
|
2013-02-07 20:17:20 +01:00
|
|
|
} else if ($old) {
|
|
|
|
$title = pht(
|
2015-03-12 19:21:12 +01:00
|
|
|
'%s deleted the Thread name "%s".',
|
2013-02-07 20:17:20 +01:00
|
|
|
$this->renderHandleLink($author_phid),
|
2013-02-13 23:50:15 +01:00
|
|
|
$old);
|
2013-01-25 02:23:05 +01:00
|
|
|
} else {
|
|
|
|
$title = pht(
|
2015-03-12 19:21:12 +01:00
|
|
|
'%s named this Thread "%s".',
|
2013-01-25 02:23:05 +01:00
|
|
|
$this->renderHandleLink($author_phid),
|
2013-02-13 23:50:15 +01:00
|
|
|
$new);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
case ConpherenceTransactionType::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;
|
2013-01-25 02:23:05 +01:00
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
$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();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = parent::getRequiredHandlePHIDs();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$phids[] = $this->getAuthorPHID();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
2013-02-06 23:03:52 +01:00
|
|
|
case ConpherenceTransactionType::TYPE_FILES:
|
2013-05-30 23:24:50 +02:00
|
|
|
case ConpherenceTransactionType::TYPE_DATE_MARKER:
|
2013-01-25 02:23:05 +01:00
|
|
|
break;
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
$phids = array_merge($phids, $this->getOldValue());
|
|
|
|
$phids = array_merge($phids, $this->getNewValue());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|