function _drupalchat_get_sid in DrupalChat 7.2
Same name and namespace in other branches
- 6.2 drupalchat.module \_drupalchat_get_sid()
- 7 drupalchat.module \_drupalchat_get_sid()
7 calls to _drupalchat_get_sid()
- drupalchat_get_messages in ./drupalchat.module 
- drupalchat_get_messages_specific in ./drupalchat.module 
- drupalchat_get_thread_history in ./drupalchat.module 
- drupalchat_init in ./drupalchat.module 
- @todo Please document this function.
- drupalchat_poll in ./drupalchat.module 
- Process and get messages
File
- ./drupalchat.module, line 85 
- Module code for DrupalChat.
Code
function _drupalchat_get_sid($create = TRUE) {
  global $user;
  $sid = -1;
  if (check_plain(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;
    }
  }
  else {
    if (check_plain(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;
}