diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php --- a/src/applications/people/query/PhabricatorPeopleQuery.php +++ b/src/applications/people/query/PhabricatorPeopleQuery.php @@ -312,10 +312,11 @@ $this->dateCreatedBefore); } - if ($this->isAdmin) { + if ($this->isAdmin !== null) { $where[] = qsprintf( $conn_r, - 'user.isAdmin = 1'); + 'user.isAdmin = %d', + (int)$this->isAdmin); } if ($this->isDisabled !== null) { @@ -332,10 +333,11 @@ (int)$this->isApproved); } - if ($this->isSystemAgent) { + if ($this->isSystemAgent !== null) { $where[] = qsprintf( $conn_r, - 'user.isSystemAgent = 1'); + 'user.isSystemAgent = %d', + (int)$this->isSystemAgent); } if (strlen($this->nameLike)) { diff --git a/src/applications/people/query/PhabricatorPeopleSearchEngine.php b/src/applications/people/query/PhabricatorPeopleSearchEngine.php --- a/src/applications/people/query/PhabricatorPeopleSearchEngine.php +++ b/src/applications/people/query/PhabricatorPeopleSearchEngine.php @@ -20,10 +20,23 @@ $saved->setParameter('usernames', $request->getStrList('usernames')); $saved->setParameter('nameLike', $request->getStr('nameLike')); - $saved->setParameter('isAdmin', $request->getStr('isAdmin')); - $saved->setParameter('isDisabled', $request->getStr('isDisabled')); - $saved->setParameter('isSystemAgent', $request->getStr('isSystemAgent')); - $saved->setParameter('needsApproval', $request->getStr('needsApproval')); + + $saved->setParameter( + 'isAdmin', + $this->readBoolFromRequest($request, 'isAdmin')); + + $saved->setParameter( + 'isDisabled', + $this->readBoolFromRequest($request, 'isDisabled')); + + $saved->setParameter( + 'isSystemAgent', + $this->readBoolFromRequest($request, 'isSystemAgent')); + + $saved->setParameter( + 'needsApproval', + $this->readBoolFromRequest($request, 'needsApproval')); + $saved->setParameter('createdStart', $request->getStr('createdStart')); $saved->setParameter('createdEnd', $request->getStr('createdEnd')); @@ -65,24 +78,21 @@ $is_disabled = $saved->getParameter('isDisabled'); $is_system_agent = $saved->getParameter('isSystemAgent'); $needs_approval = $saved->getParameter('needsApproval'); - $no_disabled = $saved->getParameter('noDisabled'); - if ($is_admin) { - $query->withIsAdmin(true); + if ($is_admin !== null) { + $query->withIsAdmin($is_admin); } - if ($is_disabled) { - $query->withIsDisabled(true); - } else if ($no_disabled) { - $query->withIsDisabled(false); + if ($is_disabled !== null) { + $query->withIsDisabled($is_disabled); } - if ($is_system_agent) { - $query->withIsSystemAgent(true); + if ($is_system_agent !== null) { + $query->withIsSystemAgent($is_system_agent); } - if ($needs_approval) { - $query->withIsApproved(false); + if ($needs_approval !== null) { + $query->withIsApproved(!$needs_approval); } $start = $this->parseDateTime($saved->getParameter('createdStart')); @@ -108,10 +118,10 @@ $usernames = $saved->getParameter('usernames', array()); $like = $saved->getParameter('nameLike'); - $is_admin = $saved->getParameter('isAdmin'); - $is_disabled = $saved->getParameter('isDisabled'); - $is_system_agent = $saved->getParameter('isSystemAgent'); - $needs_approval = $saved->getParameter('needsApproval'); + $is_admin = $this->getBoolFromQuery($saved, 'isAdmin'); + $is_disabled = $this->getBoolFromQuery($saved, 'isDisabled'); + $is_system_agent = $this->getBoolFromQuery($saved, 'isSystemAgent'); + $needs_approval = $this->getBoolFromQuery($saved, 'needsApproval'); $form ->appendChild( @@ -125,28 +135,49 @@ ->setLabel(pht('Name Contains')) ->setValue($like)) ->appendChild( - id(new AphrontFormCheckboxControl()) - ->setLabel('Role') - ->addCheckbox( - 'isAdmin', - 1, - pht('Show only administrators.'), - $is_admin) - ->addCheckbox( - 'isDisabled', - 1, - pht('Show only disabled users.'), - $is_disabled) - ->addCheckbox( - 'isSystemAgent', - 1, - pht('Show only bots.'), - $is_system_agent) - ->addCheckbox( - 'needsApproval', - 1, - pht('Show only users who need approval.'), - $needs_approval)); + id(new AphrontFormSelectControl()) + ->setName('isAdmin') + ->setLabel(pht('Administrators')) + ->setValue($is_admin) + ->setOptions( + array( + '' => pht('(Show All)'), + 'true' => pht('Show Only Administrators'), + 'false' => pht('Hide Administrators'), + ))) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setName('isDisabled') + ->setLabel(pht('Disabled')) + ->setValue($is_disabled) + ->setOptions( + array( + '' => pht('(Show All)'), + 'true' => pht('Show Only Disabled Users'), + 'false' => pht('Hide Disabled Users'), + ))) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setName('isSystemAgent') + ->setLabel(pht('Bots')) + ->setValue($is_system_agent) + ->setOptions( + array( + '' => pht('(Show All)'), + 'true' => pht('Show Only Bots'), + 'false' => pht('Hide Bots'), + ))) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setName('needsApproval') + ->setLabel(pht('Needs Approval')) + ->setValue($needs_approval) + ->setOptions( + array( + '' => pht('(Show All)'), + 'true' => pht('Show Only Unapproved Users'), + 'false' => pht('Hide Unapproved Users'), + ))); $this->appendCustomFieldsToForm($form, $saved); @@ -165,6 +196,7 @@ protected function getBuiltinQueryNames() { $names = array( + 'active' => pht('Active'), 'all' => pht('All'), ); @@ -183,10 +215,13 @@ switch ($query_key) { case 'all': return $query; + case 'active': + return $query + ->setParameter('isDisabled', false); case 'approval': return $query ->setParameter('needsApproval', true) - ->setParameter('noDisabled', true); + ->setParameter('isDisabled', true); } return parent::buildSavedQueryFromBuiltin($query_key); @@ -240,7 +275,7 @@ } if ($user->getIsSystemAgent()) { - $item->addIcon('fa-desktop', pht('Bot/Script')); + $item->addIcon('fa-desktop', pht('Bot')); } if ($viewer->getIsAdmin()) {