Elgg  Version 3.0
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:40
elgg_set_context_stack(array $stack)
Set the entire context stack.
Definition: pageowner.php:259
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:81
elgg_view_menu($menu, array $vars=[])
Render a menu.
Definition: views.php:755
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
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:168
elgg echo
Translates a string.
Definition: languages.js:43
elgg_get_context_stack()
Get the entire context stack (e.g.
Definition: pageowner.php:248
elgg_build_hmac($data)
Get an HMAC token builder/validator object.
Definition: actions.php:62
elgg_get_page_owner_guid($guid=0)
Gets the guid of the entity that owns the current page.
Definition: pageowner.php:22
elgg_get_config($name, $default=null)
Get an Elgg configuration value.