From e6d2e66ea250a78db5f056253dcba65240ba62e8 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Sat, 26 Mar 2016 19:36:13 -0700 Subject: [PATCH] Adding basic transaction titles to awarding/revoking badges Summary: Ref T10677, awarding/revoking a badge should create timeline entries with titles that are more clear (excludes homepage feed stories) Test Plan: Award/revoke a badge to single or multiple users. See timeline entries that reflect those actions. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Maniphest Tasks: T10677 Differential Revision: https://secure.phabricator.com/D15533 --- .../storage/PhabricatorBadgesTransaction.php | 40 +++++++++++++++++++ .../PhabricatorUSEnglishTranslation.php | 14 +++++++ 2 files changed, 54 insertions(+) diff --git a/src/applications/badges/storage/PhabricatorBadgesTransaction.php b/src/applications/badges/storage/PhabricatorBadgesTransaction.php index f25c629c96..dc92d1fc8f 100644 --- a/src/applications/badges/storage/PhabricatorBadgesTransaction.php +++ b/src/applications/badges/storage/PhabricatorBadgesTransaction.php @@ -109,6 +109,26 @@ final class PhabricatorBadgesTransaction $qual_new); } break; + case self::TYPE_AWARD: + if (!is_array($new)) { + $new = array(); + } + $handles = $this->renderHandleList($new); + return pht( + '%s awarded this badge to %s recipient(s): %s.', + $this->renderHandleLink($author_phid), + new PhutilNumber(count($new)), + $handles); + case self::TYPE_REVOKE: + if (!is_array($new)) { + $new = array(); + } + $handles = $this->renderHandleList($new); + return pht( + '%s revoked this badge from %s recipient(s): %s.', + $this->renderHandleLink($author_phid), + new PhutilNumber(count($new)), + $handles); } return parent::getTitle(); @@ -223,4 +243,24 @@ final class PhabricatorBadgesTransaction $this->getOldValue(), $this->getNewValue()); } + + public function getRequiredHandlePHIDs() { + $phids = parent::getRequiredHandlePHIDs(); + + $type = $this->getTransactionType(); + switch ($type) { + case self::TYPE_AWARD: + case self::TYPE_REVOKE: + $new = $this->getNewValue(); + if (!is_array($new)) { + $new = array(); + } + foreach ($new as $phid) { + $phids[] = $phid; + } + break; + } + + return $phids; + } } diff --git a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php index 93027ce5d6..54e69476d4 100644 --- a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php @@ -1528,6 +1528,20 @@ final class PhabricatorUSEnglishTranslation '%s removed watchers for %3$s: %4$s.', ), ), + + '%s awarded this badge to %s recipient(s): %s.' => array( + array( + '%s awarded this badge to recipient: %3$s.', + '%s awarded this badge to recipients: %3$s.', + ), + ), + + '%s revoked this badge from %s recipient(s): %s.' => array( + array( + '%s revoked this badge from recipient: %3$s.', + '%s revoked this badge from recipients: %3$s.', + ), + ), ); }