function captcha_set_form_id_setting in CAPTCHA 6.2
Same name and namespace in other branches
- 8 captcha.inc \captcha_set_form_id_setting()
- 7 captcha.inc \captcha_set_form_id_setting()
Helper function for adding/updating a CAPTCHA point.
Parameters
$form_id the form ID to configure.:
captcha_type the setting for the given form_id, can be::
- 'none' to disable CAPTCHA,
- 'default' to use the default challenge type
- NULL to remove the entry for the CAPTCHA type
- something of the form 'image_captcha/Image'
- an object with attributes $captcha_type->module and $captcha_type->captcha_type
Return value
nothing
17 calls to captcha_set_form_id_setting()
- CaptchaAdminTestCase::testCaptchaPlacementCacheFlushing in ./
captcha.test - Test the CAPTCHA placement flushing.
- CaptchaAdminTestCase::testCaptchaPointSettingGetterAndSetter in ./
captcha.test - Test the CAPTCHA point setting getter/setter.
- CaptchaAdminTestCase::testUntrustedUserPosting in ./
captcha.test - CaptchaAdminTestCase::testXssOnCaptchaDescription in ./
captcha.test - Test XSS vulnerability on CAPTCHA description.
- CaptchaPersistenceTestCase::setUpPersistence in ./
captcha.test - Set up the persistence and CAPTCHA settings.
File
- ./
captcha.inc, line 20 - General CAPTCHA functionality and helper functions.
Code
function captcha_set_form_id_setting($form_id, $captcha_type) {
if ($captcha_type == 'none') {
db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id);
db_query("INSERT INTO {captcha_points} (form_id, module, captcha_type) VALUES ('%s', NULL, NULL)", $form_id);
}
elseif ($captcha_type == 'default') {
db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id);
db_query("INSERT INTO {captcha_points} (form_id, module, captcha_type) VALUES ('%s', NULL, '%s')", $form_id, 'default');
}
elseif ($captcha_type == NULL) {
db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id);
}
elseif (is_object($captcha_type) && !empty($captcha_type->module) && !empty($captcha_type->captcha_type)) {
db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id);
db_query("INSERT INTO {captcha_points} (form_id, module, captcha_type) VALUES ('%s', '%s', '%s')", $form_id, $captcha_type->module, $captcha_type->captcha_type);
}
elseif (is_string($captcha_type) && substr_count($captcha_type, '/') == 1) {
list($module, $type) = explode('/', $captcha_type);
db_query("DELETE FROM {captcha_points} WHERE form_id = '%s'", $form_id);
db_query("INSERT INTO {captcha_points} (form_id, module, captcha_type) VALUES ('%s', '%s', '%s')", $form_id, $module, $type);
}
else {
drupal_set_message(t('Failed to set a CAPTCHA type for form %form_id: could not interpret value "@captcha_type"', array(
'%form_id' => $form_id,
'@captcha_type' => (string) $captcha_type,
)), 'warning');
}
}