Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file function.pncountnewmessages.php

Documentation is available at function.pncountnewmessages.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.pncountnewmessages.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Functions
  11.  */
  12.  
  13. /**
  14.  * Smarty function to get the number of new messages for the user currently logged in
  15.  *
  16.  *
  17.  * Available parameters:
  18.  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
  19.  *
  20.  * Example
  21.  *   <!--[pncountnewmessages assign=newmessages]-->!
  22.  *
  23.  *
  24.  * @author       Frank Schummertz
  25.  * @since        03/19/2004
  26.  * @param        array       $params      All attributes passed to this function from the template
  27.  * @param        object      &$smarty     Reference to the Smarty object
  28.  */
  29. function smarty_function_pncountnewmessages ($params&$smarty)
  30. {
  31.     extract($params);
  32.     unset($params);
  33.  
  34.     $newmessages 0;
  35.     if (pnUserLoggedIn()) {
  36.         if (pnModAvailable('Messages'))    {
  37.             $dbconn pnDBGetConn(true);
  38.             $pntable pnDBGetTables();
  39.             $column &$pntable['priv_msgs_column'];
  40.             // get unread messages
  41.             $result $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[to_userid]='DataUtil::formatForStore(pnUserGetVar('uid')) "' AND $column[read_msg]='0'");
  42.             list($newmessages$result->fields;  // new messages
  43.             $result->Close();
  44.         }
  45.     }
  46.  
  47.     if (isset($assign)) {
  48.         $smarty->assign($assign$newmessages);
  49.     else {
  50.         return $newmessages;
  51.     }
  52. }

Documentation generated on Fri, 18 Jul 2008 21:45:38 +0200 by phpDocumentor 1.4.1