Changeset View
Changeset View
Standalone View
Standalone View
src/applications/audit/storage/PhabricatorAuditTransaction.php
<?php | <?php | ||||
final class PhabricatorAuditTransaction | final class PhabricatorAuditTransaction | ||||
extends PhabricatorApplicationTransaction { | extends PhabricatorApplicationTransaction { | ||||
const TYPE_COMMIT = 'audit:commit'; | const TYPE_COMMIT = 'audit:commit'; | ||||
const TYPE_INLINEDONE = 'audit:inlinedone'; | |||||
const MAILTAG_ACTION_CONCERN = 'audit-action-concern'; | const MAILTAG_ACTION_CONCERN = 'audit-action-concern'; | ||||
const MAILTAG_ACTION_ACCEPT = 'audit-action-accept'; | const MAILTAG_ACTION_ACCEPT = 'audit-action-accept'; | ||||
const MAILTAG_ACTION_RESIGN = 'audit-action-resign'; | const MAILTAG_ACTION_RESIGN = 'audit-action-resign'; | ||||
const MAILTAG_ACTION_CLOSE = 'audit-action-close'; | const MAILTAG_ACTION_CLOSE = 'audit-action-close'; | ||||
const MAILTAG_ADD_AUDITORS = 'audit-add-auditors'; | const MAILTAG_ADD_AUDITORS = 'audit-add-auditors'; | ||||
const MAILTAG_ADD_CCS = 'audit-add-ccs'; | const MAILTAG_ADD_CCS = 'audit-add-ccs'; | ||||
const MAILTAG_COMMENT = 'audit-comment'; | const MAILTAG_COMMENT = 'audit-comment'; | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
} else { | } else { | ||||
$title = pht( | $title = pht( | ||||
'%s committed %s.', | '%s committed %s.', | ||||
$committer, | $committer, | ||||
$commit); | $commit); | ||||
} | } | ||||
return $title; | return $title; | ||||
case self::TYPE_INLINEDONE: | |||||
$done = 0; | |||||
$undone = 0; | |||||
foreach ($new as $phid => $state) { | |||||
if ($state == PhabricatorInlineCommentInterface::STATE_DONE) { | |||||
$done++; | |||||
} else { | |||||
$undone++; | |||||
} | |||||
} | |||||
if ($done && $undone) { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as done and %s inline comment(s) '. | |||||
'as not done.', | |||||
$author_handle, | |||||
new PhutilNumber($done), | |||||
new PhutilNumber($undone)); | |||||
} else if ($done) { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as done.', | |||||
$author_handle, | |||||
new PhutilNumber($done)); | |||||
} else { | |||||
return pht( | |||||
'%s marked %s inline comment(s) as not done.', | |||||
$author_handle, | |||||
new PhutilNumber($undone)); | |||||
} | |||||
break; | |||||
case PhabricatorAuditActionConstants::INLINE: | case PhabricatorAuditActionConstants::INLINE: | ||||
return pht( | return pht( | ||||
'%s added inline comments.', | '%s added inline comments.', | ||||
$author_handle); | $author_handle); | ||||
case PhabricatorAuditActionConstants::ADD_CCS: | case PhabricatorAuditActionConstants::ADD_CCS: | ||||
if ($add && $rem) { | if ($add && $rem) { | ||||
return pht( | return pht( | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | public function getBodyForFeed(PhabricatorFeedStory $story) { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_COMMIT: | case self::TYPE_COMMIT: | ||||
$data = $this->getNewValue(); | $data = $this->getNewValue(); | ||||
return $story->renderSummary($data['summary']); | return $story->renderSummary($data['summary']); | ||||
} | } | ||||
return parent::getBodyForFeed($story); | return parent::getBodyForFeed($story); | ||||
} | } | ||||
public function isInlineCommentTransaction() { | |||||
public function shouldGenerateOldValue() { | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_INLINEDONE: | |||||
return false; | |||||
} | |||||
return parent::shouldGenerateOldValue(); | |||||
} | |||||
// TODO: These two mail methods can likely be abstracted by introducing a | |||||
// formal concept of "inline comment" transactions. | |||||
public function shouldHideForMail(array $xactions) { | |||||
$type_inline = PhabricatorAuditActionConstants::INLINE; | |||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case $type_inline: | case PhabricatorAuditActionConstants::INLINE: | ||||
foreach ($xactions as $xaction) { | |||||
if ($xaction->getTransactionType() != $type_inline) { | |||||
return true; | return true; | ||||
} | } | ||||
} | |||||
return ($this !== head($xactions)); | |||||
} | |||||
return parent::shouldHideForMail($xactions); | return parent::isInlineCommentTransaction(); | ||||
} | } | ||||
public function getBodyForMail() { | public function getBodyForMail() { | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorAuditActionConstants::INLINE: | |||||
return null; | |||||
case self::TYPE_COMMIT: | case self::TYPE_COMMIT: | ||||
$data = $this->getNewValue(); | $data = $this->getNewValue(); | ||||
return $data['description']; | return $data['description']; | ||||
} | } | ||||
return parent::getBodyForMail(); | return parent::getBodyForMail(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |