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

Source for file function.displaygreeting.php

Documentation is available at function.displaygreeting.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.displaygreeting.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 display a greeting to the user with the number of private messages received.
  15.  *
  16.  * This function displays a welcome message: welcome and the number of private
  17.  * messages for a registered user or welcome and a signup link for an anonymous user.
  18.  *
  19.  * Examples (with Admin having 5 messages total, 1 unread):
  20.  * <!--[displaygreeting]-->  or
  21.  * <!--[displaygreeting displayMsgs=true]-->
  22.  * Returns
  23.  * Welcome [username]! You have 1 new message.
  24.  * or
  25.  * Welcome [username]! You have no new messages.
  26.  *
  27.  * <!--[displaygreeting class="welcome" displayMsgs=false]-->
  28.  * Returns
  29.  * Welcome [username]!
  30.  * styled with the class "welcome"
  31.  *
  32.  * <!--[displaygreeting multiline=true displayAllMsgs=true]-->
  33.  * Returns
  34.  * Welcome [username]!
  35.  * You have 5 private messages, 1 unread.
  36.  *
  37.  * <!--[displaygreeting displayAllMsgs=false class="messages"]-->
  38.  * Returns
  39.  * Welcome [username]! You have 1 unread message.
  40.  * or
  41.  * Welcome [username]! You have no unread messages.
  42.  *
  43.  * If not logged in, returns
  44.  * Unregistered? <a href="user.php">Register for a user account</a>.
  45.  *
  46.  * @author       Mark West, Martin Stær Andersen
  47.  * @since        19/10/2003
  48.  * @see          function.displaygreeting.php::smarty_function_displaygreeting()
  49.  * @param        array       $params         All attributes passed to this function from the template
  50.  * @param        object      &$smarty        Reference to the Smarty object
  51.  * @param        string      class           CSS class for string
  52.  * @param        string      displayMsgs     Set to false (or any value) to turn off display of Private Messages
  53.  * @param        string      displayAllMsgs  Set to false (or any value) to only display unread Messages
  54.  * @param        string      multiline       Set to true to show Welcome and Messages on two lines (with Break).
  55.  * @return       string      the welcome message
  56.  */
  57. function smarty_function_displaygreeting($params&$smarty)
  58. {
  59.     extract($params);
  60.     unset($params);
  61.  
  62.     // set some defaults
  63.     if (isset($class)) {
  64.         $class ' class="'.$class.'"';
  65.     else {
  66.         $class '';
  67.     }
  68.  
  69.     // Turn on message display if not explicitly set or set true, or Display All is set
  70.     $displayMsgs !isset($displayMsgs|| $displayMsgs || isset($displayAllMsgstrue false;
  71.     $displayAllMsgs = isset($displayAllMsgs&& $displayAllMsgs true false;
  72.     $multiline = isset($multiline&& $multiline true false;
  73.  
  74.     if (pnUserLoggedIn()) {
  75.         $greeting '<span'.$class.'>'.pnML('_THEME_WELCOMEUSER'array('username' => pnUserGetVar('uname')));
  76.         if (pnModAvailable('pnMessages'&& ($displayMsgs || $displayAllMsgs)) {
  77.             $messages pnModAPIFunc('pnMessages''user''getmessagecount');
  78.             $inboxurl DataUtil::formatForDisplay(pnModURL('pnMessages''user''inbox'));
  79.             if ($multiline{
  80.                 $greeting .= "<br />\n";
  81.             else {
  82.                 $greeting .= '&nbsp;';
  83.             }
  84.             if ($displayAllMsgs{
  85.                 if ($messages['unread'0{
  86.                     $greeting .= pnML('_THEME_YOUHAVEXPRIVATEMESSAGES'array('x' => $messages['totalin']'u' => $messages['unread']'url' => $inboxurl)true);
  87.                 else {
  88.                     $greeting .= pnML('_THEME_YOUHAVENOPRIVATEMESSAGES'array('url' => $inboxurl)true);
  89.                 }
  90.             else {
  91.                 if ($messages['totalin'0{
  92.                     $greeting .= pnML('_THEME_YOUHAVEXNEWPRIVATEMESSAGES'array('x' => $messages['unread']'url' => $inboxurl)true);
  93.                 else {
  94.                     $greeting .= pnML('_THEME_YOUHAVENONEWPRIVATEMESSAGES'array('url' => $inboxurl)true);
  95.                 }
  96.             }
  97.         }
  98.         $greeting .="</span>\n";
  99.     else {  // If not logged in, show login link, ask them to register
  100.         $greeting '<span'.$class.'>'._CREATEACCOUNT."</span>\n";
  101.     // end login and private messages
  102.  
  103.     return $greeting;
  104. }

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