Source for file function.displaygreeting.php
Documentation is available at function.displaygreeting.php
* Zikula Application Framework
* @copyright (c) 2004, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: function.displaygreeting.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_Template_Plugins
* Smarty function to display a greeting to the user with the number of private messages received.
* This function displays a welcome message: welcome and the number of private
* messages for a registered user or welcome and a signup link for an anonymous user.
* Examples (with Admin having 5 messages total, 1 unread):
* <!--[displaygreeting]--> or
* <!--[displaygreeting displayMsgs=true]-->
* Welcome [username]! You have 1 new message.
* Welcome [username]! You have no new messages.
* <!--[displaygreeting class="welcome" displayMsgs=false]-->
* styled with the class "welcome"
* <!--[displaygreeting multiline=true displayAllMsgs=true]-->
* You have 5 private messages, 1 unread.
* <!--[displaygreeting displayAllMsgs=false class="messages"]-->
* Welcome [username]! You have 1 unread message.
* Welcome [username]! You have no unread messages.
* If not logged in, returns
* Unregistered? <a href="user.php">Register for a user account</a>.
* @author Mark West, Martin Stær Andersen
* @see function.displaygreeting.php::smarty_function_displaygreeting()
* @param array $params All attributes passed to this function from the template
* @param object &$smarty Reference to the Smarty object
* @param string class CSS class for string
* @param string displayMsgs Set to false (or any value) to turn off display of Private Messages
* @param string displayAllMsgs Set to false (or any value) to only display unread Messages
* @param string multiline Set to true to show Welcome and Messages on two lines (with Break).
* @return string the welcome message
$class = ' class="'. $class. '"';
// Turn on message display if not explicitly set or set true, or Display All is set
$displayMsgs = !isset ($displayMsgs) || $displayMsgs || isset ($displayAllMsgs) ? true : false;
$displayAllMsgs = isset ($displayAllMsgs) && $displayAllMsgs ? true : false;
$multiline = isset ($multiline) && $multiline ? true : false;
$greeting = '<span'. $class. '>'. pnML('_THEME_WELCOMEUSER', array('username' => pnUserGetVar('uname')));
if (pnModAvailable('pnMessages') && ($displayMsgs || $displayAllMsgs)) {
$messages = pnModAPIFunc('pnMessages', 'user', 'getmessagecount');
if ($messages['unread'] > 0) {
$greeting .= pnML('_THEME_YOUHAVEXPRIVATEMESSAGES', array('x' => $messages['totalin'], 'u' => $messages['unread'], 'url' => $inboxurl), true);
$greeting .= pnML('_THEME_YOUHAVENOPRIVATEMESSAGES', array('url' => $inboxurl), true);
if ($messages['totalin'] > 0) {
$greeting .= pnML('_THEME_YOUHAVEXNEWPRIVATEMESSAGES', array('x' => $messages['unread'], 'url' => $inboxurl), true);
$greeting .= pnML('_THEME_YOUHAVENONEWPRIVATEMESSAGES', array('url' => $inboxurl), true);
} else { // If not logged in, show login link, ask them to register
} // end login and private messages
|