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

Enrich "gave a token" feed story

Summary: Name the token which was given in the feed story.

Test Plan: Gave/rescinded tokens. Looked at a feed story.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+60 -3
+2
src/__phutil_library_map__.php
··· 1698 1698 'PhabricatorTokenGivenFeedStory' => 'applications/tokens/feed/PhabricatorTokenGivenFeedStory.php', 1699 1699 'PhabricatorTokenGivenQuery' => 'applications/tokens/query/PhabricatorTokenGivenQuery.php', 1700 1700 'PhabricatorTokenLeaderController' => 'applications/tokens/controller/PhabricatorTokenLeaderController.php', 1701 + 'PhabricatorTokenPHIDTypeToken' => 'applications/tokens/phid/PhabricatorTokenPHIDTypeToken.php', 1701 1702 'PhabricatorTokenQuery' => 'applications/tokens/query/PhabricatorTokenQuery.php', 1702 1703 'PhabricatorTokenReceiverInterface' => 'applications/tokens/interface/PhabricatorTokenReceiverInterface.php', 1703 1704 'PhabricatorTokenReceiverQuery' => 'applications/tokens/query/PhabricatorTokenReceiverQuery.php', ··· 3856 3857 'PhabricatorTokenGivenFeedStory' => 'PhabricatorFeedStory', 3857 3858 'PhabricatorTokenGivenQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3858 3859 'PhabricatorTokenLeaderController' => 'PhabricatorTokenController', 3860 + 'PhabricatorTokenPHIDTypeToken' => 'PhabricatorPHIDType', 3859 3861 'PhabricatorTokenQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3860 3862 'PhabricatorTokenReceiverQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3861 3863 'PhabricatorTokenUIEventListener' => 'PhutilEventListener',
+11 -2
src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php
··· 14 14 return $phids; 15 15 } 16 16 17 + public function getRequiredObjectPHIDs() { 18 + $phids = array(); 19 + $phids[] = $this->getValue('tokenPHID'); 20 + return $phids; 21 + } 22 + 17 23 public function renderView() { 18 24 $view = $this->newStoryView(); 19 25 $view->setAppIcon('token-dark'); ··· 22 28 $href = $this->getHandle($this->getPrimaryObjectPHID())->getURI(); 23 29 $view->setHref($href); 24 30 31 + $token = $this->getObject($this->getValue('tokenPHID')); 32 + 25 33 $title = pht( 26 - '%s awarded %s a token.', 34 + '%s awarded %s a %s token.', 27 35 $this->linkTo($this->getValue('authorPHID')), 28 - $this->linkTo($this->getValue('objectPHID'))); 36 + $this->linkTo($this->getValue('objectPHID')), 37 + $token->getName()); 29 38 30 39 $view->setTitle($title); 31 40 $view->setImage($this->getHandle($author_phid)->getImageURI());
+44
src/applications/tokens/phid/PhabricatorTokenPHIDTypeToken.php
··· 1 + <?php 2 + 3 + final class PhabricatorTokenPHIDTypeToken extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'TOKN'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Token'); 13 + } 14 + 15 + public function newObject() { 16 + return new PhabricatorToken(); 17 + } 18 + 19 + public function loadObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new PhabricatorTokenQuery()) 24 + ->setViewer($query->getViewer()) 25 + ->setParentQuery($query) 26 + ->withPHIDs($phids) 27 + ->execute(); 28 + } 29 + 30 + public function loadHandles( 31 + PhabricatorHandleQuery $query, 32 + array $handles, 33 + array $objects) { 34 + 35 + foreach ($handles as $phid => $handle) { 36 + $token = $objects[$phid]; 37 + 38 + $name = $token->getName(); 39 + 40 + $handle->setName("{$name} Token"); 41 + } 42 + } 43 + 44 + }
+3 -1
src/applications/tokens/query/PhabricatorTokenQuery.php
··· 45 45 array('misc-4', pht('The World Burns')), 46 46 ); 47 47 48 + $type = PhabricatorTokenPHIDTypeToken::TYPECONST; 49 + 48 50 $tokens = array(); 49 51 foreach ($specs as $id => $spec) { 50 52 list($image, $name) = $spec; ··· 52 54 $token = id(new PhabricatorToken()) 53 55 ->setID($id) 54 56 ->setName($name) 55 - ->setPHID('PHID-TOKN-'.$image); 57 + ->setPHID('PHID-'.$type.'-'.$image); 56 58 $tokens[] = $token; 57 59 } 58 60