Index: captcha_api.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/captcha/Attic/captcha_api.txt,v retrieving revision 1.1.4.5 diff -u -u -p -r1.1.4.5 captcha_api.txt --- captcha_api.txt 17 Aug 2007 18:43:13 -0000 1.1.4.5 +++ captcha_api.txt 19 Sep 2007 09:25:33 -0000 @@ -1,26 +1,26 @@ -This documentation is for developers that want to implement their own captcha -challenge and integrate it with the base captcha module. +This documentation is for developers that want to implement their own CAPTCHA +and integrate it with the base CAPTCHA module. === Required: hook_captcha($op, $captcha_type='') === The hook_captcha() hook is the only required function if you want to integrate -with the base captcha module. +with the base CAPTCHA module. Functionality depends on the first argument $op: - * 'list': you should return an array of possible captcha type names that your + * 'list': you should return an array of possible CAPTCHA type names that your module implements. - * 'generate': generate a captcha challenge. + * 'generate': generate a CAPTCHA. You should return an array that offers form elements and the solution - of your captcha challenge, defined by the second argument $captcha_type. + of your CAPTCHA, defined by the second argument $captcha_type. The returned array $captcha should have the following items: - $captcha['solution']: this is the solution of your captcha challenge + $captcha['solution']: this is the solution of your CAPTCHA $captcha['form']: an array of the form elements you want to add to the form. There should be a key 'captcha_response' in this array, which points to the form element where the user enters his answer. Let's give a simple example to make this more clear. -We create the captcha challenge 'Foo captcha', which requires the user to +We create the CAPTCHA type 'Foo CAPTCHA', which requires the user to enter "foo" in a textfield. """ @@ -30,9 +30,9 @@ enter "foo" in a textfield. function foo_captcha_captcha($op, $captcha_type='') { switch($op) { case 'list': - return array("Foo captcha"); + return array('Foo CAPTCHA'); case 'generate': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == 'Foo CAPTCHA') { $captcha = array(); $captcha['solution'] = 'foo'; $captcha['form']['captcha_response'] = array ( @@ -47,22 +47,22 @@ function foo_captcha_captcha($op, $captc """ Validation of the answer against the solution and other stuff is done by the -base captcha module. +base CAPTCHA module. === Required: the .info file === -You should specify that your module depends on the base captcha module. +You should specify that your module depends on the base CAPTCHA module. Optionally you could put your module in the "Spam control" package. -For our simple foo captcha module this would mean the following lines in the +For our simple foo CAPTCHA module this would mean the following lines in the file foo_captcha.info: """ -name = "Foo captcha" -description = "The foo captcha requires the user to enter the word 'foo'." +name = "Foo CAPTCHA" +description = "The foo CAPTCHA requires the user to enter the word 'foo'." package = "Spam control" dependencies = captcha """ @@ -72,11 +72,11 @@ dependencies = captcha === Recommended: hook_menu($may_cache) === -More advanced captcha modules probably want some configuration page. To integrate -nicely with the captcha module you should offer your configuration page as a +More advanced CAPTCHA modules probably want some configuration page. To integrate +nicely with the CAPTCHA module you should offer your configuration page as a MENU_LOCAL_TASK menu entry under 'admin/user/captcha/'. -For our simple foo captcha module this would mean: +For our simple foo CAPTCHA module this would mean: """ /** @@ -87,7 +87,7 @@ function foo_captcha_menu($may_cache) { if ($may_cache) { $items[] = array( 'path' => 'admin/user/captcha/foo_captcha', - 'title' => t('Foo captcha'), + 'title' => t('Foo CAPTCHA'), 'callback' => 'drupal_get_form', 'callback arguments' => array('foo_captcha_settings_form'), 'type' => MENU_LOCAL_TASK, @@ -104,10 +104,10 @@ returns the form of your configuration p === Optional: hook_help($section) === -To offer a description/explanation of your captcha challenge, you can use the +To offer a description/explanation of your CAPTCHA, you can use the normal hook_help() system. -For our simple foo captcha module this would mean: +For our simple foo CAPTCHA module this would mean: """ /** @@ -116,16 +116,15 @@ For our simple foo captcha module this w function foo_captcha_help($section) { switch ($section) { case 'admin/user/captcha/foo_captcha': - return '

' . t('This is a very simple captcha, which requires users to enter "foo" in a textfield.') . '

'; + return '

'. t('This is a very simple CAPTCHA, which requires users to enter "foo" in a textfield.') .'

'; } - return $output; } """ === Optional: preprocess the response === In some situations it could be necessary to preprocess the response before -letting the captcha module validate it. For example: if you want the validation +letting the CAPTCHA module validate it. For example: if you want the validation to be case insensitive, you could convert the reponse to lower case. To enable response preprocessing: @@ -137,7 +136,7 @@ function foo_captcha_captcha($op, $captc switch($op) { ... case 'generate': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == 'Foo CAPTCHA') { ... $captcha['preprocess'] = TRUE, ... @@ -151,7 +150,7 @@ function foo_captcha_captcha($op, $captc switch($op) { ... case 'preprocess': - if ($captcha_type == "Foo captcha") { + if ($captcha_type == 'Foo CAPTCHA') { return strtolower($response); } break;