How to alert you about new message and friend request on account page

Page Builder -> Account

1)
add a new HTML-block

Caption Lang Key: _New Friend and Message

2)
add a new language key

Key name: _New Friend and Message
Category: System
String text for English language: New Messages and Friends Request

3)
edit table sys_page_compose (the last ID)

Desc: Show new messages and friends request
Caption: _New Friend and Message
Func: PHP
Content: Pfriend();

4)
Add this code to file inc/design.inc.php (above this function: get_member_thumbnail)

function Pfriend(){
global $site;
global $oTemplConfig;

$User = getNickName($ID);
$SQLselect = mysql_query("SELECT Profiles.ID, Profiles.NickName, sys_friend_list.Profile
FROM Profiles
INNER JOIN sys_friend_list
ON Profiles.ID = sys_friend_list.Profile
WHERE Profiles.NickName = '$User'
AND sys_friend_list.Check = '0'");


$alertText = '<span style="color:maroon;font-size:20px;text-shadow:1px 1px 3px #000;">';
$alertTextE = '</span>';

$row = mysql_num_rows($SQLselect);
if($row == 1):
echo MsgBox('<img src="templates/base/images/icons/action_broadcast.png"><a href="/communicator.php?&communicator_mode=friends_requests"> ' . $alertText . $row . ' Friend Request</a>' . $alertTextE);
elseif($row >= 2):
echo MsgBox('<img src="templates/base/images/icons/action_broadcast.png"><a href="/communicator.php?&communicator_mode=friends_requests"> ' . $alertText . $row . ' Friend Requests</a>' . $alertTextE);
else:
echo '';
endif;

$User = getNickName($ID);
$SQLselect = mysql_query("SELECT Profiles.ID, Profiles.Headline, Profiles.NickName, sys_messages.New, sys_messages.Recipient
FROM Profiles
INNER JOIN sys_messages
ON Profiles.ID = sys_messages.Recipient
WHERE Profiles.NickName = '$User'
AND sys_messages.New = '1' ORDER BY sys_messages.New");


$alertText = '<span style="color:maroon;font-size:20px;text-shadow:1px 1px 3px #000;">';
$alertTextE = '</span>';

$row = mysql_num_rows($SQLselect);
if($row == 1):
echo MsgBox('<img src="templates/base/images/icons/mails.png"><a href="/mail.php?mode=inbox"> ' . $alertText . $row . ' New Message</a>' . $alertTextE);
elseif($row >= 2):
echo MsgBox('<img src="templates/base/images/icons/mails.png"><a href="/mail.php?mode=inbox"> ' . $alertText . $row . ' New Messages</a>' . $alertTextE);
else:
echo '';
endif;

}


5)
Clear cache

6) DONE

Quote · 6 Jun 2012
this is awesome and works great :) Thank you lot okweb
DedicatedServer4You.com -- BIGGEST Range of Dedicated Servers at the Lowest Price!
Quote · 7 Jun 2012

Thanks okweb!

Was reading the other post http://www.boonex.com/forums/topic/Friend-Request-2011-03-11.htm too.

Your solution is much more elegant!

Added the following in red to make it work globally. :)Cool

echo MsgBox('<img src="templates/base/images/icons/action_broadcast.png"><a href="'.BX_DOL_URL_ROOT.'communicator.php?&communicator_mode=friends_requests"> ' . $alertText . $row . ' Friend Request</a>' . $alertTextE);
elseif($row >= 2):
echo MsgBox('<img src="templates/base/images/icons/action_broadcast.png"><a href="'.BX_DOL_URL_ROOT.'communicator.php?&communicator_mode=friends_requests"> ' . $alertText . $row . ' Friend Requests</a>' . $alertTextE);

 

echo MsgBox('<img src="templates/base/images/icons/mails.png"><a href="'.BX_DOL_URL_ROOT.'mail.php?mode=inbox"> ' . $alertText . $row . ' New Message</a>' . $alertTextE);
elseif($row >= 2):
echo MsgBox('<img src="templates/base/images/icons/mails.png"><a href="'.BX_DOL_URL_ROOT.'mail.php?mode=inbox"> ' . $alertText . $row . ' New Messages</a>' . $alertTextE);

Quote · 8 Jul 2012

It works GREAT!!!

THANK you very much.

Greetings from Germany

Quote · 12 Aug 2012

Upps... I have detected a problem. When Memeber delete his Messsages before reading, the counter show still New Messages.

I

 

 

 

 

Quote · 12 Aug 2012

We must change the SQL (include the Field "Trash"). If this containd the word "recipient" we must ignore the unread Message.

Quote · 12 Aug 2012

HERE THE COMPLETE CODE NOW WITHOUT TRASH-MESSAGES:

 

function Pfriend(){
global $site;
global $oTemplConfig;

$User = getNickName($ID);
$SQLselect = mysql_query("SELECT Profiles.ID, Profiles.NickName, sys_friend_list.Profile
FROM Profiles
INNER JOIN sys_friend_list
ON Profiles.ID = sys_friend_list.Profile
WHERE Profiles.NickName = '$User'
AND sys_friend_list.Check = '0'");


$alertText = '<span style="color:maroon;font-size:20px;text-shadow:1px 1px 3px #000;">';
$alertTextE = '</span>';

$row = mysql_num_rows($SQLselect);
if($row == 1):
echo MsgBox('<img src="templates/base/images/icons/action_broadcast.png"><a href="'.BX_DOL_URL_ROOT.'communicator.php?&communicator_mode=friends_requests"> ' . $alertText . $row . ' new Friend Request</a>' . $alertTextE);
elseif($row >= 2):
echo MsgBox('<img src="templates/base/images/icons/action_broadcast.png"><a href="'.BX_DOL_URL_ROOT.'communicator.php?&communicator_mode=friends_requests"> ' . $alertText . $row . ' new Friend Requests</a>' . $alertTextE);
else:
echo '';
endif;


$User = getNickName($ID);
$SQLselect = mysql_query("SELECT Profiles.ID, Profiles.Headline, Profiles.NickName, sys_messages.New, sys_messages.Recipient
FROM Profiles
INNER JOIN sys_messages
ON Profiles.ID = sys_messages.Recipient
WHERE Profiles.NickName = '$User'
AND sys_messages.New = '1' AND sys_messages.Trash NOT LIKE '%recipient%'
ORDER BY sys_messages.New");


$alertText = '<span style="color:maroon;font-size:20px;text-shadow:1px 1px 3px #000;">';
$alertTextE = '</span>';

$row = mysql_num_rows($SQLselect);
if($row == 1):
echo MsgBox('<img src="templates/base/images/icons/mails.png"><a href="'.BX_DOL_URL_ROOT.'mail.php?mode=inbox"> ' . $alertText . $row . ' New Message</a>' . $alertTextE);
elseif($row >= 2):
echo MsgBox('<img src="templates/base/images/icons/mails.png"><a href="'.BX_DOL_URL_ROOT.'mail.php?mode=inbox"> ' . $alertText . $row . ' New Messages</a>' . $alertTextE);
else:
echo '';
endif;

}

 

Quote · 13 Aug 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.