You are here

function _drupalchat_buddylist in DrupalChat 6

Same name and namespace in other branches
  1. 6.2 drupalchat.module \_drupalchat_buddylist()
  2. 7.2 drupalchat.module \_drupalchat_buddylist()
  3. 7 drupalchat.module \_drupalchat_buddylist()
2 calls to _drupalchat_buddylist()
drupalchat_poll in ./drupalchat.module
Process and get messages
_drupalchat_chat in ./drupalchat.module

File

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

Code

function _drupalchat_buddylist($uid) {
  $users = array();
  $drupalchat_rel = variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH);
  if ($drupalchat_rel == DRUPALCHAT_REL_UR) {
    $relationships = user_relationships_load(array(
      'name' => variable_get('drupalchat_ur_name', 'friend'),
      'user' => $uid,
      'approved' => 1,
    ), array(), TRUE);
    foreach ($relationships as $rid => $relationship) {
      $uid == $relationship->requester_id ? $users[] = $relationship->requestee_id : ($users[] = $relationship->requester_id);
    }
  }
  elseif ($drupalchat_rel == DRUPALCHAT_REL_FF) {
    $result = db_query("SELECT * FROM {flag_friend} WHERE uid = %d OR friend_uid = %d", $uid, $uid);
    while ($friend = db_fetch_object($result)) {
      $uid == $friend->uid ? $users[] = $friend->friend_uid : ($users[] = $friend->uid);
    }
  }
  return $users;
}