Login     Sign up
Mutual friends
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

new 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)
        );
}   

[/code]

added some code in the function show_sidebar

before

[code]
//friends
[/code]

[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));
[/code]

165 months ago
emjhie Bahrink (@emjhie)
Join date: Sep 27th 2010
Community posts: 91
View Profile
Send Message

very nice.. Falcone the Master of Jcow..

165 months ago
DeFender (@defender)
Join date: Oct 1st 2010
Community posts: 167
View Profile
Send Message

yep dj master jcow

is it possible in v3.3 ?

165 months ago
DeFender (@defender)
Join date: Oct 1st 2010
Community posts: 167
View Profile
Send Message

nice I get it . thanks falcone

165 months ago
arizon efendi (@arizon)
Join date: Aug 26th 2010
Community posts: 145
View Profile
Send Message

nice job falcon. its work perfect at my network. thanks.

165 months ago
DeFender (@defender)
Join date: Oct 1st 2010
Community posts: 167
View Profile
Send Message

[quote=defender]

is it possible in v3.3 ? [/quote]

no need , thanks again,
only one thing
when I look at my profile, mutual and my friends are the same, it is possible not show mutual at own profile ?

165 months ago
Håvard Rylandsholm (@haavard)
Join date: Sep 24th 2010
Community posts: 51
View Profile
Send Message

[quote=defender]

when I look at my profile, mutual and my friends are the same, it is possible not show mutual at own profile ? [/quote]

yes, is it possible to hide it from (my profil) ?

165 months ago
Håvard Rylandsholm (@haavard)
Join date: Sep 24th 2010
Community posts: 51
View Profile
Send Message

when i pusch the link (see all) under Mutual Friends.

I get this error code:

Fatal error: Call to undefined method u::mutualfriends() in /mnt/webcluster1storage4/T/theracew/www/index.php on line 33

165 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

the are two parts, a new function called mutualfriends and a new section.

did you add the mutualfriends function in the u.module.php file (or u.php for older versions) ?

165 months ago
arizon efendi (@arizon)
Join date: Aug 26th 2010
Community posts: 145
View Profile
Send Message

do you have the script to hide mutual friend from (my profil) ?

165 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

[code]
// Mutual friends
if ($client['id'] != ($owner['id']) ) {

    $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");
    $mfs = sql_counts($res);
    $output = '';
    while ($row = sql_fetch_array($res)) {
        $output .= avatar($row);
    }
    if ($mfs > 0) {
    $mfstext = ($mfs == 1)?t(' friend in common'):t(' friends in common');  
    ass(array('title'=>t('Mutual Friends'), 'content' => '<div class="toolbar"><span style="float:left">'.$mfs.$mfstext.'</span><span style="float:right">'.url('u/'.$owner['username'] .'/mutualfriends',t('See all')).'</span></div><div style="clear:both;"></div>'.$output));
    }

}
[/code]

165 months ago
arizon efendi (@arizon)
Join date: Aug 26th 2010
Community posts: 145
View Profile
Send Message

oke falcone thanks. i will try.

165 months ago
1 2 3 4 5 Next