You are here

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

Same name and namespace in other branches
  1. 6.2 model/botcha.model.inc \BotchaModel::getRecipebooksRecipes()
  2. 6.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksRecipes()
  3. 7.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksRecipes()
3 calls to BotchaModel::getRecipebooksRecipes()
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.
BotchaModel::getRecipesRecipebooks in model/botcha.model.inc
BotchaRecipebookAbstract::getRecipes in controller/botcha_recipebook.controller.inc
@todo BotchaRecipebook getRecipes Description.

File

model/botcha.model.inc, line 73

Class

BotchaModel

Code

public static function getRecipebooksRecipes($parameters = NULL) {

  // Get the value from the cache.

  //self::$recipebooks_recipes = &drupal_static('botcha_recipebooks_recipes');

  //if (empty(self::$recipebooks_recipes) || $parameters['reset']) {
  $fields = array();
  switch ($parameters['mode']) {
    case 'recipe':
      $fields[] = 'recipe_id';
      break;
    case 'recipebook':
    default:
      $fields[] = 'rbid';
      break;
  }
  $rbr = db_select('botcha_recipebook_recipe', 'brr')
    ->fields('brr', $fields);
  if (!empty($parameters['recipebooks'])) {
    $rbr
      ->condition('rbid', (array) $parameters['recipebooks'], 'IN');
  }
  if (!empty($parameters['recipes'])) {
    $rbr
      ->condition('recipe_id', (array) $parameters['recipes'], 'IN');
  }

  // 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 = $rbr
      ->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;
}