You are here

function _support_states in Support Ticketing System 7

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

Helper function to list available states.

8 calls to _support_states()
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.
support_overview_summary_settings in support_overview/support_overview.module
Configure what to display on the summary page.

... See full list

File

./support.module, line 2996
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 = :phase1 ORDER BY weight", array(
          ':phase1' => 1,
        ));
      }
      else {
        if (!$all) {
          $result = db_query("SELECT sid, state FROM {support_states} WHERE phase2 = :phase2 ORDER BY weight", array(
            ':phase2' => 1,
          ));
        }
      }
    }
    foreach ($result as $state) {
      $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_query("SELECT state FROM {support_states} WHERE sid = :sid", array(
        ':sid' => $sid,
      ))
        ->fetchField();
    }
  }
  return $states["{$admin}-{$all}-{$sid}"];
}