function _drupalchat_get_sid in DrupalChat 7
Same name and namespace in other branches
- 6.2 drupalchat.module \_drupalchat_get_sid()
- 7.2 drupalchat.module \_drupalchat_get_sid()
9 calls to _drupalchat_get_sid()
- drupalchat_ex_auth in ./
drupalchat.module - 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.
File
- ./
drupalchat.module, line 68 - 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;
}
}
else {
if (variable_get('drupalchat_polling_method', DRUPALCHAT_AJAX) == DRUPALCHAT_COMMERCIAL) {
if ($user->uid > 0) {
return $user->uid;
}
else {
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;
}