2013-05-31 19:51:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorPeopleSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
2014-06-12 22:22:20 +02:00
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Users');
|
|
|
|
}
|
|
|
|
|
2015-02-05 00:47:48 +01:00
|
|
|
public function getApplicationClassName() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return 'PhabricatorPeopleApplication';
|
2014-05-16 04:17:09 +02:00
|
|
|
}
|
|
|
|
|
Integrate ApplicationSearch with CustomField
Summary:
Ref T2625. Ref T3794. Ref T418. Ref T1703.
This is a more general version of D5278. It expands CustomField support to include real integration with ApplicationSearch.
Broadly, custom fields may elect to:
- build indicies when objects are updated;
- populate ApplicationSearch forms with new controls;
- read inputs entered into those controls out of the request; and
- apply constraints to search queries.
Some utility/helper stuff is provided to make this easier. This part could be cleaner, but seems reasonable for a first cut. In particular, the Query and SearchEngine must manually call all the hooks right now instead of everything happening magically. I think that's fine for the moment; they're pretty easy to get right.
Test Plan:
I added a new searchable "Company" field to People:
{F58229}
This also cleaned up the disable/reorder view a little bit:
{F58230}
As it did before, this field appears on the edit screen:
{F58231}
However, because it has `search`, it also appears on the search screen:
{F58232}
When queried, it returns the expected results:
{F58233}
And the actually good bit of all this is that the query can take advantage of indexes:
mysql> explain SELECT * FROM `user` user JOIN `user_customfieldstringindex` `appsearch_0` ON `appsearch_0`.objectPHID = user.phid AND `appsearch_0`.indexKey = 'mk3Ndy476ge6' AND `appsearch_0`.indexValue IN ('phacility') ORDER BY user.id DESC LIMIT 101;
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| 1 | SIMPLE | appsearch_0 | ref | key_join,key_find | key_find | 232 | const,const | 1 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | user | eq_ref | phid | phid | 194 | phabricator2_user.appsearch_0.objectPHID | 1 | |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
2 rows in set (0.00 sec)
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T418, T1703, T2625, T3794
Differential Revision: https://secure.phabricator.com/D6992
2013-09-16 22:44:34 +02:00
|
|
|
public function getCustomFieldObject() {
|
|
|
|
return new PhabricatorUser();
|
|
|
|
}
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
|
|
|
|
$saved->setParameter('usernames', $request->getStrList('usernames'));
|
|
|
|
$saved->setParameter('nameLike', $request->getStr('nameLike'));
|
2015-06-02 19:22:26 +02:00
|
|
|
|
|
|
|
$saved->setParameter(
|
|
|
|
'isAdmin',
|
|
|
|
$this->readBoolFromRequest($request, 'isAdmin'));
|
|
|
|
|
|
|
|
$saved->setParameter(
|
|
|
|
'isDisabled',
|
|
|
|
$this->readBoolFromRequest($request, 'isDisabled'));
|
|
|
|
|
|
|
|
$saved->setParameter(
|
|
|
|
'isSystemAgent',
|
|
|
|
$this->readBoolFromRequest($request, 'isSystemAgent'));
|
|
|
|
|
2015-06-02 17:52:00 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'isMailingList',
|
|
|
|
$this->readBoolFromRequest($request, 'isMailingList'));
|
|
|
|
|
2015-06-02 19:22:26 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'needsApproval',
|
|
|
|
$this->readBoolFromRequest($request, 'needsApproval'));
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
$saved->setParameter('createdStart', $request->getStr('createdStart'));
|
|
|
|
$saved->setParameter('createdEnd', $request->getStr('createdEnd'));
|
|
|
|
|
Integrate ApplicationSearch with CustomField
Summary:
Ref T2625. Ref T3794. Ref T418. Ref T1703.
This is a more general version of D5278. It expands CustomField support to include real integration with ApplicationSearch.
Broadly, custom fields may elect to:
- build indicies when objects are updated;
- populate ApplicationSearch forms with new controls;
- read inputs entered into those controls out of the request; and
- apply constraints to search queries.
Some utility/helper stuff is provided to make this easier. This part could be cleaner, but seems reasonable for a first cut. In particular, the Query and SearchEngine must manually call all the hooks right now instead of everything happening magically. I think that's fine for the moment; they're pretty easy to get right.
Test Plan:
I added a new searchable "Company" field to People:
{F58229}
This also cleaned up the disable/reorder view a little bit:
{F58230}
As it did before, this field appears on the edit screen:
{F58231}
However, because it has `search`, it also appears on the search screen:
{F58232}
When queried, it returns the expected results:
{F58233}
And the actually good bit of all this is that the query can take advantage of indexes:
mysql> explain SELECT * FROM `user` user JOIN `user_customfieldstringindex` `appsearch_0` ON `appsearch_0`.objectPHID = user.phid AND `appsearch_0`.indexKey = 'mk3Ndy476ge6' AND `appsearch_0`.indexValue IN ('phacility') ORDER BY user.id DESC LIMIT 101;
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| 1 | SIMPLE | appsearch_0 | ref | key_join,key_find | key_find | 232 | const,const | 1 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | user | eq_ref | phid | phid | 194 | phabricator2_user.appsearch_0.objectPHID | 1 | |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
2 rows in set (0.00 sec)
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T418, T1703, T2625, T3794
Differential Revision: https://secure.phabricator.com/D6992
2013-09-16 22:44:34 +02:00
|
|
|
$this->readCustomFieldsFromRequest($request, $saved);
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
return $saved;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
|
|
$query = id(new PhabricatorPeopleQuery())
|
2014-03-20 03:28:04 +01:00
|
|
|
->needPrimaryEmail(true)
|
|
|
|
->needProfileImage(true);
|
2013-05-31 19:51:20 +02:00
|
|
|
|
2014-05-16 04:17:09 +02:00
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
|
|
|
|
// If the viewer can't browse the user directory, restrict the query to
|
|
|
|
// just the user's own profile. This is a little bit silly, but serves to
|
|
|
|
// restrict users from creating a dashboard panel which essentially just
|
|
|
|
// contains a user directory anyway.
|
|
|
|
$can_browse = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$this->getApplication(),
|
2014-07-25 00:20:39 +02:00
|
|
|
PeopleBrowseUserDirectoryCapability::CAPABILITY);
|
2014-05-16 04:17:09 +02:00
|
|
|
if (!$can_browse) {
|
|
|
|
$query->withPHIDs(array($viewer->getPHID()));
|
|
|
|
}
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
$usernames = $saved->getParameter('usernames', array());
|
|
|
|
if ($usernames) {
|
|
|
|
$query->withUsernames($usernames);
|
|
|
|
}
|
|
|
|
|
|
|
|
$like = $saved->getParameter('nameLike');
|
|
|
|
if ($like) {
|
|
|
|
$query->withNameLike($like);
|
|
|
|
}
|
|
|
|
|
|
|
|
$is_admin = $saved->getParameter('isAdmin');
|
|
|
|
$is_disabled = $saved->getParameter('isDisabled');
|
|
|
|
$is_system_agent = $saved->getParameter('isSystemAgent');
|
2015-06-02 17:52:00 +02:00
|
|
|
$is_mailing_list = $saved->getParameter('isMailingList');
|
2013-11-13 20:24:18 +01:00
|
|
|
$needs_approval = $saved->getParameter('needsApproval');
|
2013-05-31 19:51:20 +02:00
|
|
|
|
2015-06-02 19:22:26 +02:00
|
|
|
if ($is_admin !== null) {
|
|
|
|
$query->withIsAdmin($is_admin);
|
2013-05-31 19:51:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-02 19:22:26 +02:00
|
|
|
if ($is_disabled !== null) {
|
|
|
|
$query->withIsDisabled($is_disabled);
|
2013-05-31 19:51:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-02 19:22:26 +02:00
|
|
|
if ($is_system_agent !== null) {
|
|
|
|
$query->withIsSystemAgent($is_system_agent);
|
2013-05-31 19:51:20 +02:00
|
|
|
}
|
|
|
|
|
2015-06-02 17:52:00 +02:00
|
|
|
if ($is_mailing_list !== null) {
|
|
|
|
$query->withIsMailingList($is_mailing_list);
|
|
|
|
}
|
|
|
|
|
2015-06-02 19:22:26 +02:00
|
|
|
if ($needs_approval !== null) {
|
|
|
|
$query->withIsApproved(!$needs_approval);
|
2013-11-13 20:24:18 +01:00
|
|
|
}
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
$start = $this->parseDateTime($saved->getParameter('createdStart'));
|
|
|
|
$end = $this->parseDateTime($saved->getParameter('createdEnd'));
|
|
|
|
|
|
|
|
if ($start) {
|
|
|
|
$query->withDateCreatedAfter($start);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($end) {
|
|
|
|
$query->withDateCreatedBefore($end);
|
|
|
|
}
|
Integrate ApplicationSearch with CustomField
Summary:
Ref T2625. Ref T3794. Ref T418. Ref T1703.
This is a more general version of D5278. It expands CustomField support to include real integration with ApplicationSearch.
Broadly, custom fields may elect to:
- build indicies when objects are updated;
- populate ApplicationSearch forms with new controls;
- read inputs entered into those controls out of the request; and
- apply constraints to search queries.
Some utility/helper stuff is provided to make this easier. This part could be cleaner, but seems reasonable for a first cut. In particular, the Query and SearchEngine must manually call all the hooks right now instead of everything happening magically. I think that's fine for the moment; they're pretty easy to get right.
Test Plan:
I added a new searchable "Company" field to People:
{F58229}
This also cleaned up the disable/reorder view a little bit:
{F58230}
As it did before, this field appears on the edit screen:
{F58231}
However, because it has `search`, it also appears on the search screen:
{F58232}
When queried, it returns the expected results:
{F58233}
And the actually good bit of all this is that the query can take advantage of indexes:
mysql> explain SELECT * FROM `user` user JOIN `user_customfieldstringindex` `appsearch_0` ON `appsearch_0`.objectPHID = user.phid AND `appsearch_0`.indexKey = 'mk3Ndy476ge6' AND `appsearch_0`.indexValue IN ('phacility') ORDER BY user.id DESC LIMIT 101;
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| 1 | SIMPLE | appsearch_0 | ref | key_join,key_find | key_find | 232 | const,const | 1 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | user | eq_ref | phid | phid | 194 | phabricator2_user.appsearch_0.objectPHID | 1 | |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
2 rows in set (0.00 sec)
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T418, T1703, T2625, T3794
Differential Revision: https://secure.phabricator.com/D6992
2013-09-16 22:44:34 +02:00
|
|
|
|
|
|
|
$this->applyCustomFieldsToQuery($query, $saved);
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSearchForm(
|
|
|
|
AphrontFormView $form,
|
|
|
|
PhabricatorSavedQuery $saved) {
|
|
|
|
|
|
|
|
$usernames = $saved->getParameter('usernames', array());
|
|
|
|
$like = $saved->getParameter('nameLike');
|
|
|
|
|
2015-06-02 19:22:26 +02:00
|
|
|
$is_admin = $this->getBoolFromQuery($saved, 'isAdmin');
|
|
|
|
$is_disabled = $this->getBoolFromQuery($saved, 'isDisabled');
|
|
|
|
$is_system_agent = $this->getBoolFromQuery($saved, 'isSystemAgent');
|
2015-06-02 17:52:00 +02:00
|
|
|
$is_mailing_list = $this->getBoolFromQuery($saved, 'isMailingList');
|
2015-06-02 19:22:26 +02:00
|
|
|
$needs_approval = $this->getBoolFromQuery($saved, 'needsApproval');
|
2013-05-31 19:51:20 +02:00
|
|
|
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setName('usernames')
|
|
|
|
->setLabel(pht('Usernames'))
|
|
|
|
->setValue(implode(', ', $usernames)))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setName('nameLike')
|
|
|
|
->setLabel(pht('Name Contains'))
|
|
|
|
->setValue($like))
|
|
|
|
->appendChild(
|
2015-06-02 19:22:26 +02:00
|
|
|
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'),
|
|
|
|
)))
|
2015-06-02 17:52:00 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setName('isMailingList')
|
|
|
|
->setLabel(pht('Mailing Lists'))
|
|
|
|
->setValue($is_mailing_list)
|
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'' => pht('(Show All)'),
|
|
|
|
'true' => pht('Show Only Mailing Lists'),
|
|
|
|
'false' => pht('Hide Mailing Lists'),
|
|
|
|
)))
|
2015-06-02 19:22:26 +02:00
|
|
|
->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'),
|
|
|
|
)));
|
2013-05-31 19:51:20 +02:00
|
|
|
|
Integrate ApplicationSearch with CustomField
Summary:
Ref T2625. Ref T3794. Ref T418. Ref T1703.
This is a more general version of D5278. It expands CustomField support to include real integration with ApplicationSearch.
Broadly, custom fields may elect to:
- build indicies when objects are updated;
- populate ApplicationSearch forms with new controls;
- read inputs entered into those controls out of the request; and
- apply constraints to search queries.
Some utility/helper stuff is provided to make this easier. This part could be cleaner, but seems reasonable for a first cut. In particular, the Query and SearchEngine must manually call all the hooks right now instead of everything happening magically. I think that's fine for the moment; they're pretty easy to get right.
Test Plan:
I added a new searchable "Company" field to People:
{F58229}
This also cleaned up the disable/reorder view a little bit:
{F58230}
As it did before, this field appears on the edit screen:
{F58231}
However, because it has `search`, it also appears on the search screen:
{F58232}
When queried, it returns the expected results:
{F58233}
And the actually good bit of all this is that the query can take advantage of indexes:
mysql> explain SELECT * FROM `user` user JOIN `user_customfieldstringindex` `appsearch_0` ON `appsearch_0`.objectPHID = user.phid AND `appsearch_0`.indexKey = 'mk3Ndy476ge6' AND `appsearch_0`.indexValue IN ('phacility') ORDER BY user.id DESC LIMIT 101;
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
| 1 | SIMPLE | appsearch_0 | ref | key_join,key_find | key_find | 232 | const,const | 1 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | user | eq_ref | phid | phid | 194 | phabricator2_user.appsearch_0.objectPHID | 1 | |
+----+-------------+-------------+--------+-------------------+----------+---------+------------------------------------------+------+----------------------------------------------+
2 rows in set (0.00 sec)
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T418, T1703, T2625, T3794
Differential Revision: https://secure.phabricator.com/D6992
2013-09-16 22:44:34 +02:00
|
|
|
$this->appendCustomFieldsToForm($form, $saved);
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
$this->buildDateRange(
|
|
|
|
$form,
|
|
|
|
$saved,
|
|
|
|
'createdStart',
|
|
|
|
pht('Joined After'),
|
|
|
|
'createdEnd',
|
|
|
|
pht('Joined Before'));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/people/'.$path;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:34:51 +01:00
|
|
|
protected function getBuiltinQueryNames() {
|
2013-05-31 19:51:20 +02:00
|
|
|
$names = array(
|
2015-06-02 19:22:26 +02:00
|
|
|
'active' => pht('Active'),
|
2013-05-31 19:51:20 +02:00
|
|
|
'all' => pht('All'),
|
|
|
|
);
|
|
|
|
|
2013-11-13 20:24:18 +01:00
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
if ($viewer->getIsAdmin()) {
|
|
|
|
$names['approval'] = pht('Approval Queue');
|
|
|
|
}
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
return $names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
|
|
|
switch ($query_key) {
|
|
|
|
case 'all':
|
|
|
|
return $query;
|
2015-06-02 19:22:26 +02:00
|
|
|
case 'active':
|
|
|
|
return $query
|
|
|
|
->setParameter('isDisabled', false);
|
2013-11-13 20:24:18 +01:00
|
|
|
case 'approval':
|
|
|
|
return $query
|
|
|
|
->setParameter('needsApproval', true)
|
2015-06-02 19:22:26 +02:00
|
|
|
->setParameter('isDisabled', true);
|
2013-05-31 19:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
2014-05-16 04:17:09 +02:00
|
|
|
protected function renderResultList(
|
|
|
|
array $users,
|
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
array $handles) {
|
|
|
|
|
|
|
|
assert_instances_of($users, 'PhabricatorUser');
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
|
|
|
|
$is_approval = ($query->getQueryKey() == 'approval');
|
|
|
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
$primary_email = $user->loadPrimaryEmail();
|
|
|
|
if ($primary_email && $primary_email->getIsVerified()) {
|
|
|
|
$email = pht('Verified');
|
|
|
|
} else {
|
|
|
|
$email = pht('Unverified');
|
|
|
|
}
|
|
|
|
|
|
|
|
$item = new PHUIObjectItemView();
|
|
|
|
$item->setHeader($user->getFullName())
|
|
|
|
->setHref('/p/'.$user->getUsername().'/')
|
|
|
|
->addAttribute(phabricator_datetime($user->getDateCreated(), $viewer))
|
|
|
|
->addAttribute($email)
|
|
|
|
->setImageURI($user->getProfileImageURI());
|
|
|
|
|
|
|
|
if ($is_approval && $primary_email) {
|
|
|
|
$item->addAttribute($primary_email->getAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->getIsDisabled()) {
|
|
|
|
$item->addIcon('fa-ban', pht('Disabled'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$is_approval) {
|
|
|
|
if (!$user->getIsApproved()) {
|
|
|
|
$item->addIcon('fa-clock-o', pht('Needs Approval'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->getIsAdmin()) {
|
|
|
|
$item->addIcon('fa-star', pht('Admin'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->getIsSystemAgent()) {
|
2015-06-02 19:22:26 +02:00
|
|
|
$item->addIcon('fa-desktop', pht('Bot'));
|
2014-05-16 04:17:09 +02:00
|
|
|
}
|
|
|
|
|
2015-06-02 17:52:00 +02:00
|
|
|
if ($user->getIsMailingList()) {
|
|
|
|
$item->addIcon('fa-envelope-o', pht('Mailing List'));
|
|
|
|
}
|
|
|
|
|
2014-05-16 04:17:09 +02:00
|
|
|
if ($viewer->getIsAdmin()) {
|
|
|
|
$user_id = $user->getID();
|
|
|
|
if ($is_approval) {
|
|
|
|
$item->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setIcon('fa-ban')
|
|
|
|
->setName(pht('Disable'))
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setHref($this->getApplicationURI('disapprove/'.$user_id.'/')));
|
|
|
|
$item->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setIcon('fa-thumbs-o-up')
|
|
|
|
->setName(pht('Approve'))
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setHref($this->getApplicationURI('approve/'.$user_id.'/')));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
2013-05-31 19:51:20 +02:00
|
|
|
}
|