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

modified function friends of u class

modified part between

// friends
and
//pager

[code]
$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']}"));
}
$output .= '<li>';
$output .= '<span>'.url('u/'.$row['username'], $row['username']).'</span> '.avatar($row);
if ((!$isfriend) && ($client['id'] != $row['id']) ) {
$output .= '<br />'.url('friends/add/'.$row['id'],t('add as friend'));
}
$output .= '</li>';
}
$output .= '</ul>';
[/code]

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

ty falcoe....tested immediately

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

nice. thank you falcone

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

Ty. Falcone.. very nice.... Adding friends on other members very nice and easy. May be you can make same code for browse members.(-_-).

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

its nice falcone... thanks

173 months ago
kingmagi (@king10magi)
Join date: Sep 6th 2010
Community posts: 97
View Profile
Send Message

is that u mean u.module.php???

[code]

$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']}"));
}
$output .= '<li>';
$output .= '<span>'.url('u/'.$row['username'], $row['username']).'</span> '.avatar($row);
if ((!$isfriend) && ($client['id'] != $row['id']) ) {
$output .= '<br />'.url('friends/add/'.$row['id'],t('add as friend'));
}
$output .= '</li>';
}
$output .= '</ul>';[/code]

and this code put under //friends and //pager??

Thank You,

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

adding friends from browse already online on jcowmaster.net

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

this is the modified function friends in the file u.module.php

[code]
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><img src="'.ubase().'/files/icons/'.$on_offline.'"><br/>';
$output .= avatar($row);
$output .= '<div style="word-wrap: break-word;">'.url('u/'.$row['username'], $row['username']).'</div>';
$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('Friend requested');
}
elseif ((!$isfriend) && ($client['id'] != $row['id']) ) {
$output .= '<br />'.url('friends/add/'.$row['id'],t('+1 Add as Friend'));
}
if ($row['is_waiting_friend_approval']){
$output .= '<br />'.url('friends/requests',t('+1 Confirm Friend'));
}
elseif ($row['is_waiting_friend_confirmation']){
$output .= '<br />'.t('Friend requested');
}
elseif ((!$isfriend) && ($client['id'] != $row['id']) ) {
$output .= '<br />'.url('friends/add/'.$row['id'],t('+1 Add as Friend'));
}
$output .= '</li>';

    }
    $output .= '</ul>';

    // pager
    $res = sql_query("select count(*) as total from `".tb()."friends` where uid='{$profile['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'=>'Friends',
        'content'=>$output)
        );
}

[/code]

172 months ago
kingmagi (@king10magi)
Join date: Sep 6th 2010
Community posts: 97
View Profile
Send Message

emm.. still not understand..

is that you mean paste the code into u.module.php and under friend function??

or need to change anything??

Thank You,

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

delete old friend function and put new one in place of it

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

it make double "+1 add as friend" and double "friend in common"

see picture
[img]http://temanku.net/data/teman.JPG[/img]

how to fix this?

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

code updated.

172 months ago
1 2 Next