start.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * A user dashboard
  4. */
  5. elgg_register_event_handler('init', 'system', 'dashboard_init');
  6. function dashboard_init() {
  7. elgg_register_page_handler('dashboard', 'dashboard_page_handler');
  8. elgg_extend_view('css/elgg', 'dashboard/css');
  9. elgg_extend_view('js/elgg', 'dashboard/js');
  10. elgg_register_menu_item('topbar', array(
  11. 'name' => 'dashboard',
  12. 'href' => 'dashboard',
  13. 'text' => elgg_view_icon('home') . elgg_echo('dashboard'),
  14. 'priority' => 450,
  15. 'section' => 'alt',
  16. ));
  17. elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'dashboard_default_widgets');
  18. }
  19. /**
  20. * Dashboard page handler
  21. * @return bool
  22. */
  23. function dashboard_page_handler() {
  24. // Ensure that only logged-in users can see this page
  25. elgg_gatekeeper();
  26. // Set context and title
  27. elgg_set_context('dashboard');
  28. elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
  29. $title = elgg_echo('dashboard');
  30. // wrap intro message in a div
  31. $intro_message = elgg_view('dashboard/blurb');
  32. $params = array(
  33. 'content' => $intro_message,
  34. 'num_columns' => 3,
  35. 'show_access' => false,
  36. );
  37. $widgets = elgg_view_layout('widgets', $params);
  38. $body = elgg_view_layout('one_column', array(
  39. 'title' => false,
  40. 'content' => $widgets
  41. ));
  42. echo elgg_view_page($title, $body);
  43. return true;
  44. }
  45. /**
  46. * Register user dashboard with default widgets
  47. *
  48. * @param unknown_type $hook
  49. * @param unknown_type $type
  50. * @param unknown_type $return
  51. * @param unknown_type $params
  52. * @return array
  53. */
  54. function dashboard_default_widgets($hook, $type, $return, $params) {
  55. $return[] = array(
  56. 'name' => elgg_echo('dashboard'),
  57. 'widget_context' => 'dashboard',
  58. 'widget_columns' => 3,
  59. 'event' => 'create',
  60. 'entity_type' => 'user',
  61. 'entity_subtype' => ELGG_ENTITIES_ANY_VALUE,
  62. );
  63. return $return;
  64. }