function BotchaRecipebookAbstract::apply in BOTCHA Spam Prevention 6.2
Same name and namespace in other branches
- 7.2 controller/botcha_recipebook.controller.inc \BotchaRecipebookAbstract::apply()
File
- controller/
botcha_recipebook.controller.inc, line 373 - Controller layer of the BotchaRecipebook objects.
Class
- BotchaRecipebookAbstract
- @file Controller layer of the BotchaRecipebook objects.
Code
function apply(&$form, &$form_state) {
// @todo Abstract it.
//$form_state['no_cache'] = TRUE;
$form += array(
'#input' => TRUE,
);
// '#input'=1 hacks FAPI to call #process handler on the form
$form['#process'][] = 'botcha_fprocess';
if (!empty($_POST['form_build_id'])) {
$build_id = $_POST['form_build_id'];
$method = 'build_id_submit';
}
else {
$build_id = $form['#build_id'];
$method = 'build_id';
}
$this
->applyForBuildId($form, $form_state, $method, $build_id);
// User_login forms open session in validate hooks instead of submit
// we should be the first to validate - add our hook to the beginning
if (is_array($form['#validate'])) {
// Workaround since array_unshift'ing by reference was deprecated.
// @see http://www.php.net/manual/ru/function.array-unshift.php#40270
array_unshift($form['#validate'], '');
$form['#validate'][0] = '_botcha_form_validate';
}
else {
$form['#validate'] = array(
'_botcha_form_validate',
);
}
$form_state['#botcha'] = $this->id;
// Logging.
$csss = $this
->getCsss();
$jss = $this
->getJss();
if (BOTCHA_LOGLEVEL >= 4) {
watchdog(BOTCHA_LOG, '%form_id form prepared by BOTCHA: added recipes - !botchas!more', array(
'%form_id' => $form['form_id']['#value'],
'!botchas' => join(', ', $this->recipes),
'!more' => '' . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'POST=<pre>' . print_r(_botcha_filter_form_values_log($_POST), 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'GET=<pre>' . print_r(_botcha_filter_form_values_log($_GET), 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'SERVER=<pre>' . print_r($_SERVER, 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'form=<pre>' . print_r(_botcha_filter_form_log($form), 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 && count($jss) ? '<br /><br />' . 'JS=<pre>' . join("\n", $jss) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 && count($csss) ? '<br /><br />' . 'CSS=<pre>' . join("\n", $csss) . '</pre>' : ''),
), WATCHDOG_NOTICE);
}
}