1
Hi, I have seen threads on how to put a notification of new messages in your theme, but I am using the ipb forum module, which edits core files
Please help so I can change my site!
Here is the way it is done in the user menu, system_blocks.php (edited for the ipb module):
function b_system_user_show()
{
global $xoopsUser;
global $isbb, $xoopsDB;
if (is_object($xoopsUser)) {
$pm_handler =& xoops_gethandler('privmessage');
$block = array();
$block['lang_youraccount'] = _MB_SYSTEM_VACNT;
$block['lang_editaccount'] = _MB_SYSTEM_EACNT;
$block['lang_notifications'] = _MB_SYSTEM_NOTIF;
$block['uid'] = $xoopsUser->getVar('uid');
$block['lang_logout'] = _MB_SYSTEM_LOUT;
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
//<<<--------------------------------------------
//-+- IPB messages new -- Koudadnshi
//<<<--------------------------------------------
if ($isbb)
{
list($new_messages) = $xoopsDB->fetchRow($xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("ipb_messages")." WHERE recipient_id = '".$xoopsUser->getVar("uid")."' AND vid='in' AND read_state='0' "));
$block['new_messages'] = $new_messages;
}
else
$block['new_messages'] = $pm_handler->getCount($criteria);
//>>>--------------------------------------------
$block['lang_inbox'] = _MB_SYSTEM_INBOX;
$block['lang_adminmenu'] = _MB_SYSTEM_ADMENU;
return $block;
}
return false;
}
..........and here is the way they suggest it to be done (without the ipb module)...
Above header:
<{if $xoops_isuser}>
<{php}>
GLOBAL $xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid = $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $uid));
$msgcount = $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount', $msgcount);
<{/php}>
<{/if}>
In page:
<{if $msgcount > 0}>
<a class="highlight" href="<{$xoops_url}>/viewpmsg.php">Inbox (<span style="color:#ff0000; font-weight: bold;"><{$msgcount}>span>)a>
<{else}>
<a href="<{$xoops_url}>/viewpmsg.php">Inboxa>
<{/if}>
Can someone who knows php put this together to make a code that displays the New Message count that I can put anywhere in my theme? Im sure it would only take 10 mins or so...