You are here

function regcode_og_get_rules in Registration codes 6.2

Same name and namespace in other branches
  1. 6 regcode_og/regcode_og.module \regcode_og_get_rules()

List all of the regcode rules

Parameters

array $tags A key => value array of tids and terms:

bool $list_all Return all rules:

2 calls to regcode_og_get_rules()
regcode_og_regcode_used in regcode_og/regcode_og.module
Implements hook_regcode_used()
regcode_og_rules_list_markup in regcode_og/regcode_og.module
Return the formatted HTML list

File

regcode_og/regcode_og.module, line 156

Code

function regcode_og_get_rules($tags = array(), $list_all = FALSE) {

  // Sanity check
  if (!count($tags) && !$list_all) {
    return array();
  }

  // Query
  $tid_string = implode(',', array_keys($tags));
  $query = 'SELECT id, term_data.name AS term, regcode_og.og AS ogid
            FROM {regcode_og} AS regcode_og
            LEFT JOIN {term_data} AS term_data ON {regcode_og.tid = term_data.tid}';
  if ($list_all) {
    $res = db_query($query);
  }
  else {
    $res = db_query($query . ' WHERE term_data.tid IN (%s)', $tid_string);
  }

  // Build array
  $rules = array();
  while ($row = db_fetch_array($res)) {
    $rules[] = $row;
  }
  return $rules;
}