Sidebar Friends Module with messaging and activity

Register an Account
Reply
 
Thread Tools Display Modes
  #21 (permalink)  
Old 02-03-2008, 11:55 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Quote:
Originally Posted by tbones View Post
Could the display be limited to online and idle users?
As a result of some lucky trials I´ve found the following:

Go around line 78 in sidebar_friends.php:
Code:
echo '<tr>';
		
		if(isFriendOnline($friendActivity,$friendLogged)!=0) { 

            	echo '<td><img src="'.$friend_avatar.'" align="absmiddle"/> <a href="'.getmyurl('user2', $myfriend->user_login, 'profile'). '">' . $friendName.'</a></td>';
            
            
            	if (isFriendOnline($friendActivity,$friendLogged)==1){
              		echo '<td><img src='.my_pligg_base.'/templates/'.$the_template.'/images/friends_online.ico alt="online" style="margin-left:4px"></td>';}    
              	
			else {
              		echo '<td><img src='.my_pligg_base.'/templates/'.$the_template.'/images/friends_idle.ico alt="idle" style="margin-left:4px"></td>';}
                 }   
                    
       //     echo '<td><a href="#view_message" rel="view_message~!~view=small_msg_compose~!~login=' .$myfriend->user_login . '" class="lbOn">
       //     <img src='.my_pligg_base.'/templates/'.$the_template.'/images/user_message.png border=0 style="margin-left:12px"></a></td>';                    
       	     
echo '</tr>';
Reply With Quote
  #22 (permalink)  
Old 02-04-2008, 07:50 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
I go nuts! I really can´t understand why

Code:
 $friends = $db->get_results("SELECT " . table_users . ".user_login, " . table_users . ".user_avatar_source, " . table_users . ".user_email, " . table_users . ".user_id , " .table_users . ".user_lastactivity , " . table_users . ".user_logged_in FROM " . table_users . ");
as a generalization of this code

Quote:
Originally Posted by AnAlienHolakres3 View Post
function get_friend_list():
Code:
	// returns an array of people you've added as a friend
global $db, $current_user;
//echo "SELECT " . table_users . ".user_login FROM " . table_friends . " INNER JOIN " . table_users . " ON friends.friend_to = " . table_users . ".user_id WHERE (((friends.friend_from)=$current_user->user_id));";
$friends = $db->get_results("SELECT " . table_users . ".user_login, " . table_users . ".user_avatar_source, " . 
table_users . ".user_email, " . table_users . ".user_id , " .table_users . ".user_lastactivity , " . 
table_users . ".user_logged_in FROM " . table_friends . " INNER JOIN " . 
table_users . " ON " . table_friends . ".friend_to = " . 
table_users . ".user_id WHERE (((" . table_friends . ".friend_from)= " . $current_user->user_id . "));");
		return $friends;

	}
doensn´t work for my "who´s online" idea.
Reply With Quote
  #23 (permalink)  
Old 02-05-2008, 07:43 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
I have a first dirty solution that disables the friends list to get a "who´s online":

It´s very strange, instead of

Code:
 $friends = $db->get_results("SELECT " . table_users . ".user_login, " . table_users . ".user_avatar_source, " . table_users . ".user_email, " . table_users . ".user_id , " .table_users . ".user_lastactivity , " . table_users . ".user_logged_in FROM " . table_users . ");
I tried

Code:
$sql = "SELECT  user_login, user_lastactivity, user_logged_in FROM " . table_users . " WHERE user_logged_in =1";
$friends = $db->get_results($sql);
and it works but only with the WHERE extension, not without! (Thank you manya1011 for the inspiration!)

Edit: You can add an ORDER BY user_login to to SQL statement if you like.

Therefore the outer if-statement of sidebar_friends.php is redundant:
Code:
// if (isFriendOnline($friendActivity,$friendLogged)==1){
              		echo '<td><img src='.my_pligg_base.'/templates/'.$the_template.'/images/friends_online.ico alt="online" style="margin-left:4px"></td>';}    
              	
			else {
              		echo '<td><img src='.my_pligg_base.'/templates/'.$the_template.'/images/friends_idle.ico alt="idle" style="margin-left:4px"></td>';}
//                 }
A more sophisticated solution can be found here: http://forums.pligg.com/pligg-mods/1...ly-logged.html

Last edited by tbones; 02-06-2008 at 08:04 AM.
Reply With Quote
  #24 (permalink)  
Old 02-05-2008, 07:49 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Quote:
Originally Posted by tbones View Post
Could it be that it works just unidirectional?
I have only one friend definition in my database: B is a friend of A.

The display at A´s screen of B´s activity is normal but I don´t see any A activity at B`s screen.
Another small problem: Refresh (F5) doesn´t change the icon from idle to active.
Could you fix that, AnAlienHolakres3 ?

Edit: It doen´t update your own status at the moment of the refresh but at the very next moment it´s updated. Maybe it can be fixed by switching the order of some statements inside the function(s).

Last edited by tbones; 02-05-2008 at 08:31 PM.
Reply With Quote
  #25 (permalink)  
Old 02-05-2008, 08:17 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
If someone closes the browser window without logging out, the user will be idle forever.
Could you modify isFriendOnline() to trigger an auto-logout at the database after, let´s say, 60 minutes?
Reply With Quote
  #26 (permalink)  
Old 02-05-2008, 10:34 PM
Constant Pligger
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 159
Quote:
Originally Posted by tbones View Post
If someone closes the browser window without logging out, the user will be idle forever.
Could you modify isFriendOnline() to trigger an auto-logout at the database after, let´s say, 60 minutes?
Don't think u do it here its done with cookies somwhere else but that could be annoying, would be for me though..
Reply With Quote
  #27 (permalink)  
Old 02-05-2008, 10:58 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Just to be meant as a first workaround
Reply With Quote
  #28 (permalink)  
Old 02-06-2008, 06:38 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
I´m not a coder at all, sorry:

Quote:
Originally Posted by tbones View Post
Therefore the outer if-statement of sidebar_friends.php is redundant:
Code:
// if (isFriendOnline($friendActivity,$friendLogged)==1){
              		echo '<td><img src='.my_pligg_base.'/templates/'.$the_template.'/images/friends_online.ico alt="online" style="margin-left:4px"></td>';}    
              	
			else {
              		echo '<td><img src='.my_pligg_base.'/templates/'.$the_template.'/images/friends_idle.ico alt="idle" style="margin-left:4px"></td>';}
//                 }
This is nonsense! First of all, it should be the condition ($friendActivity,$friendLogged)!=0). Secondly, both are necessary since

Code:
  if (($idleLimit < $friendLastActivity) && $friendLogged){    
        if(($onlineLimit < $friendLastActivity) && $friendLogged){
                        return 1;
        }else          return 2;
    }else           return 0;
of sidebar_friends.php evaluates to 0 if more than 20 minutes have past in idle status. This makes my post about closing browser windows (#25) redundant. Sorry about bothering you!

Edit: This can also happen to the only person logged in, i.e. a refresh after 20+ minutes shows nobody in the list due to the behaviour observed at post #24.

Last edited by tbones; 02-06-2008 at 06:46 AM.
Reply With Quote
  #29 (permalink)  
Old 02-07-2008, 03:50 PM
Casual Pligger
 
Join Date: Jan 2007
Posts: 44
I hope to have this fixed on 1.0 version!
Reply With Quote
  #30 (permalink)  
Old 02-07-2008, 03:59 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Have you tried the presented solution?
Reply With Quote
Reply

Thread Tools
Display Modes




Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development