[b]Thank You![/b]
But the code has problem, so I fix it. Paste it between // friends and // pager. Here's the code:
[code]$res = sql_query("SELECT u.* FROM ".tb()."friends as f left join ".tb()."accounts as u on u.id=f.fid where f.uid={$owner['id']} ".dbhold('f')." ORDER BY f.created DESC LIMIT 30");
$output = '';
while ($row = sql_fetch_array($res)) {
$f = 1;
$output .= avatar($row);
}
ass(array('title'=>t('Friends'), 'content' => '<div class="toolbar">'.url('u/'.$owner['username'] .'/friends',t('See all')).'</div>'.$output));
ass($this->details($owner));
}
function friends($url = 0) {
global $client, $apps, $uhome,$ubase, $current_sub_menu, $offset, $num_per_page, $page;
$profile = $this->settabmenu($url, 1,'u');
$current_sub_menu['href'] = 'u/'.$url.'/friends';
// friends
$output = '<ul class="gallery">';
$res = sql_query("SELECT u.* FROM ".tb()."friends as f left join ".tb()."accounts as u on u.id=f.fid where f.uid={$profile['id']} ORDER BY f.created DESC LIMIT $offset, $num_per_page");
while ($row = sql_fetch_array($res)) {
$isfriend = 0;
if (($client['id']) && ($client['id'] != $row['id'])) {
$isfriend = sql_counts(sql_query("SELECT * FROM ".tb()."friends WHERE uid={$row['id']} and fid={$client['id']}"));
}
$on_offline = ((time()-$row['lastlogin']) > 60)? 'offline.gif':'online.gif';
if ($client['id']) {
$res2 = sql_query("select * from ".tb()."friend_reqs where uid='{$client['id']}' and fid='{$row['id']}'");
$row2 = sql_fetch_array($res2);
if ($row2['uid']) {
$row['is_waiting_friend_confirmation'] = 1;
}
$res2 = sql_query("select * from ".tb()."friend_reqs where uid='{$row['id']}' and fid='{$client['id']}'");
$row2 = sql_fetch_array($res2);
if ($row2['uid']) {
$row['is_waiting_friend_approval'] = 1;
}
if ($row['id'] != $client['id']) {
$mfs = sql_counts(sql_query("SELECT u.* FROM ".tb()."friends as f1 inner join ".tb()."friends as f2 on f1.fid = f2.fid left join ".tb()."accounts as u on f1.fid=u.id where f1.uid={$row['id']} and f2.uid={$client['id']}"));
$mfslink = "";
if ($mfs > 0) {
if ($mfs == 1) {
$mfslink = url('u/'.$row['username'] .'/mutualfriends',$mfs.t(' friend in common'));
}
else {
$mfslink = url('u/'.$row['username'] .'/mutualfriends',$mfs.t(' friends in common'));
}
}
}
}
$output .= '<li>';
$output .= '<img src="'.uhome().'/files/icons/'.$on_offline.'"><br>';
$output .= avatar($row);
$output .= '<div style="word-wrap: break-word;">'.url('u/'.$row['username'], $row['username']).'</div><br>';
$output .= $mfslink;
if ($row['is_waiting_friend_approval']){
$output .= '<br />'.url('friends/requests',t('+1 Confirm Friend'));
}
elseif ($row['is_waiting_friend_confirmation']){
$output .= '<br />'.t('Waiting for friend request approval');
}
elseif ((!$isfriend) && ($client['id'] != $row['id']) ) {
$output .= '<br />'.url('friends/add/'.$row['id'],t('+1 Add as Friend'));
}
$output .= '</li>';
}
$output .= '</ul>';
[/code] |