<?php
// $Id: pmblock.php,v 1.1 2004/07/11 10:28:09 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Half-Dead
// Author Website : http://www.e-xoops.com
// License Type   : LGPL: See /manual/LICENSES/LGPL.txt
// ------------------------------------------------------------------------- //


//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function b_pmessages_show() {
global $db, $xoopsUser;

if (!$xoopsUser) {
	return FALSE;
}

$block            = array();
$block['title']   = _PM_PRIVMSGS;
$block['content'] = "<br />";

list($total_messages) = $db->fetch_row($db->query("SELECT COUNT(*) FROM ".$db->prefix("private_msgs")." WHERE to_userid = ".$xoopsUser->getVar("uid").""));
list($new_messages)   = $db->fetch_row($db->query("SELECT COUNT(*) FROM ".$db->prefix("private_msgs")." WHERE to_userid = ".$xoopsUser->getVar("uid")." AND read_msg=0"));

if ($total_messages > 0) {
	if ($new_messages > 0) {
		$block['content'] .= $new_messages.": <a id='msgtxt' href='".XOOPS_URL."/modules/messages/' onmouseover='setBlink(0);' onmouseout='setBlink(1);'><b>"._PM_NEW."</b></a><br />";
		if ( !defined('EXOOPS_PM_INCLUDED') ) {
			$block['content'] .= "<bgsound src='".XOOPS_URL."/modules/messages/images/msg.wav' loop='false'>";
		}
		$block['content'] .= '
					<script type="text/javascript">
					<!--
					var blink    = 1;
					var blinkdom = xoopsGetElementById("msgtxt");

					function blink1() {
					blinkdom.style.visibility = "hidden";
					if (blink == 1) {
						setTimeout("blink2()", 500);
						} else {
							blinkdom.style.visibility = "visible";
						}
					}

					function blink2() {
					blinkdom.style.visibility = "visible";
					if (blink == 1) {
						setTimeout("blink1()", 1000);
					}
					}

					function setBlink(val) {
					blink = val;
					blink1();
					}

					setBlink(1);
					//-->
					</script>';

		} else {
			$block['content'] .= _PM_NONEW." <br /> ";
		}
	$block['content'] .= $total_messages.": <a href='".XOOPS_URL."/modules/messages/'>"._PM_TOT."</a>";
	} else {
		$block['content'] .= "<a href='".XOOPS_URL."/modules/messages/'>"._PM_NONEW."</a>";
	}
$block['content'] .= "<br /><br /><li><a href='".XOOPS_URL."/modules/messages/pmlite.php?send=1'>"._PM_SEND."</a></li>";

return $block;
}
?>
