You are here

function drupalchat_ex_auth in DrupalChat 7

Same name and namespace in other branches
  1. 6.2 drupalchat.module \drupalchat_ex_auth()
  2. 7.2 drupalchat.module \drupalchat_ex_auth()
1 string reference to 'drupalchat_ex_auth'
drupalchat_menu in ./drupalchat.module
Implements hook_menu().

File

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

Code

function drupalchat_ex_auth() {
  global $user;
  $user_name = NULL;
  $json = NULL;
  if (!$user->uid) {
    $sid = _drupalchat_get_sid();
    if (!(!$sid || $sid == -1)) {
      $user_name = drupalchat_get_current_guest_name();

      //$user_name = db_query('SELECT name FROM {drupalchat_users} WHERE uid = :uid AND session = :sid', array(':uid' => $user->uid, ':sid' => $sid,))->fetchField();
    }
  }
  else {
    $user_name = check_plain(format_username($user));
  }
  if ($user_name) {
    $json = _drupalchat_get_auth($user_name);
    $json['name'] = $user_name;
    $json['uid'] = $user->uid ? $user->uid : '0-' . _drupalchat_get_sid();
    if (variable_get('drupalchat_user_picture', 1) == 1) {
      $json['up'] = drupalchat_return_pic_url();
    }
    $json['upl'] = drupalchat_return_profile_url();
  }
  drupal_json_output($json);
}