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>";
?> And add
PHP Code:
{* ----- show the friends box ----- *}
{php}include('profile_friends.php');{/php}
{* ---------------------------------------- *}
PHP Code:
</fieldset>
</div>





Linear Mode

