You are here

function _support_states in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support.module \_support_states()

Helper function to list available states.

12 calls to _support_states()
support_filter_form in ./support.module
Form builder; Return form for support ticket listing filters.
support_form_alter in ./support.module
Customize comment form for ticket followups.
support_mailcmd_support_fetch_message_alter in support_mailcmd/support_mailcmd.module
Implementation of hook_support_fetch_message_alter().
support_menu in ./support.module
Implementation of hook_menu().
support_overview_summary in support_overview/support_overview.module
Display support ticket overview, highlighting ticket queues with tickets older than a configurable age limit.

... See full list

File

./support.module, line 2581
support.module

Code

function _support_states($all = TRUE, $sid = NULL, $account = NULL) {
  static $states = array();
  $admin = user_access('can administer state', $account);
  if (!isset($states["{$admin}-{$all}-{$sid}"])) {
    if ($admin || $all) {
      $result = db_query("SELECT sid, state FROM {support_states} ORDER BY weight");
    }
    else {
      if (!$all && !$sid) {
        $result = db_query("SELECT sid, state FROM {support_states} WHERE phase1 = 1 ORDER BY weight");
      }
      else {
        if (!$all) {
          $result = db_query("SELECT sid, state FROM {support_states} WHERE phase2 = 1 ORDER BY weight");
        }
      }
    }
    while ($state = db_fetch_object($result)) {
      $states["{$admin}-{$all}-{$sid}"][$state->sid] = $state->state;
    }

    // include the current state, even if user doesn't actually have access
    if ($sid && !in_array($sid, $states["{$admin}-{$all}-{$sid}"])) {
      $states["{$admin}-{$all}-{$sid}"][$sid] = db_result(db_query("SELECT state FROM {support_states} WHERE sid = %d", $sid));
    }
  }
  return $states["{$admin}-{$all}-{$sid}"];
}