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

at recaptime-dev/main 139 lines 3.6 kB view raw
1<?php 2 3final class PhabricatorProjectColumnAuthorOrder 4 extends PhabricatorProjectColumnOrder { 5 6 const ORDERKEY = 'author'; 7 8 public function getDisplayName() { 9 return pht('Group by Author'); 10 } 11 12 protected function newMenuIconIcon() { 13 return 'fa-user-plus'; 14 } 15 16 public function getHasHeaders() { 17 return true; 18 } 19 20 public function getCanReorder() { 21 return false; 22 } 23 24 public function getMenuOrder() { 25 return 3000; 26 } 27 28 protected function newHeaderKeyForObject($object) { 29 return $this->newHeaderKeyForAuthorPHID($object->getAuthorPHID()); 30 } 31 32 private function newHeaderKeyForAuthorPHID($author_phid) { 33 return sprintf('author(%s)', $author_phid); 34 } 35 36 protected function newSortVectorsForObjects(array $objects) { 37 $author_phids = mpull($objects, null, 'getAuthorPHID'); 38 $author_phids = array_keys($author_phids); 39 $author_phids = array_filter($author_phids); 40 41 if ($author_phids) { 42 $author_users = id(new PhabricatorPeopleQuery()) 43 ->setViewer($this->getViewer()) 44 ->withPHIDs($author_phids) 45 ->execute(); 46 $author_users = mpull($author_users, null, 'getPHID'); 47 } else { 48 $author_users = array(); 49 } 50 51 $vectors = array(); 52 foreach ($objects as $vector_key => $object) { 53 $author_phid = $object->getAuthorPHID(); 54 $author = idx($author_users, $author_phid); 55 if ($author) { 56 $vector = $this->newSortVectorForAuthor($author); 57 } else { 58 $vector = $this->newSortVectorForAuthorPHID($author_phid); 59 } 60 61 $vectors[$vector_key] = $vector; 62 } 63 64 return $vectors; 65 } 66 67 private function newSortVectorForAuthor(PhabricatorUser $user) { 68 return array( 69 1, 70 $user->getUsername(), 71 ); 72 } 73 74 private function newSortVectorForAuthorPHID($author_phid) { 75 return array( 76 2, 77 $author_phid, 78 ); 79 } 80 81 protected function newHeadersForObjects(array $objects) { 82 $author_phids = mpull($objects, null, 'getAuthorPHID'); 83 $author_phids = array_keys($author_phids); 84 $author_phids = array_filter($author_phids); 85 86 if ($author_phids) { 87 $author_users = id(new PhabricatorPeopleQuery()) 88 ->setViewer($this->getViewer()) 89 ->withPHIDs($author_phids) 90 ->needProfileImage(true) 91 ->execute(); 92 $author_users = mpull($author_users, null, 'getPHID'); 93 } else { 94 $author_users = array(); 95 } 96 97 $headers = array(); 98 foreach ($author_phids as $author_phid) { 99 $header_key = $this->newHeaderKeyForAuthorPHID($author_phid); 100 101 $author = idx($author_users, $author_phid); 102 if ($author) { 103 $sort_vector = $this->newSortVectorForAuthor($author); 104 $author_name = $author->getUsername(); 105 $author_image = $author->getProfileImageURI(); 106 } else { 107 $sort_vector = $this->newSortVectorForAuthorPHID($author_phid); 108 $author_name = pht('Unknown User ("%s")', $author_phid); 109 $author_image = null; 110 } 111 112 $author_icon = 'fa-user'; 113 $author_color = 'bluegrey'; 114 115 $icon_view = new PHUIIconView(); 116 117 if ($author_image) { 118 $icon_view->setImage($author_image); 119 } else { 120 $icon_view->setIcon($author_icon, $author_color); 121 } 122 123 $header = $this->newHeader() 124 ->setHeaderKey($header_key) 125 ->setSortVector($sort_vector) 126 ->setName($author_name) 127 ->setIcon($icon_view) 128 ->setEditProperties( 129 array( 130 'value' => $author_phid, 131 )); 132 133 $headers[] = $header; 134 } 135 136 return $headers; 137 } 138 139}