function botcha_set_form_id_setting in BOTCHA Spam Prevention 6
Same name and namespace in other branches
- 7 botcha.inc \botcha_set_form_id_setting()
Helper function for adding/updating a BOTCHA point.
Parameters
$form_id the form ID to configure.:
botcha_type the setting for the given form_id, can be::
- 'none' to disable BOTCHA,
- 'default' to use the default challenge type
- NULL to remove the entry for the BOTCHA type
Return value
nothing
17 calls to botcha_set_form_id_setting()
- BotchaAdminTestCase::testBotchaAdminLinks in ./
botcha.test - Testing of the BOTCHA administration links.
- BotchaAdminTestCase::testBotchaPlacementCacheFlushing in ./
botcha.test - Test the BOTCHA placement flushing.
- BotchaAdminTestCase::testBotchaPointSettingGetterAndSetter in ./
botcha.test - Test the BOTCHA point setting getter/setter.
- BotchaAdminTestCase::testUntrustedUserPosting in ./
botcha.test - BotchaSessionReuseAttackTestCase::testBotchaSessionReuseAttackDetectionOnCommentPreview in ./
botcha.test
File
- ./
botcha.inc, line 29 - General BOTCHA functionality and helper functions.
Code
function botcha_set_form_id_setting($form_id, $botcha_type) {
//watchdog('debug','IN botcha_set_form_id_setting form_id='.$form_id.' botcha_type='.$botcha_type);
if ($botcha_type == 'none') {
db_query("DELETE FROM {botcha_points} WHERE form_id = '%s'", $form_id);
db_query("INSERT INTO {botcha_points} (form_id, botcha_type) VALUES ('%s', NULL)", $form_id);
}
elseif ($botcha_type != NULL) {
db_query("DELETE FROM {botcha_points} WHERE form_id = '%s'", $form_id);
db_query("INSERT INTO {botcha_points} (form_id, botcha_type) VALUES ('%s', '%s')", $form_id, $botcha_type);
}
else {
db_query("DELETE FROM {botcha_points} WHERE form_id = '%s'", $form_id);
}
// else {
// drupal_set_message(t('Failed to set a BOTCHA type for form %form_id: could not interpret value "@botcha_type"',
// array('%form_id' => $form_id, '@botcha_type' => (string) $botcha_type)), 'warning');
// }
}