You are here

function botcha_get_form_id_setting in BOTCHA Spam Prevention 7

Same name and namespace in other branches
  1. 6 botcha.inc \botcha_get_form_id_setting()

Get the BOTCHA 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 botcha_point object with fields 'type'. If argument $symbolic is true, returns (symbolic) as 'none', 'default', etc.

4 calls to botcha_get_form_id_setting()
BotchaAdminTestCase::assertBotchaSetting in ./botcha.test
Helper function for checking BOTCHA setting of a form.
BotchaAdminTestCase::testBotchaPointSettingGetterAndSetter in ./botcha.test
Test the BOTCHA point setting getter/setter.
botcha_form_alter in ./botcha.module
Implements hook_form_alter().
botcha_point_admin_form in ./botcha.pages.inc
Form for adding BOTCHA point.

File

./botcha.inc, line 68
General BOTCHA functionality and helper functions.

Code

function botcha_get_form_id_setting($form_id, $symbolic = FALSE) {
  $botcha_point = db_select('botcha_points', 'b')
    ->fields('b', array(
    'botcha_type',
  ))
    ->condition('form_id', $form_id)
    ->execute()
    ->fetchObject();
  if (empty($botcha_point)) {
    return NULL;
  }
  elseif ($botcha_point->botcha_type == NULL && $symbolic) {
    $botcha_point->botcha_type = 'none';
  }
  if ($symbolic) {
    $botcha_point = $botcha_point->botcha_type;
  }
  return $botcha_point;
}