You are here

function _drupalchat_get_sid in DrupalChat 6.2

Same name and namespace in other branches
  1. 7.2 drupalchat.module \_drupalchat_get_sid()
  2. 7 drupalchat.module \_drupalchat_get_sid()
8 calls to _drupalchat_get_sid()
drupalchat_get_messages in ./drupalchat.module
drupalchat_get_messages_specific in ./drupalchat.module
drupalchat_init in ./drupalchat.module
drupalchat_poll in ./drupalchat.module
Process and get messages
drupalchat_send in ./drupalchat.module
Send messages via ajax

... See full list

File

./drupalchat.module, line 73
Module code for DrupalChat.

Code

function _drupalchat_get_sid($create = TRUE) {
  global $user;
  $sid = -1;
  if (variable_get('drupalchat_polling_method', DRUPALCHAT_AJAX) == DRUPALCHAT_NODEJS && isset($_SESSION['nodejs_config']['authToken'])) {
    if (!isset($_SESSION['drupalchat']) && ($user->uid != 0 || $create) || $_SESSION['drupalchat']) {
      $sid = $_SESSION['nodejs_config']['authToken'];
      $_SESSION['drupalchat'] = TRUE;
    }
  }
  elseif (variable_get('drupalchat_polling_method', DRUPALCHAT_AJAX) == DRUPALCHAT_COMMERCIAL) {
    if ($user->uid > 0) {
      return $user->uid;
    }
    else {
      return false;

      //return drupalchat_get_current_guest_id();
    }
  }
  elseif ($user->uid == 0 && function_exists('session_api_get_sid')) {
    $_COOKIE['drupalchat_c_session'] = time();
    $sid = session_api_get_sid($create);
  }
  elseif ($user->uid > 0) {
    if (property_exists($user, 'sid')) {
      $sid = $user->sid;
    }
    else {
      $sid = '';
    }
  }
  return $sid;
}