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

Fix bad rendering pathway on user profiles for viewers without Badges application

Summary: Fixes T10275. We'd fatal on `$flex` not being defined.

Test Plan: Uninstalled badges, viewed profile. Before: fatal; now: no badges element appears but profile renders properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10275

Differential Revision: https://secure.phabricator.com/D15182
This commit is contained in:
epriestley 2016-02-04 07:13:47 -08:00
parent 2f0571923c
commit 42954bc5ac

View file

@ -176,39 +176,40 @@ final class PhabricatorPeopleProfileViewController
return $box;
}
private function buildBadgesView(
PhabricatorUser $user) {
private function buildBadgesView(PhabricatorUser $user) {
$viewer = $this->getViewer();
$class = 'PhabricatorBadgesApplication';
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$badge_phids = $user->getBadgePHIDs();
if ($badge_phids) {
$badges = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withPHIDs($badge_phids)
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
->execute();
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return null;
}
$flex = new PHUIBadgeBoxView();
foreach ($badges as $badge) {
$item = id(new PHUIBadgeView())
->setIcon($badge->getIcon())
->setHeader($badge->getName())
->setSubhead($badge->getFlavor())
->setQuality($badge->getQuality());
$flex->addItem($item);
}
$badge_phids = $user->getBadgePHIDs();
if ($badge_phids) {
$badges = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withPHIDs($badge_phids)
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
->execute();
} else {
$error = id(new PHUIBoxView())
->addClass('mlb')
->appendChild(pht('User does not have any badges.'));
$flex = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild($error);
$flex = new PHUIBadgeBoxView();
foreach ($badges as $badge) {
$item = id(new PHUIBadgeView())
->setIcon($badge->getIcon())
->setHeader($badge->getName())
->setSubhead($badge->getFlavor())
->setQuality($badge->getQuality());
$flex->addItem($item);
}
} else {
$error = id(new PHUIBoxView())
->addClass('mlb')
->appendChild(pht('User does not have any badges.'));
$flex = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild($error);
}
$box = id(new PHUIObjectBoxView())