You are here

public static function BotchaModel::getRecipebooksForms in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 model/botcha.model.inc \BotchaModel::getRecipebooksForms()
  2. 6.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksForms()
  3. 7.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksForms()
4 calls to BotchaModel::getRecipebooksForms()
Botcha::getRecipebook in controller/botcha.controller.inc
Gets a recipe book from cache. If it does not exists in cache - gets from database. If it does not exists there also - returns new recipe book or BotchaRecipebookNone depending on input parameter.
BotchaFormAbstract::getRecipebook in controller/botcha_form.controller.inc
@todo BotchaForm getRecipebook Description.
BotchaModel::getFormsRecipebooks in model/botcha.model.inc
Just an alias for getRecipebooksForms.
BotchaRecipebookAbstract::getForms in controller/botcha_recipebook.controller.inc
@todo BotchaRecipebook getForms Description.

File

model/botcha.model.inc, line 29

Class

BotchaModel

Code

public static function getRecipebooksForms($parameters = array()) {

  // Get the value from the cache.

  //self::$recipebooks_forms = &drupal_static('botcha_recipebooks_forms');

  //if (empty(self::$recipebooks_forms) || $parameters['reset']) {
  $fields = array();
  switch ($parameters['mode']) {
    case 'form':

      //return self::$recipebooks_forms->fetchAllAssoc('form_id');
      $fields[] = 'form_id';
      break;
    case 'recipebook':
    default:

      //return self::$recipebooks_forms->fetchAllAssoc('rbid');
      $fields[] = 'rbid';
      break;
  }
  $rbf = db_select('botcha_recipebook_form', 'brf')
    ->fields('brf', $fields);
  if (!empty($parameters['recipebooks'])) {
    $rbf
      ->condition('rbid', (array) $parameters['recipebooks'], 'IN');
  }
  if (!empty($parameters['forms'])) {
    $rbf
      ->condition('form_id', (array) $parameters['forms'], 'IN');
  }

  //self::$recipebooks_forms = $rbf;

  //}

  // Catching of PDOException helps to avoid WSOD during update use case. The
  // reason is in that form_alter is called before performing an update.
  // @see http://drupal.org/node/1828710
  try {
    $result = $rbf
      ->execute()
      ->fetchCol();
  } catch (Exception $e) {
    if ($e instanceof PDOException) {
      watchdog_exception('BOTCHA', $e, 'Please perform an update via update.php or reinstall the BOTCHA module to fix the reason of this warning! %type: !message in %function (line %line of %file).', array(), WATCHDOG_WARNING);
      $result = array();
    }
  }
  return $result;
}