all.php 828 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * If you register an 'all' string for the event name, the handler function will
  4. * be called for all events with that name, regardless of event type. The same
  5. * can be done for the event type argument. Registering 'all' for both
  6. * arguments results in a handler being called for every event.
  7. */
  8. elgg_register_event_handler('all', 'object', 'example_event_handler');
  9. // This function will be called for any event of type 'object'
  10. function example_event_handler($event, $type, $object) {
  11. // check what sort of object is passed
  12. if ($object instanceof ElggObject) {
  13. $subtype = $object->getSubtype();
  14. switch ($subtype) {
  15. case 'blog':
  16. case 'thewire':
  17. case 'pages':
  18. // prevent these object subtypes from being saved or changed
  19. return false;
  20. default:
  21. return true;
  22. }
  23. }
  24. return true;
  25. }