Elgg  Version 4.3
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) {
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']);
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
elgg_set_context_stack(array $stack)
Set the entire context stack.
Definition: context.php:99
elgg_set_page_owner_guid($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
elgg_view_menu($menu, array $vars=[])
Render a menu.
Definition: views.php:468
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_set_config($name, $value)
Set an Elgg configuration value.
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
elgg echo
Translates a string.
Definition: deprecated.js:530
elgg_build_hmac($data)
Get an HMAC token builder/validator object.
Definition: actions.php:54
elgg_get_context_stack()
Get the entire context stack (e.g.
Definition: context.php:88
elgg_get_config($name, $default=null)
Get an Elgg configuration value.