start.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Main plugin file
  4. */
  5. require_once(dirname(__FILE__) . "/lib/functions.php");
  6. require_once(dirname(__FILE__) . "/lib/hooks.php");
  7. require_once(dirname(__FILE__) . "/vendor/autoload.php");
  8. // register default Elgg events
  9. elgg_register_event_handler("init", "system", "html_email_handler_init");
  10. elgg_register_event_handler("pagesetup", "system", "html_email_handler_pagesetup");
  11. /**
  12. * Gets called during system initialization
  13. *
  14. * @return void
  15. */
  16. function html_email_handler_init() {
  17. // register page_handler for nice URL's
  18. elgg_register_page_handler("html_email_handler", "html_email_handler_page_handler");
  19. // plugin hooks
  20. elgg_register_plugin_hook_handler("cron", "daily", "html_email_handler_daily_cron_hook");
  21. // Handler that takes care of sending emails as HTML
  22. elgg_register_plugin_hook_handler("email", "system", "html_email_handler_email_hook");
  23. }
  24. /**
  25. * Gets called during the pagesetup fase of the system
  26. *
  27. * @return void
  28. */
  29. function html_email_handler_pagesetup() {
  30. // add a menu item to the Theming preview
  31. elgg_register_menu_item("theme_sandbox", array(
  32. "name" => "html_email_handler",
  33. "text" => elgg_echo("html_email_handler:theme_preview:menu"),
  34. "href" => "html_email_handler/test",
  35. "target" => "_blank"
  36. ));
  37. }
  38. /**
  39. * The page handler for html_email_handler
  40. *
  41. * @param array $page the page elements
  42. *
  43. * @return bool
  44. */
  45. function html_email_handler_page_handler($page) {
  46. $result = false;
  47. switch ($page[0]) {
  48. case "test":
  49. $result = true;
  50. include(dirname(__FILE__) . "/pages/test.php");
  51. break;
  52. }
  53. return $result;
  54. }