New Mail Anywhere

This is nothing special but i thought i would share it anyways.
What this code share will do is it will display the number of unread messages your users have.
If there's no unread messages the block wont be displayed.
For this share i am using Deanos Tools, if you don't have it i suggest you download it and install it.

Inside your inc/design.inc.php file, paste this function anywhere, aslong as it's not inside another function.

function Pmessages(){

$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"> ' . $alertText . $row . ' New Message' . $alertTextE);


elseif($row >= 2):

echo MsgBox('<img src="templates/base/images/icons/mails.png"> ' . $alertText . $row . ' New Messages' . $alertTextE);

else:

echo '';

endif;

}
//Ends uread messages

Go to your admin panel --> Modules --> Deanos Tools and click on Insert PHP Block

Choose what page you want the block to appear on, set your language key and give it a name

Inside the php code text field insert the function

Pmessages();

Click the Insert Button

Go to your Builders --> Pages Blocks and choose the page you created the block on

In the Inactive Blocks section should be your new block, drag it to where you want the block to appear.

I created mine on the Mail Page, here's what it looks like being logged in as the Administrator

New Mail

Here's what it's like being logged in as Demo user

New Mail

Be a dolphin, be creative in you own way and you will attract a audience
Quote · 23 Jul 2010

Loved the idea and works great, one thing I discovered though is with one minor addition

you can link the message notification to the Inbox.

Really makes the site a bit easier to navigate.

The two additions is all.

if($row == 1):

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


elseif($row >= 2):

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

else:

Quote · 12 Nov 2010

Just came across a problem with this. Using 7.0.4

I deleted 3 "unread" messages from my inbox, and then deleted them from the trash, still unread.

Now the block showing new messages on the profile is still showing 3 new messages.

I've also tried sending a new message to the account, block showed 4 new messages,

deleted that message and am back to 3 new messages.

Any way to correct this?

Quote · 19 Dec 2010

 

Just came across a problem with this. Using 7.0.4

I deleted 3 "unread" messages from my inbox, and then deleted them from the trash, still unread.

Now the block showing new messages on the profile is still showing 3 new messages.

I've also tried sending a new message to the account, block showed 4 new messages,

deleted that message and am back to 3 new messages.

Any way to correct this?

Strange, the code above should work, hemmm   :thinking:

=> http://friends.smansakra.sch.id => friends community based dolphin 7
Quote · 20 Dec 2010

Nice mod. I love it... however, my message says I have 2 messages at all times. Ive deleted everything from the mail boxes and even cleared Cache. Anyone else have this problem or know why?

My signature can beat up your signature!
Quote · 7 Jan 2011

Same problem, worked fine until I deleted 3 unread messages.

Since then I have 3 new messages when inbox is empty, 4 when there's 1 new, so on.

Haven't had much time to work on it but so far no help in the forums.

Tis the season, everyone's busy,,,

Quote · 7 Jan 2011

wolf2217 ...

May I ask where you found the code for this "mod"? Do you know if it is listed in the Market anywhere? I have found no results on it.

Although I find this "mod" to be very useful, I have decided to take it off of my site until the problem can be corrected.

My signature can beat up your signature!
Quote · 7 Jan 2011

Strangest thing, now I'm showing 1 new message when inbox is empty instead of 3.

Gotta figure this out, it's a handy "mod",

BTW Sn@tfu, run a search for New Mail Anywhere in Code Sharing, you'll find it.

Quote · 8 Jan 2011

searching for New Mail Anywhere brings me to this post. I tried that already. Im wondering where he found this code though.

My signature can beat up your signature!
Quote · 8 Jan 2011

I see, I got the impression  Wolf2217 wrote the code not found it.

Still haven't heard from anyone re: a fix though.

Quote · 8 Jan 2011

Sorry guys for such a late reply and yes i just looked in to the issue you guys reported and i have a quick fix for it.

In the function Pmessages look for the Query.

Add this 1 column to the query:

sys_messages.Trash,

In the WHERE clause we need to add that table with a null value (Add this after AND sys_messages.New = '1')

AND sys_messages.Trash = ' '

Now if you have 3 messages and you send 1 or all 3 to the trash can you wont be notified of a new message, new message notification should only be visible if you haven't read them or deleted them.

Yes, even if you don't read them, it still works Cool

And no, i didn't pick up this code from some other place.

I hope this fixes the issue, i'm currently running the latest beta 7.0.5

To make sure you guys got it, this is what the query should look like

 

$SQLselect = mysql_query("SELECT Profiles.ID, Profiles.Headline, Profiles.NickName, sys_messages.New, sys_messages.Trash, 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 = '' ORDER BY sys_messages.New");

Be a dolphin, be creative in you own way and you will attract a audience
Quote · 27 Jan 2011

I just tested this out on 7.0.4, seems to work perfectly.

Deleted a message without reading it, simply deleted it.

New message box had cleared instantly.

Thanks much Wolf.

Quote · 28 Jan 2011

Quote · 2 Feb 2011

Hi wolf 2217,

 

thanks for your share. I've done some code cleaning and inserted variables for translation functions and .. voilá!

Followed the Padding I've changed the # to color name like "black" or "green" and it just works fine for me!

 

@RonBon01 , just clean cache files incl. the users ones and counter restarts.

 

Regards.

Sleepless
Quote · 1 Mar 2011

It looks like wolf2217's fix for deleted messages doesn't work with 7.07. Anyone else noticing this?

Quote · 7 Sep 2011

Is it possible to add this at the header rather than in a block?

Quote · 21 Oct 2011

 

Is it possible to add this at the header rather than in a block?

 very good idea I think.....

Quote · 21 Oct 2011

If member1 writes a new message to member2 and then deletes the message before member2 opened it. There will be no display of "1 New Message" for member2, even the inbox contains this new one. I suggest another code change to fix this.

instead of

AND sys_messages.Trash = ''

use

AND (sys_messages.Trash = '' OR sys_messages.Trash = 'sender')

Check my GeoDistance, Watermark, TorBlock and Android Push Notifications mods | http://goo.gl/H3Vp81
Quote · 13 Apr 2013
 
 
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.