]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1465: Added unregister_event_handler() and unregister_plugin_hook().
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 27 Jan 2010 16:03:23 +0000 (16:03 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 27 Jan 2010 16:03:23 +0000 (16:03 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3848 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php

index 074204310a49ed94105a1368b1f6de4d8461645d..021af5e4868f34a9480c0571eb248a043722bfd1 100644 (file)
@@ -1636,6 +1636,22 @@ function register_elgg_event_handler($event, $object_type, $function, $priority
        return events($event, $object_type, $function, $priority);
 }
 
+/**
+ * Unregisters a function to a particular kind of event
+ *
+ * @param string $event The event type
+ * @param string $object_type The object type
+ * @param string $function The function name
+ */
+function unregister_elgg_event_handler($event, $object_type, $function) {
+       global $CONFIG;
+       foreach($CONFIG->events[$event][$object_type] as $key => $event_function) {
+               if ($event_function == $function) {
+                       unset($CONFIG->events[$event][$object_type][$key]);
+               }
+       }
+}
+
 /**
  * Alias function for events, that triggers a particular kind of event
  *
@@ -1703,6 +1719,22 @@ function register_plugin_hook($hook, $entity_type, $function, $priority = 500) {
        }
 }
 
+/**
+ * Unregister a function to a plugin hook for a particular entity type
+ *
+ * @param string $hook The name of the hook
+ * @param string $entity_type The name of the type of entity (eg "user", "object" etc)
+ * @param string $function The name of a valid function to be run
+ */
+function unregister_plugin_hook($hook, $entity_type, $function) {
+       global $CONFIG;
+       foreach($CONFIG->hooks[$hook][$entity_type] as $key => $hook_function) {
+               if ($hook_function == $function) {
+                       unset($CONFIG->hooks[$hook][$entity_type][$key]);
+               }
+       }
+}
+
 /**
  * Triggers a plugin hook, with various parameters as an array. For example, to provide
  * a 'foo' hook that concerns an entity of type 'bar', with a parameter called 'param1'