0 GROUP BY u.uid ORDER BY COUNT(ur.requester_id OR ur.requestee_id) DESC ", $user->uid, $user->uid, $rtid); $user_rel_com = array(); while ($value = db_fetch_array($user_rel)) { $user_rel_com[] = $value; } //Exit if no users found. if (empty($user_rel_com)) { return; } foreach ($user_rel_com as $row) { $req_req_id_list .= " OR ur.requester_id = " . $row['uid'] . " OR ur.requestee_id = " . $row['uid']; $no_include_friends .= " AND u.uid <> ". $row['uid']; } //Trim the first " OR ". $req_req_id_list = drupal_substr($req_req_id_list, 4); //Get all of the current user's friends' friends and order by how many times they show up in the list. $user_rel_rel = db_query(" SELECT u.uid FROM {users} u LEFT JOIN {user_relationships} ur ON (u.uid = ur.requester_id OR u.uid = ur.requestee_id) WHERE (%s) AND ur.approved = 1 AND ur.rtid = %d AND u.uid <> %d %s AND u.status <> 0 GROUP BY u.uid ORDER BY COUNT(ur.requester_id OR ur.requestee_id) DESC ", $req_req_id_list, $rtid, $user->uid, $no_include_friends); $user_rel_rel_com = array(); while ($value = db_fetch_array($user_rel_rel)) { $user_rel_rel_com[] = $value['uid']; } //Scrambles the users non-randomly. Does not scramble the user at the bottom of the list. $z = $user_rel_rel_com; $i = 0; foreach ($user_rel_rel_com as $v) { $r = rand(0, 1); if ($r === 1 && $user_rel_rel_com[$i + 1]) { $z[$i] = $user_rel_rel_com[$i + 1]; $z[$i + 1] = $v; } $i++; } for ($i = 0; $i < $max; $i++) { if ($z[$i] != $user->uid) { $account = user_load(array('uid' => $z[$i])); $list[] = theme('user_picture', $account) .' '. theme('username', $account); } } //Theme with CSS as appropriate. "More" link is optional. echo ''. theme('item_list', $list) . l('More', 'uymn') .''; ?>