You are here

function _quiz_search_terms in Quiz 7

Same name and namespace in other branches
  1. 8.4 quiz.admin.inc \_quiz_search_terms()
  2. 6.4 quiz.admin.inc \_quiz_search_terms()
  3. 7.6 quiz.admin.inc \_quiz_search_terms()
  4. 7.4 quiz.admin.inc \_quiz_search_terms()
  5. 7.5 quiz.admin.inc \_quiz_search_terms()

Helper function for finding terms...

Parameters

string $start: The start of the string we are looking for

2 calls to _quiz_search_terms()
quiz_categorized_form_validate in ./quiz.admin.inc
Validate the categorized form
quiz_categorized_term_ahah in ./quiz.admin.inc
Ahah function for finding terms...

File

./quiz.admin.inc, line 776
Administrator interface for Quiz module.

Code

function _quiz_search_terms($start, $all = FALSE) {
  $terms = array();
  $sql_args = array_keys(_quiz_get_vocabularies());
  if (empty($sql_args)) {
    return $terms;
  }
  $query = db_select('term_data', 't')
    ->fields('t', array(
    'name',
    'tid',
  ))
    ->condition('t.vid', $sql_args, 'IN');
  if (!$all) {
    $query
      ->condition('t.name', '%' . $start . '%', 'LIKE');
  }
  $res = $query
    ->execute();

  // TODO Don't user db_fetch_object
  while ($res_o = db_fetch_object($res)) {
    $terms[$res_o->tid] = $res_o->name;
  }
  return $terms;
}