function _drupalchat_get_buddylist in DrupalChat 7
Same name and namespace in other branches
- 6.2 drupalchat.module \_drupalchat_get_buddylist()
- 7.2 drupalchat.module \_drupalchat_get_buddylist()
2 calls to _drupalchat_get_buddylist()
- drupalchat_settings_form_validate in ./
drupalchat.admin.inc - @todo Please document this function.
- _drupalchat_get_auth in ./
drupalchat.module
File
- ./
drupalchat.module, line 910 - 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 && function_exists('user_relationships_type_load') && function_exists('user_relationships_load')) {
$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);
}
}
}
else {
if ($drupalchat_rel == DRUPALCHAT_REL_FF) {
$fid = '1';
$final_list[$fid]['name'] = 'friend';
$final_list[$fid]['plural'] = 'friends';
$result = db_query("SELECT * FROM {flag_friend} WHERE uid = :uid OR friend_uid = :uid", array(
':uid' => $uid,
':friend_uid' => $uid,
));
foreach ($result as $friend) {
$uid == $friend->uid ? $final_list[$fid]['valid_uids'][] = $friend->friend_uid : ($final_list[$fid]['valid_uids'][] = $friend->uid);
}
}
}
return $final_list;
}