@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Badges ... on your profile

Summary: Shows badges on profile if you have them. Check if app is installed, show badges.

Test Plan:
Gave myself a liberal selection of badge. Gave notchad one badge. Gave chadtwo absolutely nothing.

{F651069}

Reviewers: btrahan, lpriestley, epriestley

Reviewed By: epriestley

Subscribers: johnny-bit, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13692

+71
+37
src/applications/people/controller/PhabricatorPeopleProfileController.php
··· 23 23 $user = id(new PhabricatorPeopleQuery()) 24 24 ->setViewer($viewer) 25 25 ->withUsernames(array($this->username)) 26 + ->needBadges(true) 26 27 ->needProfileImage(true) 27 28 ->needAvailability(true) 28 29 ->executeOne(); ··· 157 158 ->setHeaderText(pht('Recent Activity')) 158 159 ->appendChild($this->buildPeopleFeed($user, $viewer)); 159 160 161 + $badges = $this->buildBadgesView($user); 162 + 160 163 $nav = $this->buildIconNavView($user); 161 164 $nav->selectFilter("{$name}/"); 162 165 $nav->appendChild($object_box); 166 + $nav->appendChild($badges); 163 167 $nav->appendChild($feed); 164 168 165 169 return $this->buildApplicationPage( ··· 185 189 $field_list->appendFieldsToPropertyList($user, $viewer, $view); 186 190 187 191 return $view; 192 + } 193 + 194 + private function buildBadgesView( 195 + PhabricatorUser $user) { 196 + 197 + $viewer = $this->getViewer(); 198 + $class = 'PhabricatorBadgesApplication'; 199 + $box = null; 200 + 201 + if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { 202 + $badge_phids = $user->getBadgePHIDs(); 203 + if ($badge_phids) { 204 + $badges = id(new PhabricatorBadgesQuery()) 205 + ->setViewer($viewer) 206 + ->withPHIDs($badge_phids) 207 + ->execute(); 208 + 209 + $flex = new PHUIBadgeBoxView(); 210 + foreach ($badges as $badge) { 211 + $item = id(new PHUIBadgeView()) 212 + ->setIcon($badge->getIcon()) 213 + ->setHeader($badge->getName()) 214 + ->setSubhead($badge->getFlavor()) 215 + ->setQuality($badge->getQuality()); 216 + $flex->addItem($item); 217 + } 218 + 219 + $box = id(new PHUIObjectBoxView()) 220 + ->setHeaderText(pht('Badges')) 221 + ->appendChild($flex); 222 + } 223 + } 224 + return $box; 188 225 } 189 226 190 227 private function buildPeopleFeed(
+24
src/applications/people/query/PhabricatorPeopleQuery.php
··· 22 22 private $needProfile; 23 23 private $needProfileImage; 24 24 private $needAvailability; 25 + private $needBadges; 25 26 26 27 public function withIDs(array $ids) { 27 28 $this->ids = $ids; ··· 113 114 return $this; 114 115 } 115 116 117 + public function needBadges($need) { 118 + $this->needBadges = $need; 119 + return $this; 120 + } 121 + 116 122 public function newResultObject() { 117 123 return new PhabricatorUser(); 118 124 } ··· 144 150 } 145 151 146 152 $user->attachUserProfile($profile); 153 + } 154 + } 155 + 156 + if ($this->needBadges) { 157 + $edge_query = id(new PhabricatorEdgeQuery()) 158 + ->withSourcePHIDs(mpull($users, 'getPHID')) 159 + ->withEdgeTypes( 160 + array( 161 + PhabricatorRecipientHasBadgeEdgeType::EDGECONST, 162 + )); 163 + $edge_query->execute(); 164 + 165 + foreach ($users as $user) { 166 + $phids = $edge_query->getDestinationPHIDs( 167 + array( 168 + $user->getPHID(), 169 + )); 170 + $user->attachBadgePHIDs($phids); 147 171 } 148 172 } 149 173
+10
src/applications/people/storage/PhabricatorUser.php
··· 55 55 private $preferences = null; 56 56 private $omnipotent = false; 57 57 private $customFields = self::ATTACHABLE; 58 + private $badgePHIDs = self::ATTACHABLE; 58 59 59 60 private $alternateCSRFString = self::ATTACHABLE; 60 61 private $session = self::ATTACHABLE; ··· 1143 1144 */ 1144 1145 public function renderHandleList(array $phids) { 1145 1146 return $this->loadHandles($phids)->renderList(); 1147 + } 1148 + 1149 + public function attachBadgePHIDs(array $phids) { 1150 + $this->badgePHIDs = $phids; 1151 + return $this; 1152 + } 1153 + 1154 + public function getBadgePHIDs() { 1155 + return $this->assertAttached($this->badgePHIDs); 1146 1156 } 1147 1157 1148 1158