XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
function.xoInboxCount.php
Go to the documentation of this file.
1 <?php
2 
3 function smarty_function_xoInboxCount($params, &$smarty)
4 {
5  global $xoopsUser;
6 
7  if (!isset($xoopsUser) || !is_object($xoopsUser)) {
8  return;
9  }
10  $time = time();
11  if (isset($_SESSION['xoops_inbox_count']) && @$_SESSION['xoops_inbox_count_expire'] > $time) {
12  $count = intval($_SESSION['xoops_inbox_count']);
13  } else {
14  $pm_handler =& xoops_gethandler('privmessage');
15 
17  $xoopsPreload->triggerEvent('core.class.smarty.xoops_plugins.xoinboxcount', array($pm_handler));
18 
19  $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
20  $criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
21  $count = intval($pm_handler->getCount($criteria));
22  $_SESSION['xoops_inbox_count'] = $count;
23  $_SESSION['xoops_inbox_count_expire'] = $time + 60;
24  }
25  if (!@empty( $params['assign'])) {
26  $smarty->assign( $params['assign'], $count );
27  } else {
28  echo $count;
29  }
30 }
31 
32 ?>