1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Adding awarder info to badge cards displayed on user profile pages

Summary: Ref T8940

Test Plan: Award badge, open recipient profile page, badge should appear in badges list, and flipping the badge card should show who awarded it.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: chad, Korvin

Maniphest Tasks: T8940

Differential Revision: https://secure.phabricator.com/D15570
This commit is contained in:
lkassianik 2016-04-01 17:52:52 -07:00
parent 839e7e2fc6
commit 219357aa9f

View file

@ -181,26 +181,48 @@ final class PhabricatorPeopleProfileViewController
return null; return null;
} }
$badge_phids = $user->getBadgePHIDs(); $awards = array();
if ($badge_phids) { $badges = array();
if ($user->getBadgePHIDs()) {
$awards = id(new PhabricatorBadgesAwardQuery())
->setViewer($viewer)
->withRecipientPHIDs(array($user->getPHID()))
->execute();
$awards = mpull($awards, null, 'getBadgePHID');
$badge_phids = mpull($awards, 'getBadgePHID');
$badges = id(new PhabricatorBadgesQuery()) $badges = id(new PhabricatorBadgesQuery())
->setViewer($viewer) ->setViewer($viewer)
->withPHIDs($badge_phids) ->withPHIDs($badge_phids)
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE)) ->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
->execute(); ->execute();
} else { $badges = mpull($badges, null, 'getPHID');
$badges = array();
} }
if (count($badges)) { if (count($badges)) {
$flex = new PHUIBadgeBoxView(); $flex = new PHUIBadgeBoxView();
foreach ($badges as $badge) { foreach ($badges as $badge) {
$item = id(new PHUIBadgeView()) if ($badge) {
->setIcon($badge->getIcon()) $awarder_info = array();
->setHeader($badge->getName())
->setSubhead($badge->getFlavor()) $award = idx($awards, $badge->getPHID(), null);
->setQuality($badge->getQuality()); $awarder_phid = $award->getAwarderPHID();
$flex->addItem($item); $awarder_handle = $viewer->renderHandle($awarder_phid);
$awarder_info = pht(
'Awarded by %s',
$awarder_handle->render());
$item = id(new PHUIBadgeView())
->setIcon($badge->getIcon())
->setHeader($badge->getName())
->setSubhead($badge->getFlavor())
->setQuality($badge->getQuality())
->addByLine($awarder_info);
$flex->addItem($item);
}
} }
} else { } else {
$error = id(new PHUIBoxView()) $error = id(new PHUIBoxView())