本文整理汇总了PHP中PhabricatorUser::getBadgePHIDs方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::getBadgePHIDs方法的具体用法?PHP PhabricatorUser::getBadgePHIDs怎么用?PHP PhabricatorUser::getBadgePHIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorUser
的用法示例。
在下文中一共展示了PhabricatorUser::getBadgePHIDs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildBadges
private function buildBadges(PhabricatorUser $user, $viewer)
{
$class = 'PhabricatorBadgesApplication';
$items = array();
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$badge_phids = $user->getBadgePHIDs();
if ($badge_phids) {
$badges = id(new PhabricatorBadgesQuery())->setViewer($viewer)->withPHIDs($badge_phids)->execute();
foreach ($badges as $badge) {
$items[] = id(new PHUIBadgeMiniView())->setIcon($badge->getIcon())->setHeader($badge->getName())->setQuality($badge->getQuality());
}
}
}
return $items;
}
示例2: buildBadgesView
private function buildBadgesView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$class = 'PhabricatorBadgesApplication';
$box = null;
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();
$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);
}
$box = id(new PHUIObjectBoxView())->setHeaderText(pht('Badges'))->appendChild($flex)->setBackground(PHUIBoxView::GREY);
}
}
return $box;
}
示例3: buildBadgesView
private function buildBadgesView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$class = 'PhabricatorBadgesApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return null;
}
$badge_phids = $user->getBadgePHIDs();
if ($badge_phids) {
$badges = id(new PhabricatorBadgesQuery())->setViewer($viewer)->withPHIDs($badge_phids)->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))->execute();
$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())->setHeaderText(pht('Badges'))->addClass('project-view-badges')->appendChild($flex)->setBackground(PHUIObjectBoxView::GREY);
return $box;
}
示例4: buildBadgesView
private function buildBadgesView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$class = 'PhabricatorBadgesApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return null;
}
$awards = array();
$badges = array();
if ($user->getBadgePHIDs()) {
$awards = id(new PhabricatorBadgesAwardQuery())->setViewer($viewer)->withRecipientPHIDs(array($user->getPHID()))->execute();
$awards = mpull($awards, null, 'getBadgePHID');
$badges = array();
foreach ($awards as $award) {
$badge = $award->getBadge();
if ($badge->getStatus() == PhabricatorBadgesBadge::STATUS_ACTIVE) {
$badges[$award->getBadgePHID()] = $badge;
}
}
}
if (count($badges)) {
$flex = new PHUIBadgeBoxView();
foreach ($badges as $badge) {
if ($badge) {
$awarder_info = array();
$award = idx($awards, $badge->getPHID(), null);
$awarder_phid = $award->getAwarderPHID();
$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())->setHref($badge->getViewURI())->addByLine($awarder_info);
$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);
}
// Best option?
$badges = id(new PhabricatorBadgesQuery())->setViewer($viewer)->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
$button = id(new PHUIButtonView())->setTag('a')->setIcon('fa-plus')->setText(pht('Award'))->setWorkflow(true)->setHref('/badges/award/' . $user->getID() . '/');
$can_award = false;
if (count($badges)) {
$can_award = true;
}
$header = id(new PHUIHeaderView())->setHeader(pht('Badges'));
if (count($badges)) {
$header->addActionLink($button);
}
$box = id(new PHUIObjectBoxView())->setHeader($header)->addClass('project-view-badges')->appendChild($flex)->setBackground(PHUIObjectBoxView::GREY);
return $box;
}