Доброго времени суток, как видно по названию темы хочу в профиле сделать в блоке друзья сортировку друзей по ORDER BY RAND() я так понял нужно в class_user.php рить но только непойму где, там есть типа
PHP:
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
// $friend_details (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER OR NOT TO RETRIEVE THE "FRIEND TYPE" AND "FRIEND EXPLANATION"
// OUTPUT: AN ARRAY OF THE USER'S FRIENDS
function user_friend_list($start, $limit, $direction = 0, $friend_status = 1, $sort_by = "se_users.user_dateupdated DESC", $where = "", $friend_details = 0, $other_user_id = 0)
{
global $database, $setting, $user;
if( !$other_user_id && $user->user_info['user_id'] != $this->user_info['user_id'] )
{
$other_user_id = $user->user_info['user_id'];
}
// SET VARIABLE
$friend_array = Array();
// MAKE SURE CONNECTIONS ARE ALLOWED
if( $setting['setting_connection_allow'] )
{
// BEGIN FRIEND QUERY
$friend_query = "
SELECT
se_friends.friend_id,
se_users.user_id,
se_users.user_username,
se_users.user_fname,
se_users.user_lname,
se_users.user_photo,
se_users.user_lastlogindate,
se_users.user_dateupdated
";
if( $other_user_id )
{
$friend_query .= ",
CASE
WHEN (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$other_user_id}' AND friend_user_id2=se_users.user_id AND friend_status='1' LIMIT 1)
THEN 2
WHEN (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$other_user_id}' AND friend_user_id2=se_users.user_id AND friend_status='0' LIMIT 1)
THEN 1
ELSE 0
END
AS is_viewers_friend
";
}
$friend_query .= ",
CASE
WHEN (SELECT TRUE FROM se_users AS se_users2 WHERE se_users2.user_id=se_users.user_id AND (user_blocklist LIKE '{$this->user_info['user_id']},%' OR user_blocklist LIKE '%,{$this->user_info['user_id']}' OR user_blocklist LIKE '%,{$this->user_info['user_id']},%') LIMIT 1)
THEN TRUE
ELSE FALSE
END
AS is_viewers_blocklisted
";
// GET FRIEND EXPLAIN, IF NECESSARY
if( $friend_details ) $friend_query .= ",
se_friends.friend_type,
se_friendexplains.friendexplain_body
";
// CONTINUE QUERY
$friend_query .= "
FROM
se_friends
LEFT JOIN
se_users ON
";
// MAKE SURE TO JOIN ON THE CORRECT FIELD (DEPENDENT ON DIRECTION)
if( $direction == 1 ) $friend_query .= "
se_friends.friend_user_id1=se_users.user_id
";
if( $direction != 1 ) $friend_query .= "
se_friends.friend_user_id2=se_users.user_id
";
// JOIN ON FRIEND EXPLAIN TABLE, IF NECESSARY
if( $friend_details ) $friend_query .= "
LEFT JOIN
se_friendexplains
ON se_friends.friend_id=se_friendexplains.friendexplain_friend_id
";
// CONTINUE QUERY
$friend_query .= "
WHERE
friend_status='{$friend_status}'
";
// EITHER "LIST OF WHO USER IS A FRIEND OF" OR "LIST OF USER'S FRIENDS"
if( $direction == 1 ) $friend_query .= " &&
friend_user_id2='{$this->user_info['user_id']}'
";
if( $direction != 1 ) $friend_query .= " &&
friend_user_id1='{$this->user_info['user_id']}'
";
// ADD ADDITIONAL WHERE CLAUSE IF EXISTS
if( $where ) $friend_query .= " &&
{$where}
";
// SET SORT AND LIMIT
$friend_query .= "
ORDER BY
{$sort_by}
LIMIT
{$start}, {$limit}
";
но незнаю ничего не выходит, вот кстати для онлайна сделал там проще в functions_general.php там вот
PHP:
// THIS FUNCTION RETURNS AN ARRAY CONTAINING THE USERNAMES OF ONLINE FRIENDS
// INPUT:
// OUTPUT: AN ARRAY OF USERNAMES FOR FRIENDS CURRENTLY ACTIVE IN THE SYSTEM
function online_friends() {
global $database, $owner;
// GET LOGGED IN FRIENDS ONLINE
$onlinefriends_array = Array();
$online_time = time()-60*60;
$online_friends = $database->database_query("SELECT u.user_username, u.user_fname, u.user_lname, u.user_id, u.user_photo
FROM se_users u
INNER JOIN se_friends f ON f.friend_user_id2=u.user_id WHERE f.friend_user_id1='{$owner->user_info['user_id']}'
&& u.user_lastactive > '$online_time' AND u.user_invisible=0 ORDER BY RAND() LIMIT 2000")
or die($database->database_error());
while($online_friend_info = $database->database_fetch_assoc($online_friends)) {
$online_friend = new se_user();
$online_friend->user_info[user_id] = $online_friend_info[user_id];
$online_friend->user_info[user_username] = $online_friend_info[user_username];
$online_friend->user_info[user_fname] = $online_friend_info[user_fname];
$online_friend->user_info[user_lname] = $online_friend_info[user_lname];
$online_friend->user_info[user_photo] = $online_friend_info[user_photo];
$online_friend->user_displayname();
// SET ONLINE FRIENDS ARRAY
$onlinefriends_array[] = $online_friend;
$onlinefriends_usernames[] = $online_friend->user_info[user_username];
}
// GET VISITORS ONLINE
$total_visitors = 0;
return Array($onlinefriends_array, $total_visitors, $onlinefriends_usernames);
} // END online_friends() FUNCTION
буду благодарен за помощь)