function captcha_get_form_id_setting in CAPTCHA 6.2
Same name and namespace in other branches
- 8 captcha.inc \captcha_get_form_id_setting()
- 7 captcha.inc \captcha_get_form_id_setting()
Get the CAPTCHA setting for a given form_id.
Parameters
$form_id the form_id to query for:
$symbolic flag to return as (symbolic) strings instead of object.:
Return value
NULL if no setting is known or a captcha_point object with fields 'module' and 'captcha_type'. If argument $symbolic is true, returns (symbolic) as 'none', 'default' or in the form 'captcha/Math'.
4 calls to captcha_get_form_id_setting()
- CaptchaAdminTestCase::assertCaptchaSetting in ./
captcha.test - Helper function for checking CAPTCHA setting of a form.
- CaptchaAdminTestCase::testCaptchaPointSettingGetterAndSetter in ./
captcha.test - Test the CAPTCHA point setting getter/setter.
- captcha_form_alter in ./
captcha.module - Implementation of hook_form_alter().
- captcha_point_admin_form in ./
captcha.admin.inc
File
- ./
captcha.inc, line 58 - General CAPTCHA functionality and helper functions.
Code
function captcha_get_form_id_setting($form_id, $symbolic = FALSE) {
if (module_exists('ctools')) {
ctools_include('export');
$captcha_points = ctools_export_load_object('captcha_points', 'names', array(
$form_id,
));
$captcha_point = array_pop($captcha_points);
}
else {
$result = db_query("SELECT module, captcha_type FROM {captcha_points} WHERE form_id = '%s'", $form_id);
if (!$result) {
return NULL;
}
$captcha_point = db_fetch_object($result);
}
if (!$captcha_point) {
$captcha_point = NULL;
}
elseif (!empty($captcha_point->captcha_type) && $captcha_point->captcha_type == 'default') {
if (!$symbolic) {
list($module, $type) = explode('/', variable_get('captcha_default_challenge', 'captcha/Math'));
$captcha_point->module = $module;
$captcha_point->captcha_type = $type;
}
else {
$captcha_point = 'default';
}
}
elseif (empty($captcha_point->module) && empty($captcha_point->captcha_type) && $symbolic) {
$captcha_point = 'none';
}
elseif ($symbolic) {
$captcha_point = $captcha_point->module . '/' . $captcha_point->captcha_type;
}
return $captcha_point;
}