Elgg  Version master
users.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
8  'query' => elgg_extract('term', $vars),
9  'type' => 'user',
10  'limit' => elgg_extract('limit', $vars),
11  'save_as_array' => (bool) elgg_extract('save_as_array', $vars, true),
12  'sort_by' => [
13  'property_type' => 'metadata',
14  'property' => 'name',
15  'direction' => 'ASC',
16  ],
17  'fields' => ['metadata' => ['name', 'username']],
18  'item_view' => elgg_extract('item_view', $vars, 'search/entity'),
19  'input_name' => elgg_extract('name', $vars),
20 ];
21 
22 if (elgg_extract('friends_only', $vars, false)) {
23  $target_guid = (int) elgg_extract('match_target', $vars);
24  if ($target_guid) {
26  } else {
28  }
29 
30  if (!$target || !$target->canEdit()) {
31  throw new EntityPermissionsException();
32  }
33 
34  $options['relationship'] = 'friend';
35  $options['relationship_guid'] = $target->guid;
36 }
37 
38 // by default search in all users,
39 // with 'include_banned' => false, only search in 'allowed' users
40 if (!(bool) elgg_extract('include_banned', $vars, true)) {
41  $options['metadata_name_value_pairs'][] = [
42  'name' => 'banned',
43  'value' => 'no',
44  ];
45 }
46 
47 $body = elgg_list_entities($options, 'elgg_search');
48 
49 echo elgg_view_page('', $body);
$vars
Definition: theme.php:3
Thrown when entity can not be edited or container permissions do not allow it to be written.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:246
elgg_list_entities(array $options=[], ?callable $getter=null, ?callable $viewer=null)
Returns a string of rendered entities.
Definition: entities.php:551
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:68
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
Definition: gatekeepers.php:64
$target_guid
Definition: groups.php:22
elgg_view_page(string $title, string|array $body, string $page_shell='default', array $vars=[])
Assembles and outputs a full page.
Definition: views.php:235
$target
Definition: create.php:17
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:24
$options
Definition: users.php:7
if(elgg_extract('friends_only', $vars, false)) if(!(bool) elgg_extract('include_banned', $vars, true)) $body
Definition: users.php:47