Mutual friendsnew function in u.module.php
Code
function mutualfriends($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';
// Mutual friends
$output = '<ul class="small_avatars">';
$res = 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={$profile['id']} and f2.uid={$client['id']} ORDER BY f1.created DESC LIMIT $offset, $num_per_page");
while ($row = sql_fetch_array($res)) {
$output .= '<li>';
$output .= '<span>'.url('u/'.$row['username'], $row['username']).'</span> '.avatar($row);
$output .= '</li>';
}
$output .= '</ul>';
// pager
$res = sql_query("select count(*) as total from ".tb()."friends as f1 inner join ".tb()."friends as f2 on f1.fid = f2.fid where f1.uid={$profile['id']} and f2.uid={$client['id']} ".dbhold() );
$row = sql_fetch_array($res);
$total = $row['total'];
$pb = new PageBar($total, $num_per_page, $page);
$pb->paras = $ubase.'u/'.$profile['username'].'/friends';
$pagebar = $pb->whole_num_bar();
$output .= $pagebar;
section(
array('title'=>t('Mutual Friends'),
'content'=>$output)
);
}
added some code in the function show_sidebar
before
Code
//friends
[b]AND THIS WHERE ???[/b]
Code
// Mutual friends
$res = 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={$owner['id']} and f2.uid={$client['id']} ".dbhold('f1')." ORDER BY f1.created DESC LIMIT 30");
$output = '';
while ($row = sql_fetch_array($res)) {
$f = 1;
$output .= avatar($row);
}
ass(array('title'=>t('Mutual Friends'), 'content' => '<div class="toolbar">'.url('u/'.$owner['username'] .'/mutualfriends',t('See all')).'</div>'.$output)); |