start.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace AU\AnonymousComments;
  3. const PLUGIN_ID = 'AU_anonymous_comments';
  4. const PLUGIN_VERSION = 20150918;
  5. require_once __DIR__ . '/lib/hooks.php';
  6. require_once __DIR__ . '/lib/events.php';
  7. require_once __DIR__ . '/lib/functions.php';
  8. elgg_register_event_handler('init', 'system', __NAMESPACE__ . '\\init');
  9. function init() {
  10. // Extend system CSS with our own styles
  11. elgg_extend_view('css/elgg','anonymous_comments/css');
  12. // extend the form view to present a comment form to a logged out user
  13. elgg_extend_view('page/elements/comments', 'anonymous_comments/pre_comments', 0);
  14. elgg_extend_view('page/elements/comments', 'anonymous_comments/post_comments');
  15. //add override for anonymous user profile
  16. elgg_extend_view('profile/details', 'profile/anon_user_details', 501);
  17. elgg_register_plugin_hook_handler('register', 'menu:user_hover', __NAMESPACE__ . '\\hover_menu_hook', 1000);
  18. elgg_register_plugin_hook_handler('view_vars', 'icon/user/default', __NAMESPACE__ . '\\user_icon_vars');
  19. elgg_register_plugin_hook_handler('email', 'system', __NAMESPACE__ . '\\anon_email_hook', 0);
  20. elgg_register_plugin_hook_handler('register', 'menu:entity', __NAMESPACE__ . '\\comment_entity_menu', 1000);
  21. // override permissions for the specific context
  22. elgg_register_plugin_hook_handler('permissions_check', 'all', __NAMESPACE__ . '\\permissions_check');
  23. // register plugin hook to monitor comment counts - return only the count of approved comments
  24. elgg_register_plugin_hook_handler('comments:count', 'all', __NAMESPACE__ . '\\comment_count_hook', 1000);
  25. //register action to approve/delete comments
  26. elgg_register_action("comments/moderate", __DIR__ . "/actions/comments/moderate.php");
  27. //register action to save our anonymous comments
  28. elgg_register_action("comments/anon_add", __DIR__ . "/actions/comments/anon_add.php", 'public');
  29. elgg_register_event_handler('pagesetup', 'system', __NAMESPACE__ . '\\pagesetup');
  30. elgg_register_page_handler('auac', __NAMESPACE__ . '\\auac_pagehandler');
  31. }
  32. function auac_pagehandler($page) {
  33. switch ($page[0]) {
  34. case 'approve':
  35. echo elgg_view('resources/anonymous_comments/approve', array(
  36. 'page' => $page
  37. ));
  38. break;
  39. case 'delete':
  40. echo elgg_view('resources/anonymous_comments/delete', array(
  41. 'page' => $page
  42. ));
  43. break;
  44. }
  45. return false;
  46. }