You are here

function _support_client_terms in Support Ticketing System 6

Return an alphabetized list of all terms used with this client.

2 calls to _support_client_terms()
support_filter_form in ./support.module
Form builder; Return form for support ticket listing filters.
support_invoice_ui_form in ./support.module
Provide form for selecting projects.

File

./support.module, line 3776
support.module

Code

function _support_client_terms($clid, $state = NULL) {
  static $tids = array();
  if (is_array($clid)) {
    $clid = implode(',', $clid);
  }
  else {
    $clid = (int) $clid;
  }
  if (!isset($tids["{$clid}"][$state])) {
    $query_filter = _support_state_query_filter($state);
    if ($state < 0) {
      $query_filter .= 'AND st.state NOT IN (' . implode(', ', _support_get_state(SUPPORT_STATE_CLOSED)) . ')';
    }
    else {
      $query_filter .= $state ? "AND st.state = {$state}" : '';
    }
    $result = db_query('SELECT DISTINCT(tn.tid) AS tid, td.name FROM {support_ticket} st LEFT JOIN {term_node} tn ON st.nid = tn.nid LEFT JOIN {term_data} td ON tn.tid = td.tid WHERE st.client IN(%s) AND !ISNULL(tn.nid) ' . $query_filter . ' ORDER BY td.name ASC', $clid);
    while ($term = db_fetch_object($result)) {
      $tids["{$clid}"][$state][$term->tid] = $term->name;
    }
  }
  if (isset($tids["{$clid}"][$state])) {
    return $tids["{$clid}"][$state];
  }
  return NULL;
}