plugin.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. include ('../plugins/'.$name.'/setup.php');
  19. $function = 'squirrelmail_plugin_init_'.$name;
  20. $function();
  21. }
  22. // This function executes a hook
  23. function do_hook ($name) {
  24. global $squirrelmail_plugin_hooks;
  25. if (is_array($squirrelmail_plugin_hooks[$name])) {
  26. reset($squirrelmail_plugin_hooks[$name]);
  27. while (list ($id, $function) =
  28. each ($squirrelmail_plugin_hooks[$name])) {
  29. // Add something to set correct gettext domain for plugin
  30. $function();
  31. }
  32. }
  33. }
  34. // On startup, register all plugins configured for use
  35. if (is_array($plugins))
  36. while (list ($id, $name) = each ($plugins))
  37. use_plugin($name);
  38. ?>