From 4163da9d624fcdf881a4d3d181cec1511df5b1a1 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Thu, 26 Sep 2013 17:27:21 -0700 Subject: [PATCH] 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 --- .../PhabricatorApplicationTransaction.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index b1c96f1dc7..3ed95c6661 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -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);