function friendlist_activity_get_friends in Heartbeat 6.4
Same name and namespace in other branches
- 6.3 modules/friendlist_activity/friendlist_activity.module \friendlist_activity_get_friends()
Generate the view of people that a user is following
1 call to friendlist_activity_get_friends()
- friendlist_activity_heartbeat_related_uid_info in modules/
friendlist_activity/ friendlist_activity.module - Implementation of hook_heartbeat_related_uid_info().
File
- modules/
friendlist_activity/ friendlist_activity.module, line 117
Code
function friendlist_activity_get_friends($uid) {
$uids = array();
$api = variable_get('heartbeat_relations_api', 'none');
if ($api == 'friendlist_api') {
$sql = "SELECT fr.requestee_id as 'uid' FROM {friendlist_relations} as fr\n INNER JOIN {friendlist_statuses} fs ON fs.rid = fr.rid\n WHERE fr.requester_id = %d AND fs.status = '%s' ORDER BY fs.last_update_time DESC, fr.rid DESC";
$result = db_query($sql, $uid, 'TW_BOTH');
while ($row = db_fetch_object($result)) {
$uids[] = $row->uid;
}
}
elseif ($api == 'user_relationships_api') {
// If the current user is fan, following, ..., has a one way relation
// to the other user, or if he has a two way relation to the user ...
// fetch them
$sql = "SELECT DISTINCT ur.requestee_id FROM {user_relationships} ur\n INNER JOIN {user_relationship_types} urt ON ur.rtid = urt.rtid\n WHERE ur.requester_id = %d AND ur.approved = 1";
$result = db_query($sql, $uid, $uid);
if (!empty($result)) {
while ($row = db_fetch_object($result)) {
$uids[] = $row->requestee_id;
}
}
}
elseif ($api == 'flag_friend_api') {
$uids = array_keys(flag_friend_get_friends($uid));
}
return $uids;
}