contents.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // capture global state necessary for menus
  3. $state = [
  4. 'contexts' => elgg_get_context_stack(),
  5. 'input' => elgg_get_config("input"),
  6. 'page_owner_guid' => elgg_get_page_owner_guid(),
  7. ];
  8. // g = guid, pog = page_owner_guid, c = contexts, m = mac
  9. $guid = (int) get_input("g", 0, false);
  10. $page_owner_guid = (int) get_input("pog", 0, false);
  11. $contexts = (array) get_input("c", [], false);
  12. $mac = get_input("m", "", false);
  13. $input = (array) get_input("i", [], false);
  14. // verify MAC
  15. $data = serialize([$guid, $page_owner_guid, $contexts, $input]);
  16. if (!elgg_build_hmac($data)->matchesToken($mac)) {
  17. return;
  18. }
  19. $user = get_user($guid);
  20. if (!$user) {
  21. return;
  22. }
  23. // render view using state as it was in the placeholder view
  24. elgg_set_context_stack($contexts);
  25. elgg_set_config("input", $input);
  26. elgg_set_page_owner_guid($page_owner_guid);
  27. $params = [
  28. "entity" => $user,
  29. "username" => $user->username,
  30. "name" => $user->name,
  31. ];
  32. echo elgg_view_menu("user_hover", $params);
  33. // revert global state
  34. elgg_set_context_stack($state['contexts']);
  35. elgg_set_config("input", $state['input']);
  36. elgg_set_page_owner_guid($state['page_owner_guid']);