Elgg  Version master
UserSearchFieldsHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Search;
4 
10 
18  public function __invoke(\Elgg\Event $event) {
19 
20  $value = (array) $event->getValue();
21 
22  $defaults = [
23  'metadata' => [],
24  ];
25 
26  $value = array_merge($defaults, $value);
27 
28  $fields = [
29  'username',
30  'name',
31  'description',
32  ];
33 
34  if (elgg_in_context('admin') && elgg_is_admin_logged_in()) {
35  $fields[] = 'email';
36  }
37 
38  $value['metadata'] = array_merge($value['metadata'], $fields);
39 
40  return $value;
41  }
42 }
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
$defaults
Generic entity header upload helper.
Definition: header.php:6
elgg_in_context(string $context)
Check if this context exists anywhere in the stack.
Definition: context.php:78
$value
Definition: generic.php:51
$fields
Save the configuration of the security.txt contents.
Definition: security_txt.php:6
__invoke(\Elgg\Event $event)
Populate default search fields for user entities.
Models an event passed to event handlers.
Definition: Event.php:11