home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / class / smarty / xoops_plugins / function.xoInboxCount.php < prev    next >
Encoding:
PHP Script  |  2006-09-04  |  843 b   |  29 lines

  1. <?php
  2.  
  3.  
  4.  
  5. function smarty_function_xoInboxCount( $params, &$smarty ) {
  6.     global $xoopsUser;
  7.     
  8.     if ( !isset($xoopsUser) || !is_object($xoopsUser) ) {
  9.         return;
  10.     }
  11.     $time = time();
  12.     if ( isset( $_SESSION['xoops_inbox_count'] ) && @$_SESSION['xoops_inbox_count_expire'] > $time ) {
  13.         $count = intval( $_SESSION['xoops_inbox_count'] );
  14.     } else {
  15.         $pm_handler =& xoops_gethandler( 'privmessage' );
  16.         $criteria = new CriteriaCompo( new Criteria('read_msg', 0) );
  17.         $criteria->add( new Criteria( 'to_userid', $xoopsUser->getVar('uid') ) );
  18.         $count = intval( $pm_handler->getCount($criteria) );
  19.         $_SESSION['xoops_inbox_count'] = $count;
  20.         $_SESSION['xoops_inbox_count_expire'] = $time + 60;
  21.     }
  22.     if ( !@empty( $params['assign'] ) ) {
  23.         $smarty->assign( $params['assign'], $count );
  24.     } else {
  25.         echo $count;
  26.     }
  27. }
  28.  
  29. ?>