Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-11-2008, 02:50 PM
Casual Pligger
 
Join Date: May 2008
Posts: 50
Thanks: 16
Thanked 5 Times in 5 Posts
Profile Friends Box

I have been trying to consolidate the freinds list as well as friend management and private messaging into a box on the main profile page. I have also changed the inbox and compose links to go straight to their respective pages, not using litebox.

I modified the Module To also include a delete button, as well as formatting it to fit into the profile page;




To do this you will need to complete the steps outlined here-Online sidebar Specifically the modification to the DB, login.php, and friend.php.

PHP Code:
   <?php
//@created by AnAlienHolakres3 for Pligg community

include_once('Smarty.class.php');
$main_smarty = new Smarty;


include_once(
'config.php');
include_once(
mnminclude.'html1.php');
include_once(
mnminclude.'link.php');
include_once(
mnminclude.'tags.php');
include_once(
mnminclude.'search.php');
include_once(
mnminclude.'smartyvariables.php');
include_once(
mnminclude.'friend.php');
include_once(
mnminclude.'user.php');

// -------------------------------------------------------------------------------------

global $the_template$main_smarty$db;

//============================================================================
// Function isFriendOnline($friendActivity,$friendLogged)  decides if is user online,idle or offline and 
// returns its numbers. 
//@param friendActivity=timestamp of last friend activity
//@param friendLogged=false or true if is user logged in
// @return 0 if user is OFFLINE => last activity > 20 minutes
// @return 1 if user is ONLINE => last activity < 10 minutes
// @return 2 if user is IDLE  =>    10minutes < last activity < 20 minutes

// you can set,ONLINE and IDLE  TIME parameters in MINUTES:
//============================================================================
function isFriendOnline($friendActivity,$friendLogged) {
    
    
$online =  10;
    
$idle 20;    
    
$friendLastActivity strtotime($friendActivity);

$onlineLimit time() - $online*60;
$idleLimit =  time() - $idle*60;
  
  
    if ((
$idleLimit $friendLastActivity) && $friendLogged){    
        if((
$onlineLimit $friendLastActivity) && $friendLogged){
                        return 
1;
        }else          return 
2;
    }else           return 
0;

}
//============================================================================
// Function do_viewfriendsside() is modified function of do_viewfriends in user.php, it 
// does nearly the same thing but modified for using in sidebar and also update database
// for current user activity
//============================================================================
function do_viewfriendsside(){
    global 
$db$user$the_template,$current_user,$main_smarty;
    
    
$friend = new Friend;
    
$friends $friend->get_friend_list();    
    
    
//refresh user activity
    
$sql "UPDATE " table_users " SET user_lastactivity = FROM_UNIXTIME(".time().") WHERE user_id=" $current_user->user_id ."";
        
$db->query($sql);

    if (
$friends){
      echo 
"<fieldset><legend>Friends</legend><table border=\"0\" style=\"margin-bottom:5px\"><th style=\"text-align=left\">" .$main_smarty->get_config_vars('PLIGG_Visual_Friends_Username')."</th><th align=\"center\">".
      
$main_smarty->get_config_vars('PLIGG_Visual_Friends_Status')."</th><th>" $main_smarty->get_config_vars('PLIGG_Visual_Friends_Message')."</th>";
        foreach(
$friends as $myfriend) {
            
$friend_avatar get_avatar('small'$myfriend->user_avatar_source$myfriend->user_login$myfriend->user_email);
            
$friendActivity=$myfriend->user_lastactivity;         //time of last activity
            
$friendLogged=$myfriend->user_logged_in;               //user logged in =1, logged out = 0
            
$friendName $myfriend->user_login;

             
//if is username too long
                 
if (strlen($friendName)>16) {
                  
$friendName substr($friendName,0,14)."..";
                 };
            
          echo 
'<tr>';
            echo 
'<td><img src="'.$friend_avatar.'" align="absmiddle"/> <a href="'.getmyurl('user2'$myfriend->user_login'profile'). '">' $friendName.'</a>';
            
            
            if (
isFriendOnline($friendActivity,$friendLogged)==0){
              echo 
'<img src='.my_pligg_base.'/templates/'.$the_template.'/images/offline.png alt="offline" style="margin-left:25px">';}    
              
             elseif (
isFriendOnline($friendActivity,$friendLogged)==1) {
              echo 
'<img src='.my_pligg_base.'/templates/'.$the_template.'/images/online.png alt="online" style="margin-left:25px">';}
                    
            elseif(
isFriendOnline($friendActivity,$friendLogged)==2) { 
                 echo 
'<img src='.my_pligg_base.'/templates/'.$the_template.'/images/idle.png alt="offline" style="margin-left:25px">';}
            
            echo 
'<a href="'my_pligg_base '/module.php?module=simple_messaging&view=inbox&return=' .$myfriend->user_login '" class="lbOn">
            <img src='
.my_pligg_base.'/templates/'.$the_template.'/images/user_message.png border=0 style="margin-left:15px"></a>';                    
           
        
        echo 
'<a href="'my_pligg_base '/module.php?module=simple_messaging&view=compose&return=' urlencode($_SERVER['REQUEST_URI']) .'&to='.$myfriend->user_login '" class="lbOn">
            <img src='
.my_pligg_base.'/templates/'.$the_template.'/images/messageuser.png border=0 style="margin-left:15px"></a>';                    
           
        echo 
'<a href = "'.getmyurl('user_add_remove'$myfriend->user_login'removefriend').'"><img src='.my_pligg_base.'/templates/'.$the_template.'/images/user_delete.png border=0 style="margin-left:15px"></a></td>';
            
            echo 
'</tr>';
        
        }
        echo 
'</table>';
         echo 
'';
    }

     
    
    else {
        return 
false;
    }
}

    echo 
