<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.2 www.exoops.info 2006/03 
// $Id: userblock.php,v 1.0 2004/04/04 10:34:04 nobse Exp $					 //
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Nobse, Bama												 //
// Author Website : http://www.e-xoops.de									 //
// License Type   : GPL: See /manual/LICENSES/GPL.txt						 //	
// ------------------------------------------------------------------------- //
function ecal_userblockloc() {
global $db, $xoopsUser, $bcoosConfig ;
	$useroffset = "";
    if($xoopsUser) 
          $useroffset = $xoopsUser->getVar("timezone_offset");
    else
          $useroffset = $bcoosConfig['default_TZ'];
	$offset = $useroffset - $bcoosConfig['server_TZ'];
	$usertimevent = time() +($offset * 3600);
  
    $start = date("Y-m-j",$usertimevent);
 
	
if ($xoopsUser) {
    
	$result=$db->query("SELECT locationid, bllimit FROM ".$db->prefix("ecal_userblock")." WHERE uid=".$xoopsUser->uid()."");
	$myrow = $db->fetchArray($result);
	if ($myrow) {
	    
	
	$locationid=$myrow['locationid'];
	$bllimit=$myrow['bllimit'];
	
	$result=$db->query("SELECT location FROM ".$db->prefix("ecal_location")." WHERE lid=$locationid");
	$myrow = $db->fetchArray($result);
	$locationname=$myrow['location'];
	
	$block = array();
    $block['title'] = _MB_ECAL_USERLOC."<br>";
	$block['title'] .= $locationname;
	
	$result1=$db->query("SELECT subject,stamp,privat,username FROM ".$db->prefix("ecal")." WHERE stamp >= '$start' AND valid='yes' AND locationid=$locationid order by stamp ASC limit 0, $bllimit");
	while (list($subject, $stamp, $privat, $username) = $db->fetchRow($result1)){
		if ($xoopsUser ) {
			if ($privat == 1 and $username == $xoopsUser->uname()) {
				$tag = substr($stamp,8,2);
				$monath = substr($stamp,5,2);
				$jahr = substr($stamp,0,4);
				$block['content'] .= $tag.".".$monath." ";
				$block['content'] .= "<a href=\"".XOOPS_URL."/modules/ecal/display.php?day=$tag&month=$monath&year=$jahr\">".$subject."</a><br>";
			}
		}	
	
		if ($privat == 0) {
			$tag = substr($stamp,8,2);
			$monath = substr($stamp,5,2);
			$jahr = substr($stamp,0,4);
			$block['content'] .= $tag.".".$monath." ";
			$block['content'] .= "<a href=\"".XOOPS_URL."/modules/ecal/display.php?day=$tag&month=$monath&year=$jahr\">".$subject."</a><br>";
		}
	}
	if ($block['content'] == "") {
	    $block['content'] .= _MB_CAL_NOEVENT."<br>";
	}
	$block['content'] .= "<a href=\"".XOOPS_URL."/modules/ecal/blockconf.php?op=edit\">"._MB_ECAL_BLOCKCONFIG."</a>";
	} else {
		$block = array();
    	$block['content'] = "<a href=\"".XOOPS_URL."/modules/ecal/blockconf.php?op=edit\">"._MB_ECAL_BLOCKCONFIGERST."</a>";
		$block['title'] = _MB_ECAL_USERLOC;
	}
} else {
	$block = array();
    $block['title'] = _MB_ECAL_USERLOC."<br>";
	$block['content'] .= _MB_SYSTEM_DHAAY."<br />";
	$block['content'] .= " <a href='".XOOPS_URL."/register.php'>"._MB_SYSTEM_RNOW."</a>";
}	
	return $block;
}
//**************************************************************************
function ecal_userblockcat() {
global $db, $xoopsUser, $bcoosConfig ;
	$useroffset = "";
    if($xoopsUser) 
          $useroffset = $xoopsUser->getVar("timezone_offset");
    else
          $useroffset = $bcoosConfig['default_TZ'];
	$offset = $useroffset - $bcoosConfig['server_TZ'];
	$usertimevent = time() +($offset * 3600);
  
    $start = date("Y-m-j",$usertimevent);
 
if ($xoopsUser) {
    
	$result=$db->query("SELECT catid, bllimit FROM ".$db->prefix("ecal_userblock")." WHERE uid=".$xoopsUser->uid()."");
	$myrow = $db->fetchArray($result);
	if ($myrow) {
	    
	
	$catid=$myrow['catid'];
	$bllimit=$myrow['bllimit'];
	
	$result=$db->query("SELECT title FROM ".$db->prefix("ecal_cat")." WHERE cid=$catid");
	$myrow = $db->fetchArray($result);
	$catname=$myrow['title'];
	
	$block = array();
    $block['title'] = _MB_ECAL_USERCAT."<br>";
	$block['title'] .= $catname;
	
	$result1=$db->query("SELECT subject,stamp,privat,username FROM ".$db->prefix("ecal")." WHERE stamp >= '$start' AND valid='yes' AND cid=$catid order by stamp ASC limit 0, $bllimit");
	while (list($subject, $stamp, $privat, $username) = $db->fetchRow($result1)){
		if ($xoopsUser ) {
			if ($privat == 1 and $username == $xoopsUser->uname()) {
				$tag = substr($stamp,8,2);
				$monath = substr($stamp,5,2);
				$jahr = substr($stamp,0,4);
				$block['content'] .= $tag.".".$monath." ";
				$block['content'] .= "<a href=\"".XOOPS_URL."/modules/ecal/display.php?day=$tag&month=$monath&year=$jahr\">".$subject."</a><br>";
			}
		}	
	
		if ($privat == 0) {
			$tag = substr($stamp,8,2);
			$monath = substr($stamp,5,2);
			$jahr = substr($stamp,0,4);
			$block['content'] .= $tag.".".$monath." ";
			$block['content'] .= "<a href=\"".XOOPS_URL."/modules/ecal/display.php?day=$tag&month=$monath&year=$jahr\">".$subject."</a><br>";
		}
	}
	if ($block['content'] == "") {
	    $block['content'] .= _MB_CAL_NOEVENT."<br>";
	}
	$block['content'] .= "<a href=\"".XOOPS_URL."/modules/ecal/blockconf.php?op=edit\">"._MB_ECAL_BLOCKCONFIG."</a>";
	} else {
		$block = array();
    	$block['content'] = "<a href=\"".XOOPS_URL."/modules/ecal/blockconf.php?op=edit\">"._MB_ECAL_BLOCKCONFIGERST."</a>";
		$block['title'] = _MB_ECAL_USERLOC;
	}	
} else {
	$block = array();
    $block['title'] = _MB_ECAL_USERCAT."<br>";
	$block['content'] .= _MB_SYSTEM_DHAAY."<br />";
	$block['content'] .= " <a href='".XOOPS_URL."/register.php'>"._MB_SYSTEM_RNOW."</a>";
}
	return $block;
}
?>