@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.

Add badges to TransactionCommentView

Summary: Fixes T10698. This shows badges under the comment preview if the application uses TransactionCommentView. I suspect not everything does, but will pick the fix up for free when modernized.

Test Plan: Test commenting on a task with and without a user that has a badge. See badge preview.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10698

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

+47
+47
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 238 238 'class' => 'phui-timeline-wedge', 239 239 ), 240 240 ''); 241 + 242 + $badge_view = $this->renderBadgeView(); 243 + 241 244 $comment_box = id(new PHUIObjectBoxView()) 242 245 ->setFlush(true) 243 246 ->addClass('phui-comment-form-view') 244 247 ->addSigil('phui-comment-form') 245 248 ->appendChild($image) 249 + ->appendChild($badge_view) 246 250 ->appendChild($wedge) 247 251 ->appendChild($comment); 248 252 ··· 510 514 } 511 515 512 516 return $options; 517 + } 518 + 519 + private function renderBadgeView() { 520 + $user = $this->getUser(); 521 + $can_use_badges = PhabricatorApplication::isClassInstalledForViewer( 522 + 'PhabricatorBadgesApplication', 523 + $user); 524 + if (!$can_use_badges) { 525 + return null; 526 + } 527 + 528 + $awards = id(new PhabricatorBadgesAwardQuery()) 529 + ->setViewer($this->getUser()) 530 + ->withRecipientPHIDs(array($user->getPHID())) 531 + ->setLimit(2) 532 + ->execute(); 533 + 534 + $badge_view = null; 535 + if ($awards) { 536 + $badges = mpull($awards, 'getBadge'); 537 + $badge_list = array(); 538 + foreach ($badges as $badge) { 539 + $badge_view = id(new PHUIBadgeMiniView()) 540 + ->setIcon($badge->getIcon()) 541 + ->setQuality($badge->getQuality()) 542 + ->setHeader($badge->getName()) 543 + ->setTipDirection('E') 544 + ->setHref('/badges/view/'.$badge->getID()); 545 + 546 + $badge_list[] = $badge_view; 547 + } 548 + $flex = new PHUIBadgeBoxView(); 549 + $flex->addItems($badge_list); 550 + $flex->setCollapsed(true); 551 + $badge_view = phutil_tag( 552 + 'div', 553 + array( 554 + 'class' => 'phui-timeline-badges', 555 + ), 556 + $flex); 557 + } 558 + 559 + return $badge_view; 513 560 } 514 561 515 562 }