You are here

function _drupalchat_get_buddylist in DrupalChat 6.2

Same name and namespace in other branches
  1. 7.2 drupalchat.module \_drupalchat_get_buddylist()
  2. 7 drupalchat.module \_drupalchat_get_buddylist()
1 call to _drupalchat_get_buddylist()
_drupalchat_get_auth in ./drupalchat.module

File

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

Code

function _drupalchat_get_buddylist($uid, $drupalchat_ur_name = NULL) {
  $final_list = array();
  $drupalchat_rel = variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH);
  if ($drupalchat_ur_name == NULL) {
    $drupalchat_ur_name = variable_get('drupalchat_ur_name', 'friend');
  }
  if ($drupalchat_rel == DRUPALCHAT_REL_UR) {
    $r_names = drupal_explode_tags($drupalchat_ur_name);
    foreach ($r_names as $r_name) {
      $comp_r_name = user_relationships_type_load(array(
        'name' => $r_name,
      ), TRUE);
      $final_list[$comp_r_name->rtid]['name'] = $comp_r_name->name;
      $final_list[$comp_r_name->rtid]['plural'] = $comp_r_name->plural_name;
      $relationships = user_relationships_load(array(
        'rtid' => $comp_r_name->rtid,
        'user' => $uid,
        'approved' => 1,
      ), array(), TRUE);
      foreach ($relationships as $rid => $relationship) {
        $uid == $relationship->requester_id ? $final_list[$comp_r_name->rtid]['valid_uids'][] = $relationship->requestee_id : ($final_list[$comp_r_name->rtid]['valid_uids'] = $relationship->requester_id);
      }
    }
  }
  return $final_list;
}