plugin.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. ** plugin.php
  4. **
  5. ** This file provides the framework for a plugin architecture.
  6. **
  7. ** Plugins will eventually be a way to provide added functionality
  8. ** without having to patch the SquirrelMail source code. Have some
  9. ** patience, though, as the these funtions might change in the near
  10. ** future.
  11. **
  12. ** Documentation on how to write plugins might show up some time.
  13. **
  14. **/
  15. $plugin_php = true;
  16. // This function adds a plugin
  17. function use_plugin ($name) {
  18. if (file_exists('../plugins/'.$name.'/setup.php')) {
  19. include ('../plugins/'.$name.'/setup.php');
  20. $function = 'squirrelmail_plugin_init_'.$name;
  21. $function();
  22. }
  23. }
  24. // This function executes a hook
  25. function do_hook ($name) {
  26. global $squirrelmail_plugin_hooks;
  27. if (is_array($squirrelmail_plugin_hooks[$name])) {
  28. reset($squirrelmail_plugin_hooks[$name]);
  29. while (list ($id, $function) =
  30. each ($squirrelmail_plugin_hooks[$name])) {
  31. // Add something to set correct gettext domain for plugin
  32. $function();
  33. }
  34. }
  35. }
  36. // On startup, register all plugins configured for use
  37. if (is_array($plugins))
  38. while (list ($id, $name) = each ($plugins))
  39. use_plugin($name);
  40. ?>