The result looks like this:

Functionality:
Show user´s friends
If is user not logged in or has no friends, this module is empty, but it is shown like other sidebar modules
Show user´s friend´s status:
- online
- idle
- offline
This status is represented by icons (but it can be changed anyway).
It is of course possible to change language of columns displayed (details later).
Send message to user´s friends
- It works smoothly, however in IE 6 when user send the message and click "close" is not possible to scroll down. This is not bug of this addon nor messaging module, i beleive it is bug in Internet Explorer. The solution is pretty simple - just press f5 to refresh or - the better way- download far better Opera or Firefox.
Requirements:
- Pligg (i have 9.7 but it should work on older versions)
- Php Designer or Notepad++ or similar tool,windows Notepad only for masochists
Needed downloads:
Alternative icons:
friends_online.ico
friends_idle.ico
friends_offline.ico
user_message.png
Place it into your ../templates/yget/images/ folder
Part 2 - What to do:
The first question to be answered is how we recognize if user has a friend?
This has been already done by friends addon. I hope you have it. So the second and more important thing is how we recognize if user is online,idle or offline?
After testing I´ve done it in two ways:
1)analysing friend´s inactivity time
2)checking if user is logged in and logged out
So there is first task for you. We need add 2 columns into user´s database. So log in to your phpadmin (or similar tool) and run sql query:
Code:
ALTER TABLE your_domain_users ADD COLUMN user_lastactivity timestamp; ALTER TABLE your_domain_users ADD COLUMN user_logged_in boolean;
2)Open friend.php which is located in ../libs/ folder. We need to modify sql query for our new 2 columns. So modify these two functions:
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;
}
Code:
function get_friend_list_2()
{
// returns an array of people who have added you as a friend
global $db, $current_user;
$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;
}
3) Open sidebar.tpl in your ../templates/yget/ folder. You may have another template but this could work one way or another.
Now you can choose WHERE new sidebar module should be placed. Personally i choose before tags, so i placed this code:
Code:
{assign var=sidebar_module value="sidebar_friends"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}
You can customize it - if you want to be this module visible only if the user is logged in, the code should look like this:
Code:
{if $user_authenticated eq true}
{assign var=sidebar_module value="sidebar_friends"}{include file=$the_template_sidebar_modules."/wrapper.tpl"}
{/if}
4) Create a new file, name it sidebar_friends.tpl and place it into your ../templates/yget/sidebar_modules folder
Add to this file these 3 lines:
Code:
{* ----- show the sidebar friends box ----- *}
{php}include('sidebar_friends.php');{/php}
{* ---------------------------------------- *}





)). On the other hand - integration into new version of Pligg only with this tut shouldnt be a problem as well
Linear Mode