"<div class=\"tlb\" style=\"margin-top:10px;margin-bottom:10px\"><span></div><div id=sidefriends>";


do_viewfriendsside();


echo 
"</fieldset></div>";

?>
Save that as profile_friends.php

And add

PHP Code:
{* ----- show the friends box ----- *}

    {
php}include('profile_friends.php');{/php}

{* ---------------------------------------- *} 
To the end of user_center.tpl right after the last

PHP Code:
     </fieldset>

                </
div
Here are the icons used -icons
__________________
OSS Supporter.
Reply With Quote
The Following User Says Thank You to method20 For This Useful Post:
  #2 (permalink)  
Old 09-11-2008, 03:07 PM
Casual Pligger
Pligg Version: 9.8
Pligg Template: yellow
 
Join Date: Dec 2007
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
excellent work .....i wll try it out tonight
Reply With Quote
  #3 (permalink)  
Old 09-11-2008, 05:21 PM
micxuy's Avatar
Casual Pligger
 
Join Date: May 2007
Posts: 89
Thanks: 2
Thanked 3 Times in 3 Posts
its cool however i relise one thing, whenever you go to other profile it will still show your friends, not their friend (if you are login)

Thanks
__________________
www.drivensource.net

Driven Source is a community driven resource for all webmasters. Find cool scripts, read tutorials, dicuss news or submit
Reply With Quote
The Following User Says Thank You to micxuy For This Useful Post:
  #4 (permalink)  
Old 09-11-2008, 07:30 PM
Casual Pligger
 
Join Date: May 2008
Posts: 50
Thanks: 16
Thanked 5 Times in 5 Posts
Quote:
Originally Posted by micxuy View Post
its cool however i relise one thing, whenever you go to other profile it will still show your friends, not their friend (if you are login)

Thanks
Thanks I just realized that.

Adding this will show the box only on your profile page;

PHP Code:
{if $user_login eq $user_logged_in}

    {* ----- 
show the friends box ----- *}

    {
php}include('profile_friends.php');{/php}

{* ---------------------------------------- *}
{/if} 
__________________
OSS Supporter.
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixes to Profile Extra Fields Module v0.2 and Extended Profile Module v0.1 redwine Modification Tutorials 3 10-18-2008 10:28 AM
Sidebar Friends Module with messaging and activity AnAlienHolakres3 Modification Tutorials 31 02-09-2008 06:54 AM
Newline ability needed for a field in user profile rossoonline General Help 0 09-18-2007 06:23 PM
Tabbed Menu and Profile!!! Just about done... Genghis General Help 1 05-11-2007 03:43 AM
Suggestion for friends view dollars5 Suggestions 0 04-10-2007 12:52 PM


Search Engine Friendly URLs by vBSEO 3.2.0