start.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once(dirname(__FILE__) . "/lib/functions.php");
  3. // register default Elgg events
  4. elgg_register_event_handler("init", "system", "account_removal_init");
  5. elgg_register_event_handler("pagesetup", "system", "account_removal_pagesetup");
  6. /**
  7. * Called during system init
  8. *
  9. * @return void
  10. */
  11. function account_removal_init() {
  12. // extend the CSS with plugin CSS
  13. elgg_extend_view("css/elgg", "account_removal/css");
  14. // register pagehandler for nice URL's
  15. elgg_register_page_handler("account_removal", "account_removal_page_handler");
  16. // register actions
  17. elgg_register_action("account_removal/remove", dirname(__FILE__) . "/actions/remove.php");
  18. }
  19. /**
  20. * Called during page setup
  21. *
  22. * @return void
  23. */
  24. function account_removal_pagesetup() {
  25. $user = elgg_get_logged_in_user_entity();
  26. if (empty($user) || $user->isAdmin()) {
  27. return;
  28. }
  29. elgg_register_menu_item("page", ElggMenuItem::factory(array(
  30. "name" => "account_removal",
  31. "text" => elgg_echo('account_removal:menu:title'),
  32. "href" => "account_removal/" . $user->username,
  33. "context" => "settings"
  34. )));
  35. }
  36. /**
  37. * Account removal page handler
  38. *
  39. * @param arra $page URL segments
  40. *
  41. * @return bool
  42. */
  43. function account_removal_page_handler($page) {
  44. switch ($page[0]) {
  45. case "remove":
  46. case "disable":
  47. set_input("type", $page[0]);
  48. include(dirname(__FILE__) . "/pages/user.php");
  49. break;
  50. default:
  51. if (!empty($page[0])) {
  52. set_input("username", $page[0]);
  53. }
  54. include(dirname(__FILE__) . "/pages/user.php");
  55. break;
  56. }
  57. return true;
  58. }