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:
parent
2f0571923c
commit
42954bc5ac
1 changed files with 27 additions and 26 deletions
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue