1

Topic: Latest friends on the memer_profile page

does anyone have the extension on the  5 latest friend   i tried this code.... but it does not work


ext.latest_friends.php:

<?php
/*
=====================================================
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2007 VLD Interactive
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
=====================================================
*/

$data = array(
    'name' => 'Latest friends entries',
    'about' => 'Display the most recent guestbook entries of a selected member.',
    'author' => 'VLD Interactive',
    'email' => 'support@vldpersonals.com',
    'help' => 'http://www.vldpersonals.com/downloads/extensions/',
    'website' => 'http://www.vldpersonals.com',
);

function vldext_latest_friends ($params = array())
{
    global $DB, $SESSION, $PREFS, $TEMPLATE, $CACHE;

    $limit = isset($params['limit']) && $params['limit'] ? intval($params['limit']) : 4;
    $member_id = isset($params['member_id']) && $params['member_id'] ? mysql_real_escape_string($params['member_id']) : 0;
    $comments_form = isset($params['comments_form']) && $params['comments_form'] ? 1 : 0;
    $cache_time = isset($params['cache_time']) && $params['cache_time'] ? intval($params['cache_time']) : 5;
    $cache_name = isset($params['cache_name']) && $params['cache_name'] ? "_".$params['cache_name'] : "";
    $cache = isset($params['cache']) ? intval($params['cache']) : 1;

    $fields = array();
    if ( !$cache || ($fields = $CACHE->get("ext", "latest_friends_$member_id".$cache_name)) === false ) {

    $result = $DB->query("SELECT f.friend_id, m.* $sqlquery
                          FROM " . DB_PREFIX . "members AS m, " . DB_PREFIX . "members_data AS d, " . DB_PREFIX . "friends AS f
                          WHERE ( (f.member_id='$id' AND f.friend_id=m.member_id) OR (f.friend_id='$id' AND f.member_id=m.member_id) )
                                  AND m.member_id=d.data_id AND f.pending=0
                          ORDER BY m.screenname ASC");


        if ( $DB->num_rows($result) )
        {
            $i = 0;
            while( $entries_obj = $DB->fetch_object($result) )
            {
                $fields[$i]['member_id'] = $entries_obj->poster_id;
                $fields[$i]['member_group_id'] = $entries_obj->group_id;
                $fields[$i]['member_username'] = $entries_obj->username;
                $fields[$i]['member_email'] = $entries_obj->email;
                $fields[$i]['member_screenname'] = htmlentities2utf8($entries_obj->screenname);
                $fields[$i]['member_total_visits'] = $entries_obj->totalvisits;
                $fields[$i]['member_total_visitors'] = $entries_obj->totalvisitors;
                $fields[$i]['member_total_pictures'] = $entries_obj->totalactivepictures;
                $fields[$i]['member_total_videos'] = $entries_obj->totalactivevideos;
                $fields[$i]['member_total_favorites'] = $entries_obj->totalfavorites;
                $fields[$i]['member_total_blocked'] = $entries_obj->totalblocked;
                $fields[$i]['member_total_messages'] = ($entries_obj->totalimessages+$entries_obj->totalsmessages);
                $fields[$i]['member_new_messages'] = $entries_obj->newmessages;
                $fields[$i]['member_time_zone'] = $entries_obj->timezone;
                $fields[$i]['member_active'] = $entries_obj->active;
                $fields[$i]['member_ip_address'] = $entries_obj->ipaddress;
                $fields[$i]['member_total_guestbook_entries'] = $entries_obj->totalactiveguestbooks;
                $fields[$i]['member_total_blog_entries'] = $entries_obj->totalblogs;
                $fields[$i]['member_join_date'] = $SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->joindate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->joindate, $SESSION->conf['timezone']*60));
                $fields[$i]['member_last_visit'] = $entries_obj->lastvisit ? ($SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->lastvisit, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->lastvisit, $SESSION->conf['timezone']*60))) : 0;
                $fields[$i]['member_expiration_date'] = $entries_obj->expirationdate ? ($SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->expirationdate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->expirationdate, $SESSION->conf['timezone']*60))) : 0;
                $fields[$i]['member_online'] = ((time() - $entries_obj->lastvisit) < $PREFS->conf['user_timeout']*60) ? 1 : 0;
                $fields[$i]['member_profile_link'] = $PREFS->conf['fancy_urls'] ? ($PREFS->conf['fancy_homepages'] ? $entries_obj->username : "member/".$entries_obj->poster_id)."/" : "index.php?m=member_profile&p=profile&id=" . $entries_obj->poster_id;
                $fields[$i]['entry_id'] = $entries_obj->entry_id;
                $fields[$i]['member_friends_link'] = $PREFS->conf['fancy_urls'] ? "member/$id/friends/" : "index.php?m=member_friends&p=friends&id=$id");
                $fields[$i]['entry_body'] = nl2br(htmlentities2utf8($entries_obj->body));
                $fields[$i]['entry_post_date'] = $SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->postdate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->postdate, $SESSION->conf['timezone']*60));
                $fields[$i]['member_picture_pending'] = $entries_obj->pending;
                $fields[$i]['member_picture_adult'] = $entries_obj->adult;
                $fields[$i]['member_picture_preview'] = $entries_obj->picture ? $PREFS->conf['thumbnail_prefix'] . 'picture_' . $entries_obj->picture : '';
                $fields[$i]['member_picture_filename'] = $entries_obj->picture ? 'picture_' . $entries_obj->picture : '';
                $i++;
            }
        }

        if ( $cache ) {
            $CACHE->put("ext", "latest_friends_$member_id".$cache_name, $cache_time, $fields);
        }
    }

    $_SESSION['captcha'] = random_string(5);

    $TEMPLATE->assign("ext_latest_freinds_entries", $fields);



    $TEMPLATE->output('ext.latest_friends.tpl');
}

?>

ext.latest_friends.tpl:

<div class="ext_thumbnails">

    <div class="flatheader">
        <h3 class="visitors">Latest Blogs</h3>
    </div>
    <div class="flatgrid">
        <div class="single">
            <table cellpadding="0" cellspacing="0" class="flatgrid">
                <!-- BEGIN ext_latest_friends -->
                    <tr>
                        <td class="item" align="center">
                            <div class="image">
                                <!-- IF member_picture -->
                                    <a href="{top.virtual_path}{member_profile_link}"><img src="{top.virtual_pic_path}{member_picture}" alt="" border="0" /><br /></a>
                                <!-- ELSE -->
                                    <a href="{top.virtual_path}{member_profile_link}"><img src="{top.virtual_tpl_path}{top.loggedin_template}/media/user_picture_none.gif" alt="" border="0" /><br /></a>
                                <!-- ENDIF -->
                                <h4><a href="{top.virtual_path}{member_profile_link}">{trim:member_username,10,""}</a></h4>
                            </div>
                        </td>
                    </tr>
                <!-- END ext_latest_friends -->
            </table>
        </div>
    </div>
    <div class="clear"></div>

</div>

{latest_friends:member_id=member_id,limit=1,comments_form=1,cache=0}

Last edited by nasim___ (2007-10-29 13:26:28)

2

Re: Latest friends on the memer_profile page

anyonee???

3

Re: Latest friends on the memer_profile page

At the first: If author of extension is not Vlad do NOT mention him as author.
At the second: you need to remove $sqlquery since that variable is null and you don't fiil it in your code.
At third: I don't know why you need $_SESSION['captcha']??? You don't need it.
At fourth: You put your data to ext_latest_friends_entries but in your template you are parsing ext_latest_friends.


At last: Good try Nasim, I hope you'll make it work.

www.vldMagic.com - first choice customizations help desk
www.vldCrowd.com/radioact - my profile at vldCrowd

4

Re: Latest friends on the memer_profile page

how about this.. have made the changes:

Code:
<?php
/*
=====================================================
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2007 VLD Interactive
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
=====================================================
*/

$data = array(
    'name' => 'Latest friends entries',
    'about' => 'Display the most recent guestbook entries of a selected member.',
    'author' => 'Nasim Larki',
    'email' => 'nasim___@hotmail.com',
    'help' => 'http://www.vldpersonals.com/downloads/extensions/',
    'website' => 'http://www.notsetyet.com',
);

function vldext_latest_friends ($params = array())
{
    global $DB, $SESSION, $PREFS, $TEMPLATE, $CACHE;

    $limit = isset($params['limit']) && $params['limit'] ? intval($params['limit']) : 4;
    $member_id = isset($params['member_id']) && $params['member_id'] ? mysql_real_escape_string($params['member_id']) : 0;
    $comments_form = isset($params['comments_form']) && $params['comments_form'] ? 1 : 0;
    $cache_time = isset($params['cache_time']) && $params['cache_time'] ? intval($params['cache_time']) : 5;
    $cache_name = isset($params['cache_name']) && $params['cache_name'] ? "_".$params['cache_name'] : "";
    $cache = isset($params['cache']) ? intval($params['cache']) : 1;

    $fields = array();
    if ( !$cache || ($fields = $CACHE->get("ext", "latest_friends_$member_id".$cache_name)) === false ) {

    $result = $DB->query("SELECT f.friend_id, m.
                          FROM " . DB_PREFIX . "members AS m, " . DB_PREFIX . "members_data AS d, " . DB_PREFIX . "friends AS f
                          WHERE ( (f.member_id='$id' AND f.friend_id=m.member_id) OR (f.friend_id='$id' AND f.member_id=m.member_id) )
                                  AND m.member_id=d.data_id AND f.pending=0
                          ORDER BY m.screenname ASC");


        if ( $DB->num_rows($result) )
        {
            $i = 0;
            while( $entries_obj = $DB->fetch_object($result) )
            {
                $fields[$i]['member_id'] = $entries_obj->poster_id;
                $fields[$i]['member_group_id'] = $entries_obj->group_id;
                $fields[$i]['member_username'] = $entries_obj->username;
                $fields[$i]['member_email'] = $entries_obj->email;
                $fields[$i]['member_screenname'] = htmlentities2utf8($entries_obj->screenname);
                $fields[$i]['member_total_visits'] = $entries_obj->totalvisits;
                $fields[$i]['member_total_visitors'] = $entries_obj->totalvisitors;
                $fields[$i]['member_total_pictures'] = $entries_obj->totalactivepictures;
                $fields[$i]['member_total_videos'] = $entries_obj->totalactivevideos;
                $fields[$i]['member_total_favorites'] = $entries_obj->totalfavorites;
                $fields[$i]['member_total_blocked'] = $entries_obj->totalblocked;
                $fields[$i]['member_total_messages'] = ($entries_obj->totalimessages+$entries_obj->totalsmessages);
                $fields[$i]['member_new_messages'] = $entries_obj->newmessages;
                $fields[$i]['member_time_zone'] = $entries_obj->timezone;
                $fields[$i]['member_active'] = $entries_obj->active;
                $fields[$i]['member_ip_address'] = $entries_obj->ipaddress;
                $fields[$i]['member_total_guestbook_entries'] = $entries_obj->totalactiveguestbooks;
                $fields[$i]['member_total_blog_entries'] = $entries_obj->totalblogs;
                $fields[$i]['member_join_date'] = $SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->joindate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->joindate, $SESSION->conf['timezone']*60));
                $fields[$i]['member_last_visit'] = $entries_obj->lastvisit ? ($SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->lastvisit, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->lastvisit, $SESSION->conf['timezone']*60))) : 0;
                $fields[$i]['member_expiration_date'] = $entries_obj->expirationdate ? ($SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->expirationdate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->expirationdate, $SESSION->conf['timezone']*60))) : 0;
                $fields[$i]['member_online'] = ((time() - $entries_obj->lastvisit) < $PREFS->conf['user_timeout']*60) ? 1 : 0;
                $fields[$i]['member_profile_link'] = $PREFS->conf['fancy_urls'] ? ($PREFS->conf['fancy_homepages'] ? $entries_obj->username : "member/".$entries_obj->poster_id)."/" : "index.php?m=member_profile&p=profile&id=" . $entries_obj->poster_id;
                $fields[$i]['entry_id'] = $entries_obj->entry_id;
                $fields[$i]['member_friends_link'] = $PREFS->conf['fancy_urls'] ? "member/$id/friends/" : "index.php?m=member_friends&p=friends&id=$id");
                $fields[$i]['entry_body'] = nl2br(htmlentities2utf8($entries_obj->body));
                $fields[$i]['entry_post_date'] = $SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->postdate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->postdate, $SESSION->conf['timezone']*60));
                $fields[$i]['member_picture_pending'] = $entries_obj->pending;
                $fields[$i]['member_picture_adult'] = $entries_obj->adult;
                $fields[$i]['member_picture_preview'] = $entries_obj->picture ? $PREFS->conf['thumbnail_prefix'] . 'picture_' . $entries_obj->picture : '';
                $fields[$i]['member_picture_filename'] = $entries_obj->picture ? 'picture_' . $entries_obj->picture : '';
                $i++;
            }
        }

        if ( $cache ) {
            $CACHE->put("ext", "latest_friends_$member_id".$cache_name, $cache_time, $fields);
        }
    }


    $TEMPLATE->assign("ext_latest_freinds", $fields);



    $TEMPLATE->output('ext.latest_friends.tpl');

Last edited by nasim___ (2007-10-31 09:47:34)

5

Re: Latest friends on the memer_profile page

At first glance:
$result = $DB->query("SELECT f.friend_id, m.

change to
$result = $DB->query("SELECT f.friend_id, m.*

www.vldMagic.com - first choice customizations help desk
www.vldCrowd.com/radioact - my profile at vldCrowd

6

Re: Latest friends on the memer_profile page

Hello radioact can you please contact me at: henrykusa@hotmail.com ?  I need ot ask you something please.

Thanks

7

Re: Latest friends on the memer_profile page

hmm i tried it but it dident work.nothing shows..
here is the code:

ext.latest_friends.php:

<?php
/*
=====================================================
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2007 VLD Interactive
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
=====================================================
*/

$data = array(
    'name' => 'Latest friends entries',
    'about' => 'Display the most recent guestbook entries of a selected member.',
    'author' => 'Nasim Larki',
    'email' => 'nasim___@hotmail.com',
    'help' => 'http://www.vldpersonals.com/downloads/extensions/',
    'website' => 'http://www.notsetyet.com',
);


function vldext_latest_friends ($params = array())
{
    global $DB, $SESSION, $PREFS, $TEMPLATE, $CACHE;

    $limit = isset($params['limit']) && $params['limit'] ? intval($params['limit']) : 4;
    $member_id = isset($params['member_id']) && $params['member_id'] ? mysql_real_escape_string($params['member_id']) : 0;
    $comments_form = isset($params['comments_form']) && $params['comments_form'] ? 1 : 0;
    $cache_time = isset($params['cache_time']) && $params['cache_time'] ? intval($params['cache_time']) : 5;
    $cache_name = isset($params['cache_name']) && $params['cache_name'] ? "_".$params['cache_name'] : "";
    $cache = isset($params['cache']) ? intval($params['cache']) : 1;

    $fields = array();
    if ( !$cache || ($fields = $CACHE->get("ext", "latest_friends_$member_id".$cache_name)) === false ) {

    $result = $DB->query("SELECT f.friend_id, m.*
                          FROM " . DB_PREFIX . "members AS m, " . DB_PREFIX . "members_data AS d, " . DB_PREFIX . "friends AS f
                          WHERE ( (f.member_id='$id' AND f.friend_id=m.member_id) OR (f.friend_id='$id' AND f.member_id=m.member_id) )
                                  AND m.member_id=d.data_id AND f.pending=0
                          ORDER BY m.screenname ASC");


        if ( $DB->num_rows($result) )
        {
            $i = 0;
            while( $entries_obj = $DB->fetch_object($result) )
            {
                $fields[$i]['member_id'] = $entries_obj->poster_id;
                $fields[$i]['member_group_id'] = $entries_obj->group_id;
                $fields[$i]['member_username'] = $entries_obj->username;
                $fields[$i]['member_email'] = $entries_obj->email;
                $fields[$i]['member_screenname'] = htmlentities2utf8($entries_obj->screenname);
                $fields[$i]['member_total_visits'] = $entries_obj->totalvisits;
                $fields[$i]['member_total_visitors'] = $entries_obj->totalvisitors;
                $fields[$i]['member_total_pictures'] = $entries_obj->totalactivepictures;
                $fields[$i]['member_total_videos'] = $entries_obj->totalactivevideos;
                $fields[$i]['member_total_favorites'] = $entries_obj->totalfavorites;
                $fields[$i]['member_total_blocked'] = $entries_obj->totalblocked;
                $fields[$i]['member_total_messages'] = ($entries_obj->totalimessages+$entries_obj->totalsmessages);
                $fields[$i]['member_new_messages'] = $entries_obj->newmessages;
                $fields[$i]['member_time_zone'] = $entries_obj->timezone;
                $fields[$i]['member_active'] = $entries_obj->active;
                $fields[$i]['member_ip_address'] = $entries_obj->ipaddress;
                $fields[$i]['member_total_guestbook_entries'] = $entries_obj->totalactiveguestbooks;
                $fields[$i]['member_total_blog_entries'] = $entries_obj->totalblogs;
                $fields[$i]['member_join_date'] = $SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->joindate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->joindate, $SESSION->conf['timezone']*60));
                $fields[$i]['member_last_visit'] = $entries_obj->lastvisit ? ($SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->lastvisit, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->lastvisit, $SESSION->conf['timezone']*60))) : 0;
                $fields[$i]['member_expiration_date'] = $entries_obj->expirationdate ? ($SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->expirationdate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->expirationdate, $SESSION->conf['timezone']*60))) : 0;
                $fields[$i]['member_online'] = ((time() - $entries_obj->lastvisit) < $PREFS->conf['user_timeout']*60) ? 1 : 0;
                $fields[$i]['member_profile_link'] = $PREFS->conf['fancy_urls'] ? ($PREFS->conf['fancy_homepages'] ? $entries_obj->username : "member/".$entries_obj->poster_id)."/" : "index.php?m=member_profile&p=profile&id=" . $entries_obj->poster_id;
                $fields[$i]['entry_id'] = $entries_obj->entry_id;
                $fields[$i]['member_friends_link'] = $PREFS->conf['fancy_urls'] ? "member/$id/friends/" : "index.php?m=member_friends&p=friends&id=$id";
                $fields[$i]['entry_body'] = nl2br(htmlentities2utf8($entries_obj->body));
                $fields[$i]['entry_post_date'] = $SESSION->conf['timeformat'] ? date("m/d/Y h:i A", get_date($entries_obj->postdate, $SESSION->conf['timezone']*60)) : date("d/m/Y H:i", get_date($entries_obj->postdate, $SESSION->conf['timezone']*60));
                $fields[$i]['member_picture_pending'] = $entries_obj->pending;
                $fields[$i]['member_picture_adult'] = $entries_obj->adult;
                $fields[$i]['member_picture_preview'] = $entries_obj->picture ? $PREFS->conf['thumbnail_prefix'] . 'picture_' . $entries_obj->picture : '';
                $fields[$i]['member_picture_filename'] = $entries_obj->picture ? 'picture_' . $entries_obj->picture : '';
                $i++;
            }
        }

        if ( $cache ) {
            $CACHE->put("ext", "latest_friends_$member_id".$cache_name, $cache_time, $fields);
        }
    }


    $TEMPLATE->assign("ext_latest_freinds", $fields);



    $TEMPLATE->output('ext.latest_friends.tpl');
}

?>

ext.latest_friends.tpl:

<div class="ext_thumbnails">

    <div class="flatheader">
        <h3 class="visitors">Latest friends</h3>
    </div>
    <div class="flatgrid">
        <div class="single">
            <table cellpadding="0" cellspacing="0" class="flatgrid">
                <tr>
                    <!-- BEGIN ext_latest_friends -->
                        <td class="item" align="center">
                            <div class="image">
                                <!-- IF member_picture -->
                                    <a href="{top.virtual_path}{member_profile_link}"><img src="{top.virtual_pic_path}{member_picture}" alt="" border="0" /><br /></a>
                                <!-- ELSE -->
                                    <a href="{top.virtual_path}{member_profile_link}"><img src="{top.virtual_tpl_path}{top.loggedin_template}/media/user_picture_none.gif" alt="" border="0" /><br /></a>
                                <!-- ENDIF -->
                                <h4><a href="{top.virtual_path}{member_profile_link}">{trim:member_username,10,""}</a></h4>
                            </div>
                        </td>
                    <!-- END ext_latest_friends -->
                </tr>
            </table>
            <div class="clear"></div>
        </div>
    </div>
    <div class="clear"></div>

</div>

and this :      {latest_friends:limit=3,pictures=1,cache_time=1} on member profile

