Could the new captcha API be implemented in the more common "Drupal way" using hooks.
Take a look at the recent votingapi.module for an example.
The core captcha.module could attempt to call any modules which implement hook_captcha() and pass an $op string.
seperate sub-modules could then implement the image, math/javascript, css captchas.
This method (as opposed to the current flexinode .inc system) makes it much easier for users to install any 3rd party captcha add ons.
I hope it wont be too much of a hassle at this early stage of the captcha api development :-)
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | textimage.module | 8.05 KB | stefano@tipic.com |
| #5 | captcha_1.module | 5.14 KB | stefano@tipic.com |
Comments
Comment #1
eaton commentedActually, it looks like that feature (api support) has already been added in the latest set of cvs checkins! http://drupal.org/cvs?commit=24948 has the skinny on it... there's a nifty 'math' plugin.
Comment #2
buddaNah, I tested the original implementation of the new API this morning (last night) and the feature request post is based on the initial experience.
The use of the .inc files is a pain for starters. The extendible API is based on Flexinode.
As mentioned in IRC, even Flexinode successor CCK has moved away from the .inc method for adding 3rd party extras on.
Comment #3
eaton commentedWhoops... sorry for setting it fixed, then. My mistake. I've changed the title to reflect this last post, hope that's okay.
Comment #4
arnabdotorg commentedFixed, Captcha is now refactored into Captcha, and Textimage modules. Enjoy!
Comment #5
stefano@tipic.com commentedI had problems running the updated captcha modules (captcha+textimage) on the last cvs version.
I made some small fixes to both modules. Here's my working captcha.module, I'll post textimage.module in next comment.
FIXES FOR CAPTCHA.MODULE
======================
1) Translation issues:
t('Captcha Points for the role %role', array('%role' => $role))
t('Math Question: What is %x + %y?', array('%x'=>$x, '%y'=>$y))
2) '#defaultvalue' replaced by '#default_value'
3) If you submit the form with the right captcha answer, but without some required fields, the captcha disappears.
I fixed it by removing line
if ($_SESSION['captcha_correct']) return TRUE;from function _captcha_validate($captcha_response)Comment #6
stefano@tipic.com commentedFIXES FOR TEXTIMAGE.MODULE
==========================
1) The permission "access textimages" is wrong, it must be "access textimage"
2) Mozilla Firefox needs "title" to show tooltip above image; translation fix added:
'#prefix' => '<img src="'.url('textimage/image/'.time()).'" title="'.t('Captcha Image: you will need to recognize the text in it.').'"/>'3) '#defaultvalue' replaced by '#default_value'
Comment #7
arnabdotorg commentedStefano, thanks for the fixes. Regarding Point #3 in captcha.module, it's an intentional usability feature: The user needs to provide, only ONCE per session, the proof that she/he is human. Regarding Point #2 in textimage.module, the ALT text is populated only as an (ironic) accesibility message, since XHTML requires it. This is used when you _can't_ see the image, not required otherwise.
Also, closing _this_ issue("Use hooks for captcha api, not includes") since hooks have replaced includes. All other problems go to another issue. Thanks a lot for the input!