From a5781a77c4d079f62298323566e6adc79b98e089 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Jan 2010 16:03:23 +0000 Subject: Fixes #1465: Added unregister_event_handler() and unregister_plugin_hook(). git-svn-id: http://code.elgg.org/elgg/trunk@3848 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'engine/lib/elgglib.php') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 074204310..021af5e48 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -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' -- cgit v1.2.3