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

Move people list rendering into SearchEngine

Summary:
Ref T4986. One note:

- We have a separate "browse directory" capability, to provide some soft privacy for users of public installs. Respect that policy within the SearchEngine.
- Also restore some other icons I missed earlier.

Test Plan:
- Viewed people list.
- Build people panel.
- Verified people panel was just me without browse capability.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

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

+95 -77
+2 -77
src/applications/people/controller/PhabricatorPeopleListController.php
··· 1 1 <?php 2 2 3 - final class PhabricatorPeopleListController extends PhabricatorPeopleController 4 - implements PhabricatorApplicationSearchResultsControllerInterface { 3 + final class PhabricatorPeopleListController 4 + extends PhabricatorPeopleController { 5 5 6 6 private $key; 7 7 ··· 32 32 return $this->delegateToController($controller); 33 33 } 34 34 35 - public function renderResultsList( 36 - array $users, 37 - PhabricatorSavedQuery $query) { 38 - 39 - assert_instances_of($users, 'PhabricatorUser'); 40 - 41 - $request = $this->getRequest(); 42 - $viewer = $request->getUser(); 43 - 44 - $list = new PHUIObjectItemListView(); 45 - 46 - $is_approval = ($query->getQueryKey() == 'approval'); 47 - 48 - foreach ($users as $user) { 49 - $primary_email = $user->loadPrimaryEmail(); 50 - if ($primary_email && $primary_email->getIsVerified()) { 51 - $email = pht('Verified'); 52 - } else { 53 - $email = pht('Unverified'); 54 - } 55 - 56 - $item = new PHUIObjectItemView(); 57 - $item->setHeader($user->getFullName()) 58 - ->setHref('/p/'.$user->getUsername().'/') 59 - ->addAttribute(hsprintf('%s %s', 60 - phabricator_date($user->getDateCreated(), $viewer), 61 - phabricator_time($user->getDateCreated(), $viewer))) 62 - ->addAttribute($email) 63 - ->setImageURI($user->getProfileImageURI()); 64 - 65 - if ($is_approval && $primary_email) { 66 - $item->addAttribute($primary_email->getAddress()); 67 - } 68 - 69 - if ($user->getIsDisabled()) { 70 - $item->addIcon('disable', pht('Disabled')); 71 - } 72 - 73 - if (!$is_approval) { 74 - if (!$user->getIsApproved()) { 75 - $item->addIcon('perflab-grey', pht('Needs Approval')); 76 - } 77 - } 78 - 79 - if ($user->getIsAdmin()) { 80 - $item->addIcon('highlight', pht('Admin')); 81 - } 82 - 83 - if ($user->getIsSystemAgent()) { 84 - $item->addIcon('computer', pht('Bot/Script')); 85 - } 86 - 87 - if ($viewer->getIsAdmin()) { 88 - $user_id = $user->getID(); 89 - if ($is_approval) { 90 - $item->addAction( 91 - id(new PHUIListItemView()) 92 - ->setIcon('fa-ban') 93 - ->setName(pht('Disable')) 94 - ->setWorkflow(true) 95 - ->setHref($this->getApplicationURI('disapprove/'.$user_id.'/'))); 96 - $item->addAction( 97 - id(new PHUIListItemView()) 98 - ->setIcon('fa-thumbs-o-up') 99 - ->setName(pht('Approve')) 100 - ->setWorkflow(true) 101 - ->setHref($this->getApplicationURI('approve/'.$user_id.'/'))); 102 - } 103 - } 104 - 105 - $list->addItem($item); 106 - } 107 - 108 - return $list; 109 - } 110 35 }
+93
src/applications/people/query/PhabricatorPeopleSearchEngine.php
··· 3 3 final class PhabricatorPeopleSearchEngine 4 4 extends PhabricatorApplicationSearchEngine { 5 5 6 + public function getApplicationClassName() { 7 + return 'PhabricatorApplicationPeople'; 8 + } 9 + 6 10 public function getCustomFieldObject() { 7 11 return new PhabricatorUser(); 8 12 } ··· 28 32 $query = id(new PhabricatorPeopleQuery()) 29 33 ->needPrimaryEmail(true) 30 34 ->needProfileImage(true); 35 + 36 + $viewer = $this->requireViewer(); 37 + 38 + // If the viewer can't browse the user directory, restrict the query to 39 + // just the user's own profile. This is a little bit silly, but serves to 40 + // restrict users from creating a dashboard panel which essentially just 41 + // contains a user directory anyway. 42 + $can_browse = PhabricatorPolicyFilter::hasCapability( 43 + $viewer, 44 + $this->getApplication(), 45 + PeopleCapabilityBrowseUserDirectory::CAPABILITY); 46 + if (!$can_browse) { 47 + $query->withPHIDs(array($viewer->getPHID())); 48 + } 31 49 32 50 $usernames = $saved->getParameter('usernames', array()); 33 51 if ($usernames) { ··· 168 186 } 169 187 170 188 return parent::buildSavedQueryFromBuiltin($query_key); 189 + } 190 + 191 + protected function renderResultList( 192 + array $users, 193 + PhabricatorSavedQuery $query, 194 + array $handles) { 195 + 196 + assert_instances_of($users, 'PhabricatorUser'); 197 + 198 + $request = $this->getRequest(); 199 + $viewer = $this->requireViewer(); 200 + 201 + $list = new PHUIObjectItemListView(); 202 + 203 + $is_approval = ($query->getQueryKey() == 'approval'); 204 + 205 + foreach ($users as $user) { 206 + $primary_email = $user->loadPrimaryEmail(); 207 + if ($primary_email && $primary_email->getIsVerified()) { 208 + $email = pht('Verified'); 209 + } else { 210 + $email = pht('Unverified'); 211 + } 212 + 213 + $item = new PHUIObjectItemView(); 214 + $item->setHeader($user->getFullName()) 215 + ->setHref('/p/'.$user->getUsername().'/') 216 + ->addAttribute(phabricator_datetime($user->getDateCreated(), $viewer)) 217 + ->addAttribute($email) 218 + ->setImageURI($user->getProfileImageURI()); 219 + 220 + if ($is_approval && $primary_email) { 221 + $item->addAttribute($primary_email->getAddress()); 222 + } 223 + 224 + if ($user->getIsDisabled()) { 225 + $item->addIcon('fa-ban', pht('Disabled')); 226 + } 227 + 228 + if (!$is_approval) { 229 + if (!$user->getIsApproved()) { 230 + $item->addIcon('fa-clock-o', pht('Needs Approval')); 231 + } 232 + } 233 + 234 + if ($user->getIsAdmin()) { 235 + $item->addIcon('fa-star', pht('Admin')); 236 + } 237 + 238 + if ($user->getIsSystemAgent()) { 239 + $item->addIcon('fa-desktop', pht('Bot/Script')); 240 + } 241 + 242 + if ($viewer->getIsAdmin()) { 243 + $user_id = $user->getID(); 244 + if ($is_approval) { 245 + $item->addAction( 246 + id(new PHUIListItemView()) 247 + ->setIcon('fa-ban') 248 + ->setName(pht('Disable')) 249 + ->setWorkflow(true) 250 + ->setHref($this->getApplicationURI('disapprove/'.$user_id.'/'))); 251 + $item->addAction( 252 + id(new PHUIListItemView()) 253 + ->setIcon('fa-thumbs-o-up') 254 + ->setName(pht('Approve')) 255 + ->setWorkflow(true) 256 + ->setHref($this->getApplicationURI('approve/'.$user_id.'/'))); 257 + } 258 + } 259 + 260 + $list->addItem($item); 261 + } 262 + 263 + return $list; 171 264 } 172 265 173 266 }