public function loadResults()
 {
     $viewer = $this->getViewer();
     $raw_query = $this->getRawQuery();
     $params = $this->getParameters();
     $recipient_phid = $params['recipientPHID'];
     $badges = id(new PhabricatorBadgesQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     $awards = id(new PhabricatorBadgesAwardQuery())->setViewer($viewer)->withAwarderPHIDs(array($viewer->getPHID()))->withRecipientPHIDs(array($recipient_phid))->execute();
     $awards = mpull($awards, null, 'getBadgePHID');
     $results = array();
     foreach ($badges as $badge) {
         $closed = null;
         $badge_awards = idx($awards, $badge->getPHID(), null);
         if ($badge_awards) {
             $closed = pht('Already awarded');
         }
         $status = $badge->getStatus();
         if ($status === PhabricatorBadgesBadge::STATUS_ARCHIVED) {
             $closed = pht('Archived');
         }
         $results[] = id(new PhabricatorTypeaheadResult())->setName($badge->getName())->setIcon($badge->getIcon())->setColor(PhabricatorBadgesQuality::getQualityColor($badge->getQuality()))->setClosed($closed)->setPHID($badge->getPHID());
     }
     $results = $this->filterResultsAgainstTokens($results);
     return $results;
 }
Ejemplo n.º 2
0
 protected function getTagAttributes()
 {
     require_celerity_resource('phui-badge-view-css');
     Javelin::initBehavior('phabricator-tooltips');
     $classes = array();
     $classes[] = 'phui-badge-mini';
     if ($this->quality) {
         $quality_color = PhabricatorBadgesQuality::getQualityColor($this->quality);
         $classes[] = 'phui-badge-mini-' . $quality_color;
     }
     return array('class' => implode(' ', $classes), 'sigil' => 'has-tooltip', 'href' => $this->href, 'meta' => array('tip' => $this->header, 'align' => $this->tipDirection, 'size' => 300));
 }
Ejemplo n.º 3
0
 private function getQualityColor()
 {
     return PhabricatorBadgesQuality::getQualityColor($this->quality);
 }