You are here

function _support_current_client in Support Ticketing System 7

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

Return the currently active client.

4 calls to _support_current_client()
support_pm_form_alter in support_pm/support_pm.module
support_pm_invoice_ui_form in support_pm/support_pm.module
Provide form for selecting projects.
support_pm_invoice_ui_form_submit in support_pm/support_pm.module
Add url filter when projects are selected.
_support_status_form_attach in ./support.module
Generate form for adding update to ticket. Enhances comment_form adding a ticket status bar.

File

./support.module, line 3852
support.module

Code

function _support_current_client() {
  $clients = _support_available_clients();

  // Allow plug-in modules to affect which is the currently active client.
  drupal_alter('support_current_client', $clients);
  if (count($clients) == 1) {
    $client = key($clients);
  }
  else {
    if (count($clients)) {
      if (isset($_SESSION['support_client']) && is_numeric($_SESSION['support_client'])) {
        $client = $_SESSION['support_client'];
      }
      else {
        if (!user_access('can select client')) {

          // TODO: It should be possible to set a default client.  Perhaps allow
          // a weight to be assigned to clients -- then we select the heaviest
          // matching client...?
          $client = key($clients);
        }
        else {
          $client = FALSE;
        }
      }
    }
    else {
      $client = FALSE;
    }
  }
  return $client;
}