diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-01-27 16:03:23 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-01-27 16:03:23 +0000 |
commit | a5781a77c4d079f62298323566e6adc79b98e089 (patch) | |
tree | ccc5b045cfe5e79f9400d025c7a56543a98d7104 /engine/lib | |
parent | 9003094e5dd355a8f63ef39b429e4c7b9a7ce687 (diff) | |
download | elgg-a5781a77c4d079f62298323566e6adc79b98e089.tar.gz elgg-a5781a77c4d079f62298323566e6adc79b98e089.tar.bz2 |
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
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/elgglib.php | 32 |
1 files changed, 32 insertions, 0 deletions
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 @@ -1637,6 +1637,22 @@ function register_elgg_event_handler($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 * * @param string $event The event type @@ -1704,6 +1720,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' * with value 'value1', that by default returns true, you'd call: |