Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/events/viewDay.inc.php
<?php
if(!class_exists("Date")) {
	require_once("Date.php");
}

/*
* löschen eines Events
*/
if(isset($eventAction)) {
	if($eventAction == "delete" && ereg("^([0-9]*)$", $eventID)) {
		$eventQuery = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TABLE."_events WHERE eventID = '$eventID'"));
		
		if((ADMIN & $cbPerms) || ($eventQuery[userID] == $cbUserID)) {
			mysql_query("DELETE FROM ".TABLE."_events WHERE eventID = '$eventID'");
		}
		
		$deleteEventDate = new Date($eventQuery[eventDate]);
		$eventDay   = $deleteEventDate->getDay();
		$eventMonth = $deleteEventDate->getMonth();
		$eventYear  = $deleteEventDate->getYear();
	}
}

if(!empty($eventDay) && !empty($eventMonth) && !empty($eventYear)) {
	/*
	* Führende Nullen einbauen
	*/
	if(strlen($eventDay) < 2) {
		$eventDay = "0".$eventDay;
	}
	if(strlen($eventMonth) < 2) {
		$eventMonth = "0".$eventMonth;
	}
	
	$currentDayDate = new Date($eventYear."-".$eventMonth."-".$eventDay);
	
	/*
	* wenn neuer Event hinzugefügt wurde
	*/
	if(!empty($newEventAdd)) {
		if(strlen($newEventHour) < 2) {
			$newEventHour = "0".$newEventHour;
		}
		if(strlen($newEventMinute) < 2) {
			$newEventMinute = "0".$newEventMinute;
		}
		$newEventDate = $eventYear."-".$eventMonth."-".$eventDay." ".$newEventHour.":".$newEventMinute.":00";
		$result = mysql_query("INSERT INTO ".TABLE."_events (title, description, insertDate, eventDate, userID) VALUES ('$newEventTitle', '$newEventDesc', NOW(), '$newEventDate', '$cbUserID')");
	}
	
	/*
	* oft gebrauchte globale Variablen ans Template senden
	*/
	$eventData = array();
	$eventData['current']['day']     = $currentDayDate->getDayName();
	$eventData['current']['dayNr']   = $currentDayDate->getDay();
	$eventData['current']['month']   = $currentDayDate->getMonthName();
	$eventData['current']['monthNr'] = $currentDayDate->getMonth();
	$eventData['current']['year']    = $currentDayDate->getYear();
	
	/*
	* Calculator Objekt für Wochenberechnungen ableiten
	*/
	$calculator = new Date_Calc();
	
	/*
	* Stunden durchzählen und Eventarray mit leeren Einträgen ausstatten.
	*/
	for($z = 0; $z <= 23; $z++) {
		unset($hourContent);
		
		/* 
		* 0 voran stellen, weil sonst die events vor 10 Uhr nicht 
		* gefunden werden 
		*/
		$thisHour = $z;
		if(strlen($z) < 2) {
			$thisHour = "0".$thisHour;
		}
		
		/*
		* Wenn Event Array leer ist, einen leeren Eintrag für die Stunde einfügen
		*/
		$eventArray[$thisHour]['set'] = 0;
		$dayHours[]   = $z;
	}
	
	/*
	* Events am Tag herausfinden.
	*/
	$eventQuery = mysql_query("SELECT * FROM ".TABLE."_events WHERE SUBSTRING(eventDate, 9,2) = '$eventDay' AND MONTH(eventDate) = '$eventMonth' AND YEAR(eventDate) = '$eventYear' ORDER BY eventDate ASC");
	while($eventRow = mysql_fetch_assoc($eventQuery)) {
		$eventDate = new Date($eventRow[eventDate]);
		
		$eventArray[$eventDate->getHour()]['set'] = 1;
		
		$nextID    = count($eventArray[$eventDate->getHour()]['content']) + 1;
		
		$eventArray[$eventDate->getHour()]['content'][$nextID]             = $eventRow;
		$eventArray[$eventDate->getHour()]['content'][$nextID][eventHour]  = $eventDate->getHour();
		$eventArray[$eventDate->getHour()]['content'][$nextID][eventMin]   = $eventDate->getMinute();
		$eventArray[$eventDate->getHour()]['content'][$nextID][eventSec]   = $eventDate->getSecond();
		
	}
	
	if(is_array($eventArray)) {
		ksort($eventArray);
	}
	
	
	
	/*
	* Minuten im Array sammeln, da patTemplate so was nicht kann.
	*/
	for($y = 0; $y <= 59; $y++) {
		$thisMinute = $y;
		if(strlen($y) < 2) {
			$thisMinute = "0".$thisMinute;
		}
		$minutes[]   = $thisMinute;
	}
	
	$eventData['minutes'] = $minutes;
	$eventData['hours']   = $dayHours;
	$eventData['events']  = $eventArray;
	
	$tpl->assign("eventData", $eventData);
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."dayView.template", null, "pluginEvent".$cbUserID);
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginEvent".$cbUserID);
}
?>
Return current item: Content*Builder