<?php
// $Id: userblock.php,v 1.1 2004/07/11 10:27:52 Farsus 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, $xoopsConfig ;


	$useroffset = "";
    if($xoopsUser) 
          $useroffset = $xoopsUser->getVar("timezone_offset");
    else
          $useroffset = $xoopsConfig['default_TZ'];
	$offset = $useroffset - $xoopsConfig['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->fetch_array($result);
	if ($myrow) {
	    
	
	$locationid=$myrow['locationid'];
	$bllimit=$myrow['bllimit'];
	
	$result=$db->query("SELECT location FROM ".$db->prefix("ecal_location")." WHERE lid=$locationid");
	$myrow = $db->fetch_array($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->fetch_row($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, $xoopsConfig ;


	$useroffset = "";
    if($xoopsUser) 
          $useroffset = $xoopsUser->getVar("timezone_offset");
    else
          $useroffset = $xoopsConfig['default_TZ'];
	$offset = $useroffset - $xoopsConfig['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->fetch_array($result);
	if ($myrow) {
	    
	
	$catid=$myrow['catid'];
	$bllimit=$myrow['bllimit'];
	
	$result=$db->query("SELECT title FROM ".$db->prefix("ecal_cat")." WHERE cid=$catid");
	$myrow = $db->fetch_array($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->fetch_row($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;
}
?>