8

Re: Latest friends on the memer_profile page

I suppose you are very tired of trying to make it work man smile I've had some hard work to do this days with my site. Tonight or tomorrow I'll take your code and make it work. Take a rest friend.

www.vldMagic.com - first choice customizations help desk
www.vldCrowd.com/radioact - my profile at vldCrowd

9

Re: Latest friends on the memer_profile page

thanks radioact... your the man smile

10

Re: Latest friends on the memer_profile page

I made latest friends extension you can take it here

You can modify *.tpl file any way you like and even add link "more friends..." if you want.
Detailed info at special Release page. I hope you (forget - deleted smile)) forgive me for borrowing this idea and putting my copyrights wink

P.S.: And here the source of .php file for comparing to your variant.

function vldext_latest_friends ($params = array())
{
    global $DB, $SESSION, $PREFS, $TEMPLATE, $CACHE;

    $limit = isset($params['limit']) && $params['limit'] ? intval($params['limit']) : 8;
    $member_id = isset($params['member_id']) && $params['member_id'] ? mysql_real_escape_string($params['member_id']) : 0;
    $cache_time = isset($params['cache_time']) && $params['cache_time'] ? intval($params['cache_time']) : 5;
    $cache_name = isset($params['cache_name']) && $params['cache_name'] ? "_".$params['cache_name'] : "";
    $cache = isset($params['cache']) ? intval($params['cache']) : 1;

    $fields = array();
    if ( !$cache || ($fields = $CACHE->get("ext", "latest_friends_$member_id".$cache_name)) === false ) {

    //------------------------------------------------
    // Get friends
    //------------------------------------------------

    $result = $DB->query("SELECT f.friend_id, m.*
                          FROM " . DB_PREFIX . "members AS m, " . DB_PREFIX . "members_data AS d, " . DB_PREFIX . "friends AS f
                          WHERE ( (f.member_id='$member_id' AND f.friend_id=m.member_id) OR (f.friend_id='$member_id' AND f.member_id=m.member_id) )
                          AND m.member_id=d.data_id AND f.pending=0
                          ORDER BY f.request_date DESC
                          LIMIT $limit");


        if ( $DB->num_rows($result) )
        {
            $i = 0;
            while( $profile_obj = $DB->fetch_object($result) )
            {
                $fields[$i]['member_id'] = $profile_obj->member_id;
                $fields[$i]['member_username'] = $profile_obj->username;
                $fields[$i]['member_screenname'] = htmlentities2utf8($profile_obj->screenname);
                $fields[$i]['member_picture'] = $profile_obj->picture ? $PREFS->conf['thumbnail_prefix'] . 'picture_' . $profile_obj->picture : "";
                $fields[$i]['member_online'] = ((time() - $profile_obj->lastvisit) < $PREFS->conf['user_timeout']*60) ? 1 : 0;
                $fields[$i]['member_profile_link'] = $PREFS->conf['fancy_urls'] ? ($PREFS->conf['fancy_homepages'] ? $profile_obj->username : "member/".$profile_obj->member_id."/") : "index.php?m=member_profile&p=profile&id=" . $profile_obj->member_id;
                $i++;
            }
        }

        if ( $cache ) {
            $CACHE->put("ext", "latest_friends_$member_id".$cache_name, $cache_time, $fields);
        }
    }


    $TEMPLATE->assign("ext_latest_friends", $fields);


    $TEMPLATE->output('ext.latest_friends.tpl');
}

Last edited by radioact (2007-11-06 01:52:54)

www.vldMagic.com - first choice customizations help desk
www.vldCrowd.com/radioact - my profile at vldCrowd

11

Re: Latest friends on the memer_profile page

tahnx radiact.... big_smile

12

Re: Latest friends on the memer_profile page

How to add online option? it tried to add this in code to show friends online as paremetar online=1
{latest_friends:member_id=member_id,online=1,cache=0}

But it shows no results. And i for sure have few friends online.

<?php
/*
=====================================================
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2007 VLD Interactive
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
=====================================================
*/

$data = array(
    'name' => 'Latest friends',
    'about' => 'Display the most recent friends of a selected member.',
    'author' => 'Ramil Zhunussov',
    'email' => 'ramil@zhunussov.com',
    'help' => '',
    'website' => 'http://www.zhunussov.com',
);

function vldext_latest_friends ($params = array())
{
    global $DB, $SESSION, $PREFS, $TEMPLATE, $CACHE;

    $limit = isset($params['limit']) && $params['limit'] ? intval($params['limit']) : 8;
    $member_id = isset($params['member_id']) && $params['member_id'] ? mysql_real_escape_string($params['member_id']) : 0;
    $online = isset($params['online']) && $params['online'] ? 1 : 0;
    $cache_time = isset($params['cache_time']) && $params['cache_time'] ? intval($params['cache_time']) : 5;
    $cache_name = isset($params['cache_name']) && $params['cache_name'] ? "_".$params['cache_name'] : "";
    $cache = isset($params['cache']) ? intval($params['cache']) : 1;

    $fields = array();
    if ( !$cache || ($fields = $CACHE->get("ext", "latest_friends_$member_id".$cache_name)) === false ) {

    //------------------------------------------------
    // Get friends
    //------------------------------------------------

    $result = $DB->query("SELECT f.friend_id, m.*
                          FROM " . DB_PREFIX . "members AS m, " . DB_PREFIX . "members_data AS d, " . DB_PREFIX . "friends AS f
                          WHERE ( (f.member_id='$member_id' AND f.friend_id=m.member_id) OR (f.friend_id='$member_id' AND f.member_id=m.member_id) )
                          AND m.member_id=d.data_id AND f.pending=0
                          " . ($online ? "AND m.lastvisit > " . ( time() - $PREFS->conf['user_timeout']*60 ) : "") . "
                          ORDER BY f.request_date DESC
                          
                          LIMIT $limit");


        if ( $DB->num_rows($result) )
        {
            $i = 0;
            while( $profile_obj = $DB->fetch_object($result) )
            {
                $fields[$i]['member_id'] = $profile_obj->member_id;
                $fields[$i]['member_username'] = $profile_obj->username;
                $fields[$i]['member_screenname'] = htmlentities2utf8($profile_obj->screenname);
                $fields[$i]['member_picture'] = $profile_obj->picture ? $PREFS->conf['thumbnail_prefix'] . 'picture_' . $profile_obj->picture : "";
                $fields[$i]['member_online'] = ((time() - $profile_obj->lastvisit) < $PREFS->conf['user_timeout']*60) ? 1 : 0;
                $fields[$i]['member_profile_link'] = $PREFS->conf['fancy_urls'] ? ($PREFS->conf['fancy_homepages'] ? $profile_obj->username : "member/".$profile_obj->member_id."/") : "index.php?m=member_profile&p=profile&id=" . $profile_obj->member_id;
                $i++;
            }
        }

        if ( $cache ) {
            $CACHE->put("ext", "latest_friends_$member_id".$cache_name, $cache_time, $fields);
        }
    }


    $TEMPLATE->assign("ext_latest_friends", $fields);


    $TEMPLATE->output('ext.latest_friends.tpl');
}

?>

and template

<div class="paragraph">Online friends: 
                <!-- BEGIN ext_latest_friends -->
                <font size=2><a href="{top.virtual_path}{member_profile_link}">{member_username}</a>, </font>
                <!-- END ext_latest_friends -->

13

Re: Latest friends on the memer_profile page

I tried to show freinds without online with original code, but i does not show any results. Is this ext for latest version at all?

14

Re: Latest friends on the memer_profile page

Is also possible to show friends by coincidence because last friends is like your last friends bevore you die big_smile
and i think is more beautifull show everytime other friends from your list because on the last you remember but on the first too? and when change everytime the content is also better for comunication between the members

15

Re: Latest friends on the memer_profile page

can some Upload thei http://www.zhunussov.com/uploads/ext.latest_friends.zip
again for the Latest friends on the memer_profile page extension plz

-----------------------------------------
www.my-desi.de | the real desi community
   -----------------------------------------

16

Re: Latest friends on the memer_profile page

Please ask radioact if he can update the download link for you !

Give the world the best you have, and the best will come to you.
Tutorials and Mods for VldPersonals  Add CometChat to your vldPersonals site