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

Expand the power of user filtering

Summary:
Ref T8387. This mostly merges D10565 + D10480. I'm going to touch this to add mailing list stuff shortly so I wanted to clean those up.

This isn't super pretty but is fully flexible and consistent with other modern query UIs.

This should be more-or-less backward compatible.

Test Plan: Fiddled with the new options.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: eadler, cburroughs, epriestley

Maniphest Tasks: T8044, T8387

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

+84 -47
+6 -4
src/applications/people/query/PhabricatorPeopleQuery.php
··· 312 312 $this->dateCreatedBefore); 313 313 } 314 314 315 - if ($this->isAdmin) { 315 + if ($this->isAdmin !== null) { 316 316 $where[] = qsprintf( 317 317 $conn_r, 318 - 'user.isAdmin = 1'); 318 + 'user.isAdmin = %d', 319 + (int)$this->isAdmin); 319 320 } 320 321 321 322 if ($this->isDisabled !== null) { ··· 332 333 (int)$this->isApproved); 333 334 } 334 335 335 - if ($this->isSystemAgent) { 336 + if ($this->isSystemAgent !== null) { 336 337 $where[] = qsprintf( 337 338 $conn_r, 338 - 'user.isSystemAgent = 1'); 339 + 'user.isSystemAgent = %d', 340 + (int)$this->isSystemAgent); 339 341 } 340 342 341 343 if (strlen($this->nameLike)) {
+78 -43
src/applications/people/query/PhabricatorPeopleSearchEngine.php
··· 20 20 21 21 $saved->setParameter('usernames', $request->getStrList('usernames')); 22 22 $saved->setParameter('nameLike', $request->getStr('nameLike')); 23 - $saved->setParameter('isAdmin', $request->getStr('isAdmin')); 24 - $saved->setParameter('isDisabled', $request->getStr('isDisabled')); 25 - $saved->setParameter('isSystemAgent', $request->getStr('isSystemAgent')); 26 - $saved->setParameter('needsApproval', $request->getStr('needsApproval')); 23 + 24 + $saved->setParameter( 25 + 'isAdmin', 26 + $this->readBoolFromRequest($request, 'isAdmin')); 27 + 28 + $saved->setParameter( 29 + 'isDisabled', 30 + $this->readBoolFromRequest($request, 'isDisabled')); 31 + 32 + $saved->setParameter( 33 + 'isSystemAgent', 34 + $this->readBoolFromRequest($request, 'isSystemAgent')); 35 + 36 + $saved->setParameter( 37 + 'needsApproval', 38 + $this->readBoolFromRequest($request, 'needsApproval')); 39 + 27 40 $saved->setParameter('createdStart', $request->getStr('createdStart')); 28 41 $saved->setParameter('createdEnd', $request->getStr('createdEnd')); 29 42 ··· 65 78 $is_disabled = $saved->getParameter('isDisabled'); 66 79 $is_system_agent = $saved->getParameter('isSystemAgent'); 67 80 $needs_approval = $saved->getParameter('needsApproval'); 68 - $no_disabled = $saved->getParameter('noDisabled'); 69 81 70 - if ($is_admin) { 71 - $query->withIsAdmin(true); 82 + if ($is_admin !== null) { 83 + $query->withIsAdmin($is_admin); 72 84 } 73 85 74 - if ($is_disabled) { 75 - $query->withIsDisabled(true); 76 - } else if ($no_disabled) { 77 - $query->withIsDisabled(false); 86 + if ($is_disabled !== null) { 87 + $query->withIsDisabled($is_disabled); 78 88 } 79 89 80 - if ($is_system_agent) { 81 - $query->withIsSystemAgent(true); 90 + if ($is_system_agent !== null) { 91 + $query->withIsSystemAgent($is_system_agent); 82 92 } 83 93 84 - if ($needs_approval) { 85 - $query->withIsApproved(false); 94 + if ($needs_approval !== null) { 95 + $query->withIsApproved(!$needs_approval); 86 96 } 87 97 88 98 $start = $this->parseDateTime($saved->getParameter('createdStart')); ··· 108 118 $usernames = $saved->getParameter('usernames', array()); 109 119 $like = $saved->getParameter('nameLike'); 110 120 111 - $is_admin = $saved->getParameter('isAdmin'); 112 - $is_disabled = $saved->getParameter('isDisabled'); 113 - $is_system_agent = $saved->getParameter('isSystemAgent'); 114 - $needs_approval = $saved->getParameter('needsApproval'); 121 + $is_admin = $this->getBoolFromQuery($saved, 'isAdmin'); 122 + $is_disabled = $this->getBoolFromQuery($saved, 'isDisabled'); 123 + $is_system_agent = $this->getBoolFromQuery($saved, 'isSystemAgent'); 124 + $needs_approval = $this->getBoolFromQuery($saved, 'needsApproval'); 115 125 116 126 $form 117 127 ->appendChild( ··· 125 135 ->setLabel(pht('Name Contains')) 126 136 ->setValue($like)) 127 137 ->appendChild( 128 - id(new AphrontFormCheckboxControl()) 129 - ->setLabel('Role') 130 - ->addCheckbox( 131 - 'isAdmin', 132 - 1, 133 - pht('Show only administrators.'), 134 - $is_admin) 135 - ->addCheckbox( 136 - 'isDisabled', 137 - 1, 138 - pht('Show only disabled users.'), 139 - $is_disabled) 140 - ->addCheckbox( 141 - 'isSystemAgent', 142 - 1, 143 - pht('Show only bots.'), 144 - $is_system_agent) 145 - ->addCheckbox( 146 - 'needsApproval', 147 - 1, 148 - pht('Show only users who need approval.'), 149 - $needs_approval)); 138 + id(new AphrontFormSelectControl()) 139 + ->setName('isAdmin') 140 + ->setLabel(pht('Administrators')) 141 + ->setValue($is_admin) 142 + ->setOptions( 143 + array( 144 + '' => pht('(Show All)'), 145 + 'true' => pht('Show Only Administrators'), 146 + 'false' => pht('Hide Administrators'), 147 + ))) 148 + ->appendChild( 149 + id(new AphrontFormSelectControl()) 150 + ->setName('isDisabled') 151 + ->setLabel(pht('Disabled')) 152 + ->setValue($is_disabled) 153 + ->setOptions( 154 + array( 155 + '' => pht('(Show All)'), 156 + 'true' => pht('Show Only Disabled Users'), 157 + 'false' => pht('Hide Disabled Users'), 158 + ))) 159 + ->appendChild( 160 + id(new AphrontFormSelectControl()) 161 + ->setName('isSystemAgent') 162 + ->setLabel(pht('Bots')) 163 + ->setValue($is_system_agent) 164 + ->setOptions( 165 + array( 166 + '' => pht('(Show All)'), 167 + 'true' => pht('Show Only Bots'), 168 + 'false' => pht('Hide Bots'), 169 + ))) 170 + ->appendChild( 171 + id(new AphrontFormSelectControl()) 172 + ->setName('needsApproval') 173 + ->setLabel(pht('Needs Approval')) 174 + ->setValue($needs_approval) 175 + ->setOptions( 176 + array( 177 + '' => pht('(Show All)'), 178 + 'true' => pht('Show Only Unapproved Users'), 179 + 'false' => pht('Hide Unapproved Users'), 180 + ))); 150 181 151 182 $this->appendCustomFieldsToForm($form, $saved); 152 183 ··· 165 196 166 197 protected function getBuiltinQueryNames() { 167 198 $names = array( 199 + 'active' => pht('Active'), 168 200 'all' => pht('All'), 169 201 ); 170 202 ··· 183 215 switch ($query_key) { 184 216 case 'all': 185 217 return $query; 218 + case 'active': 219 + return $query 220 + ->setParameter('isDisabled', false); 186 221 case 'approval': 187 222 return $query 188 223 ->setParameter('needsApproval', true) 189 - ->setParameter('noDisabled', true); 224 + ->setParameter('isDisabled', true); 190 225 } 191 226 192 227 return parent::buildSavedQueryFromBuiltin($query_key); ··· 240 275 } 241 276 242 277 if ($user->getIsSystemAgent()) { 243 - $item->addIcon('fa-desktop', pht('Bot/Script')); 278 + $item->addIcon('fa-desktop', pht('Bot')); 244 279 } 245 280 246 281 if ($viewer->getIsAdmin()) {