owner_block.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Profile owner block
  4. */
  5. $user = elgg_get_page_owner_entity();
  6. if (!$user) {
  7. // no user so we quit view
  8. echo elgg_echo('viewfailure', array(__FILE__));
  9. return TRUE;
  10. }
  11. $icon = elgg_view_entity_icon($user, 'large', array(
  12. 'use_hover' => false,
  13. 'use_link' => false,
  14. 'img_class' => 'photo u-photo',
  15. ));
  16. $icon = "<img src='" . $user->getIconURL('large') . "' class='img-responsive'/>";
  17. // grab the actions and admin menu items from user hover
  18. $menu = elgg_trigger_plugin_hook('register', "menu:user_hover", array('entity' => $user), array());
  19. $builder = new ElggMenuBuilder($menu);
  20. $menu = $builder->getMenu();
  21. $menu = elgg_trigger_plugin_hook('prepare', "menu:user_hover", array(
  22. 'menu' => $menu,
  23. 'entity' => $user,
  24. 'username' => $user->username,
  25. 'name' => 'user_hover',
  26. ), $menu);
  27. $actions = elgg_extract('action', $menu, array());
  28. $admin = elgg_extract('admin', $menu, array());
  29. $profile_actions = '';
  30. if (elgg_is_logged_in() && $actions) {
  31. $profile_actions = '<ul class="elgg-menu profile-action-menu mvm">';
  32. foreach ($actions as $action) {
  33. $item = elgg_view_menu_item($action, array('class' => 'elgg-button elgg-button-action'));
  34. $profile_actions .= "<li class=\"{$action->getItemClass()}\">$item</li>";
  35. }
  36. $profile_actions .= '</ul>';
  37. }
  38. // if admin, display admin links
  39. $admin_links = '';
  40. if (elgg_is_admin_logged_in() && elgg_get_logged_in_user_guid() != elgg_get_page_owner_guid()) {
  41. $text = elgg_echo('admin:options');
  42. $admin_links = '<ul class="profile-admin-menu-wrapper">';
  43. $admin_links .= "<li><a rel=\"toggle\" href=\"#profile-menu-admin\">$text&hellip;</a>";
  44. $admin_links .= '<ul class="profile-admin-menu" id="profile-menu-admin">';
  45. foreach ($admin as $menu_item) {
  46. $admin_links .= elgg_view('navigation/menu/elements/item', array('item' => $menu_item));
  47. }
  48. $admin_links .= '</ul>';
  49. $admin_links .= '</li>';
  50. $admin_links .= '</ul>';
  51. }
  52. // content links
  53. $content_menu = elgg_view_menu('owner_block', array(
  54. 'entity' => elgg_get_page_owner_entity(),
  55. 'class' => 'profile-content-menu',
  56. ));
  57. echo <<<HTML
  58. <table><tr><td><div id="profile-owner-block">
  59. $icon
  60. $profile_actions
  61. $content_menu
  62. $admin_links
  63. </div></td>
  64. HTML;