You are here

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

Same name and namespace in other branches
  1. 6.3 model/application/botcha.application.model.inc \BotchaModel::getRecipebooksForms()
  2. 7.2 model/botcha.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 32

Class

BotchaModel

Code

public static function getRecipebooksForms($parameters = array()) {
  $key = '';
  switch ($parameters['mode']) {
    case 'form':
      $key = 'form_id';
      break;
    case 'recipebook':
    default:
      $key = 'rbid';
      break;
  }

  // Parameters to pass to the build query mechanism.
  $pars = array();
  $pars['fields'] = array();
  if (!empty($parameters['recipebooks'])) {
    $pars['conditions'][BOTCHA_MODEL_OP_IN]['rbid'] = (array) $parameters['recipebooks'];
  }
  if (!empty($parameters['forms'])) {
    $pars['conditions'][BOTCHA_MODEL_OP_IN]['form_id'] = (array) $parameters['forms'];
  }

  // Execute query and fetch the result.
  $query = BotchaModel::buildQuery(BOTCHA_MODEL_TYPE_SELECT, 'botcha_recipebook_form', $pars);
  $result_query = BotchaModel::getQueryResult($query['query'], $query['query_subs']);
  $result = BotchaModel::fetchQueryResult($result_query, $key);
  return $result;
}