Elgg  Version master
contents.php
Go to the documentation of this file.
1 <?php
2 
3 // capture global state necessary for menus
4 $state = [
5  'contexts' => elgg_get_context_stack(),
6  'input' => elgg_get_config('input'),
7  'page_owner_guid' => elgg_get_page_owner_guid(),
8 ];
9 
10 // g = guid, pog = page_owner_guid, c = contexts, m = mac
11 $guid = (int) get_input('g', 0, false);
12 $page_owner_guid = (int) get_input('pog', 0, false);
13 $contexts = (array) get_input('c', [], false);
14 $mac = get_input('m', '', false);
15 $input = (array) get_input('i', [], false);
16 
17 // verify MAC
19 
20 if (!elgg_build_hmac($data)->matchesToken($mac)) {
21  return;
22 }
23 
25 if (!$user instanceof \ElggUser) {
26  return;
27 }
28 
29 // render view using state as it was in the placeholder view
31 elgg_set_config('input', $input);
33 
34 $menu = elgg_view_menu('user_hover', [
35  'entity' => $user,
36  'username' => $user->username,
37  'name' => $user->getDisplayName(),
38 ]);
39 
40 // wrapping in a li as it is inject into a ul via javascript
41 echo elgg_format_element('li', [], $menu);
42 
43 // revert global state
44 elgg_set_context_stack($state['contexts']);
45 elgg_set_config('input', $state['input']);
46 elgg_set_page_owner_guid($state['page_owner_guid']);
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_set_context_stack(array $stack)
Set the entire context stack.
Definition: context.php:99
elgg_set_page_owner_guid(int $guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:34
elgg_get_page_owner_guid()
Elgg page owner library.
Definition: pageowner.php:12
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_set_config(string $name, $value)
Set an Elgg configuration value.
elgg_view_menu($menu, array $vars=[])
Render a menu.
Definition: views.php:441
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_build_hmac($data)
Get an HMAC token builder/validator object.
Definition: actions.php:56
elgg_get_context_stack()
Get the entire context stack (e.g.
Definition: context.php:88