From 8bdc2c56d1b1ef6234e44ad941b25bdaa1979793 Mon Sep 17 00:00:00 2001 From: marcus Date: Mon, 11 May 2009 08:41:26 +0000 Subject: Captcha list can now be extended by other plugins git-svn-id: https://code.elgg.org/elgg/trunk@3273 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/captcha/start.php | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'mod/captcha') diff --git a/mod/captcha/start.php b/mod/captcha/start.php index 26e8671d2..982a01c2c 100644 --- a/mod/captcha/start.php +++ b/mod/captcha/start.php @@ -25,9 +25,18 @@ // Default length $CONFIG->captcha_length = 5; - // Right, these actions require captcha validation TODO: Put this in config somehow - register_plugin_hook("action", "register", "captcha_verify_action_hook"); - register_plugin_hook("action", "user/requestnewpassword", "captcha_verify_action_hook"); + // Register a function that provides some default override actions + register_plugin_hook('actionlist', 'captcha', 'captcha_actionlist_hook'); + + // Register actions to intercept + $actions = array(); + $actions = trigger_plugin_hook('actionlist', 'captcha', null, $actions); + + if (($actions) && (is_array($actions))) + { + foreach ($actions as $action) + register_plugin_hook("action", $action, "captcha_verify_action_hook"); + } } function captcha_page_handler($page) @@ -108,5 +117,25 @@ return false; } + /** + * This function returns an array of actions the captcha will expect a captcha for, other plugins may + * add their own to this list thereby extending the use. + * + * @param unknown_type $hook + * @param unknown_type $entity_type + * @param unknown_type $returnvalue + * @param unknown_type $params + */ + function captcha_actionlist_hook($hook, $entity_type, $returnvalue, $params) + { + if (!is_array($returnvalue)) + $returnvalue = array(); + + $returnvalue[] = 'register'; + $returnvalue[] = 'user/requestnewpassword'; + + return $returnvalue; + } + register_elgg_event_handler('init','system','captcha_init'); ?> \ No newline at end of file -- cgit v1.2.3