start.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace AU\GroupNotices;
  3. /**
  4. * AU group notices
  5. * allows group owners to add persistent notices to a group
  6. */
  7. const PLUGIN_ID = 'au_group_notices';
  8. elgg_register_event_handler('init', 'system', __NAMESPACE__ . '\\init');
  9. /**
  10. * plugin init
  11. */
  12. function init() {
  13. //add option to save form
  14. elgg_register_action('au_group_notices/save', __DIR__ . "/actions/au_group_notices/save.php");
  15. // Extend the main CSS file
  16. elgg_extend_view('css/elgg', 'css/au_group_notices');
  17. // add settings for tools
  18. elgg_extend_view('groups/edit', 'au_group_notices/au_group_notices_settings');
  19. elgg_register_event_handler('pagesetup', 'system', __NAMESPACE__ . '\\pagesetup');
  20. }
  21. /**
  22. * Page setup event
  23. */
  24. function pagesetup() {
  25. $group = elgg_get_page_owner_entity();
  26. if (!$group instanceof \ElggGroup) {
  27. return true;
  28. }
  29. $position = $group->au_group_notice_position;
  30. switch ($position) {
  31. case 'top':
  32. elgg_extend_view('page/elements/body', 'au_group_notices/au_group_notices_show', 499);
  33. break;
  34. case 'bottom':
  35. elgg_extend_view('page/elements/body', 'au_group_notices/au_group_notices_show', 501);
  36. break;
  37. case 'sidebottom':
  38. elgg_extend_view('page/elements/sidebar', 'au_group_notices/au_group_notices_show', 600);
  39. break;
  40. case 'sidetop':
  41. elgg_extend_view('group/default', 'au_group_notices/au_group_notices_show', 100);
  42. break;
  43. default:
  44. // do nothing - if position not set, no settings provided
  45. break;
  46. }
  47. }