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
Here's what it's like being logged in as Demo user
Be a dolphin, be creative in you own way and you will attract a audience |
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:
|
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?
|
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 |
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! |
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,,,
|
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! |
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.
|
RonBo01searching 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! |
I see, I got the impression Wolf2217 wrote the code not found it.
Still haven't heard from anyone re: a fix though.
|
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
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 |
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.
|
wolf2217s post fixes this problem with unread messages
|
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 |
It looks like wolf2217's fix for deleted messages doesn't work with 7.07. Anyone else noticing this? |
Is it possible to add this at the header rather than in a block? |
Is it possible to add this at the header rather than in a block?
very good idea I think.....
|
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 |