You are here

function _botcha_filter_form_log in BOTCHA Spam Prevention 6.3

Same name and namespace in other branches
  1. 6 botcha.botcha.inc \_botcha_filter_form_log()
  2. 6.2 botcha.inc \_botcha_filter_form_log()
  3. 7 botcha.botcha.inc \_botcha_filter_form_log()
  4. 7.2 botcha.inc \_botcha_filter_form_log()
  5. 7.3 botcha.module \_botcha_filter_form_log()

Filter out sensitive form data for logging Recursive.

2 calls to _botcha_filter_form_log()
Botcha::form_alter in controller/application/botcha.application.controller.inc
Implementation of hook_form_alter().
BotchaRecipebook::handle in controller/recipebook/botcha.recipebook.controller.inc
Handle form depending on the result of spam check.

File

./botcha.module, line 117
BOTCHA - Spam Prevention It modifies forms by adding various botcha's.

Code

function _botcha_filter_form_log($form, $level = 0) {
  if (is_array($form) && !is_string($form)) {
    foreach ($form as $key => $value) {
      if ($key == '#post') {
        $form[$key] = $level == 0 ? _botcha_filter_form_values_log($value) : t('...[redundand entry - removed]');
      }
      elseif ($key == '#parameters') {
        foreach ($value as $n => $arg) {
          $value[$n] = _botcha_filter_form_log($arg, -1);
        }
        $form[$key] = $value;
      }
      elseif (!element_property($key)) {

        // Handle recursion for $key == '#parameters'
        if ($level == -1) {
          $form[$key] = $key == 'pass' ? '********' : _botcha_filter_form_log($value, -1);
        }
        else {
          $form[$key] = _botcha_filter_form_log($value, $level + 1);
          if ($key == 'pass' && isset($form[$key]['#value'])) {
            $form[$key]['#value'] = '********';
          }
        }
      }
    }
  }
  return $form;
}