Elgg  Version 3.0
users.php
Go to the documentation of this file.
1 <?php
2 
4 
5 $limit = (int) elgg_extract('limit', $vars, elgg_get_config('default_limit'));
8 
10  'query' => $query,
11  'type' => 'user',
12  'limit' => $limit,
13  'sort' => 'name',
14  'order' => 'ASC',
15  'fields' => ['metadata' => ['name', 'username']],
16  'item_view' => 'search/entity',
17  'input_name' => $input_name,
18 ];
19 
20 if (elgg_extract('friends_only', $vars, false)) {
21  $target_guid = (int) elgg_extract('match_target', $vars);
22  if ($target_guid) {
24  } else {
26  }
27 
28  if (!$target || !$target->canEdit()) {
29  throw new \Elgg\EntityPermissionsException();
30  }
31 
32  $options['wheres'][] = function(\Elgg\Database\QueryBuilder $qb, $main_alias) use ($target) {
33  $subquery = $qb->subquery('entity_relationships', 'er');
34  $subquery->select('er.guid_two')
35  ->andWhere($qb->compare('er.relationship', '=', 'friend', ELGG_VALUE_STRING))
36  ->andWhere($qb->compare('er.guid_one', '=', $target->guid, ELGG_VALUE_GUID));
37 
38  return $qb->compare("{$main_alias}.guid", 'in', $subquery->getSQL());
39  };
40 }
41 
42 // by default search in all users,
43 // with 'include_banned' => false, only search in 'allowed' users
44 if (!(bool) elgg_extract('include_banned', $vars, true)) {
45  $options['metadata_name_value_pairs'][] = [
46  'name' => 'banned',
47  'value' => 'no',
48  ];
49 }
50 
51 $body = elgg_list_entities($options, 'elgg_search');
52 
$limit
Definition: users.php:5
const ELGG_VALUE_GUID
Definition: constants.php:140
$target_guid
Definition: groups.php:22
$options
Definition: users.php:9
canEdit($user_guid=0)
Can a user edit this entity?
elgg_list_entities(array $options=[], $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:577
elgg_view_page($title, $body, $page_shell= 'default', $vars=[])
Assembles and outputs a full page.
Definition: views.php:360
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
if(elgg_extract('friends_only', $vars, false)) if(!(bool) elgg_extract('include_banned', $vars, true)) $body
Definition: users.php:51
if(!($comment instanceof\ElggComment)||!$comment->canEdit()) $target
Definition: edit.php:17
elgg echo
Translates a string.
Definition: languages.js:43
$query
Definition: users.php:6
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
const ELGG_VALUE_STRING
Definition: constants.php:139
$vars['type']
Definition: save.php:11
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
$input_name
Definition: users.php:7
elgg_get_config($name, $default=null)
Get an Elgg configuration value.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87