start.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * The main plugin file for Friend Request
  4. */
  5. // load library files
  6. require_once(dirname(__FILE__) . '/lib/functions.php');
  7. // default event handlers
  8. elgg_register_event_handler('init', 'system', 'friend_request_init');
  9. /**
  10. * Gets called during system initialization
  11. *
  12. * @return void
  13. */
  14. function friend_request_init() {
  15. // extend css
  16. elgg_extend_view('css/elgg', 'css/friend_request/site');
  17. // Page handlers
  18. // unregister friendsof
  19. elgg_unregister_page_handler('friendsof');
  20. // This will let users view their friend requests
  21. elgg_register_page_handler('friend_request', '\ColdTrick\FriendRequest\PageHandler::friendRequest');
  22. // Events
  23. // unregister default elgg friend handler
  24. elgg_unregister_event_handler('create', 'friend', '_elgg_send_friend_notification');
  25. // Handle our add action event
  26. elgg_register_event_handler('create', 'relationship', '\ColdTrick\FriendRequest\Relationships::createFriendRequest');
  27. // Plugin hooks
  28. elgg_register_plugin_hook_handler('register', 'menu:topbar', '\ColdTrick\FriendRequest\TopbarMenu::register');
  29. elgg_register_plugin_hook_handler('register', 'menu:page', '\ColdTrick\FriendRequest\PageMenu::registerCleanup');
  30. elgg_register_plugin_hook_handler('register', 'menu:page', '\ColdTrick\FriendRequest\PageMenu::register');
  31. elgg_register_plugin_hook_handler('register', 'menu:user_hover', '\ColdTrick\FriendRequest\Users::registerUserHoverMenu');
  32. elgg_register_plugin_hook_handler('register', 'menu:entity', '\ColdTrick\FriendRequest\Users::registerEntityMenu');
  33. // Actions
  34. // This overwrites the original friend requesting stuff.
  35. elgg_register_action('friends/add', dirname(__FILE__) . '/actions/friends/add.php');
  36. // We need to override the friend remove action to remove the relationship we created
  37. elgg_register_action('friends/remove', dirname(__FILE__) . '/actions/friends/removefriend.php');
  38. // friend request actions
  39. elgg_register_action('friend_request/approve', dirname(__FILE__) . '/actions/approve.php');
  40. elgg_register_action('friend_request/decline', dirname(__FILE__) . '/actions/decline.php');
  41. elgg_register_action('friend_request/revoke', dirname(__FILE__) . '/actions/revoke.php');
  42. }