1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-02 02:40:58 +01:00

Policy - make policy transactions render better in email

Summary: right now you get sent an email with a broken link 'cuz the email is plain text if you edit something with the edit policy being a project.

Test Plan: edited a legalpad document edit policy repeatedly to various projects. observed good emails via bin/mail debug tool. object page still looked good too

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7149
This commit is contained in:
Bob Trahan 2013-09-26 17:27:21 -07:00
parent 874a9b7fe3
commit 4163da9d62

View file

@ -202,6 +202,18 @@ abstract class PhabricatorApplicationTransaction
return phutil_implode_html(', ', $links);
}
public function renderPolicyName($phid) {
$policy = PhabricatorPolicy::newFromPolicyAndHandle(
$phid,
$this->getHandleIfExists($phid));
if ($this->renderingTarget == self::TARGET_HTML) {
$output = $policy->renderDescription();
} else {
$output = hsprintf('%s', $policy->getFullName());
}
return $output;
}
public function getIcon() {
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_COMMENT:
@ -281,23 +293,15 @@ abstract class PhabricatorApplicationTransaction
'%s changed the visibility of this %s from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->getApplicationObjectTypeName(),
PhabricatorPolicy::newFromPolicyAndHandle(
$old,
$this->getHandleIfExists($old))->renderDescription(),
PhabricatorPolicy::newFromPolicyAndHandle(
$new,
$this->getHandleIfExists($new))->renderDescription());
$this->renderPolicyName($old),
$this->renderPolicyName($new));
case PhabricatorTransactions::TYPE_EDIT_POLICY:
return pht(
'%s changed the edit policy of this %s from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->getApplicationObjectTypeName(),
PhabricatorPolicy::newFromPolicyAndHandle(
$old,
$this->getHandleIfExists($old))->renderDescription(),
PhabricatorPolicy::newFromPolicyAndHandle(
$new,
$this->getHandleIfExists($new))->renderDescription());
$this->renderPolicyName($old),
$this->renderPolicyName($new));
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);