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;
|
return $box;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildBadgesView(
|
private function buildBadgesView(PhabricatorUser $user) {
|
||||||
PhabricatorUser $user) {
|
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$class = 'PhabricatorBadgesApplication';
|
$class = 'PhabricatorBadgesApplication';
|
||||||
|
|
||||||
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
||||||
$badge_phids = $user->getBadgePHIDs();
|
return null;
|
||||||
if ($badge_phids) {
|
}
|
||||||
$badges = id(new PhabricatorBadgesQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withPHIDs($badge_phids)
|
|
||||||
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$flex = new PHUIBadgeBoxView();
|
$badge_phids = $user->getBadgePHIDs();
|
||||||
foreach ($badges as $badge) {
|
if ($badge_phids) {
|
||||||
$item = id(new PHUIBadgeView())
|
$badges = id(new PhabricatorBadgesQuery())
|
||||||
->setIcon($badge->getIcon())
|
->setViewer($viewer)
|
||||||
->setHeader($badge->getName())
|
->withPHIDs($badge_phids)
|
||||||
->setSubhead($badge->getFlavor())
|
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
|
||||||
->setQuality($badge->getQuality());
|
->execute();
|
||||||
$flex->addItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
$flex = new PHUIBadgeBoxView();
|
||||||
$error = id(new PHUIBoxView())
|
foreach ($badges as $badge) {
|
||||||
->addClass('mlb')
|
$item = id(new PHUIBadgeView())
|
||||||
->appendChild(pht('User does not have any badges.'));
|
->setIcon($badge->getIcon())
|
||||||
$flex = id(new PHUIInfoView())
|
->setHeader($badge->getName())
|
||||||
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
|
->setSubhead($badge->getFlavor())
|
||||||
->appendChild($error);
|
->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())
|
$box = id(new PHUIObjectBoxView())
|
||||||
|
|
Loading…
Reference in a new issue