Location: PHPKode > projects > Content*Builder > modules/forum/plugins/views/threaded/showThread.inc.php
<?php

/**
 * Threaded Ausgabe eines Threads
 *
 * @version $Id: showThread.inc.php,v 1.2 2004/05/26 20:30:42 cb_fog Exp $
 * @copyright 2003 C*B Development Team
**/

/*
* check, ob messageID eine Zahl ist (flüchtiger Check)
*/
if(preg_match("/^([0-9]*)$/", $_REQUEST[messageID]) && $_REQUEST[messageID] != "") {
	$error = 0;
	
	/*
	* Zusätzliches SQL, um bei NestedSet Message Abfrage auch gleich die 
	* Autoren zu bekommen
	*/
	$additionalSQL = array (
		"field" => ", user.fullname",
		"join"  => "LEFT JOIN ".TABLE."_community_user AS user ON user.userID = n.userID"
	);
	
	/*
	* Abruf der aktuell ausgewählten Message
	* Check, ob Message überhaupt existiert (echter check)
	*/
	$actualMessageQuery = $nestedSet_message->getNode($_REQUEST[messageID], true, $additionalSQL);
	if($actualMessageQuery == false) {
		$forum_error['wrongMessageID'] = 1;
		$error = 1;
	}
	
	
	if(!$error) {
		/* Ermittlung der Wurzel des gesamten Threads */
		$threadRootID = $actualMessageQuery[root];
		
		/*
		* Abruf der Wurzel Message
		*/
		$rootMessage = $nestedSet_message->getNode($threadRootID, true);
		
		/* 
		* Abruf der Thread Daten des Root Nodes ... Thread Daten sind in eigener Tabelle 
		*/
		$threadRootQuery = mysql_query("SELECT * FROM ".TABLE."_forum_thread WHERE rootID = '$threadRootID'");
		if(mysql_num_rows($threadRootQuery) > 0) {
			$threadRootRow = mysql_fetch_assoc($threadRootQuery);
			
			/* Forum ID ermitteln */
			$tpl->assign("forumID", $threadRootRow[categoryID]);
			
			/* 
			* Pfad Menu aufbauen
			*/
			$categoryPathQuery = $nestedSet_category->getPath($threadRootRow[categoryID], true);
			$categoryPathName[] = "Top Level";
			$categoryPathID[]   = "noID";
			if($categoryPathQuery != false) {
				foreach($categoryPathQuery as $v) {
					$categoryPathName[] = $v[name];
					$categoryPathID[]   = $v[id];
				}
			}
		}
		
		/*
		* Alle Kind Messages des Root Nodes für den Thread View unter der 
		* aktuellen Message
		*/
		$messagesQuery = $nestedSet_message->getBranch($actualMessageQuery[root], true, $additionalSQL);
		if($messagesQuery != false) {
			foreach($messagesQuery as $v) {
				$messagesMessageID[]    = $v[id];
				$messagesUserID[]       = $v[userID];
				$messagesUserName[]     = $v[fullname];
				$messagesTitle[]        = stripslashes($v[title]);
				$messagesLastModified[] = $v[editDate];
				$messagesInsertDate[]   = $v[insertDate];
				$messagesLevel[]        = $v[level];
			}
		}
		
		/*
		* Post nur editierbar wenn es der selbe User ist
		*/
		$_editablePost = 0;
		if($actualMessageQuery[userID] == $_SESSION[community_uid]) {
			$_editablePost = 1;
		}
		
		/*
		* Anzeige ob Message editiert worden ist
		*/
		$_modifiedPost = 0;
		if($actualMessageQuery[insertDate] != $actualMessageQuery[editDate]) {
			$_modifiedPost = 1;
		}
		
		$actualMessageQuery[message]  = stripslashes($actualMessageQuery[message]);
		$actualMessageQuery[editable] = $_editablePost;
		$actualMessageQuery[modified] = $_modifiedPost;
	}
} else {
	$forum_error['wrongMessageID'] = 1;
}

if(!is_array($forum_error)) {
	/*
	* Ans Template senden
	*/
	$tpl->assign(
		array ( "message_messageID"    => $messagesMessageID,
				"message_userID"       => $messagesUserID,
				"message_userName"     => $messagesUserName,
				"message_title"        => $messagesTitle,
				"message_lastModified" => $messagesLastModified,
				"message_insertDate"   => $messagesInsertDate,
				"message_rootID"       => $threadRootID,
				"message_level"        => $messagesLevel
		)
	);
	
	$tpl->assign("root_thread", $rootMessage);
	
	$tpl->assign( "categoryPath",
		array ( "categoryID"    => $categoryPathID,
				"categoryName"  => $categoryPathName
		)
	);
	
	$tpl->assign("actualMessage", $actualMessageQuery);
	
	$forum_content[] = $tpl->fetch("plugins/views/".$forum_display_method."/showThread.template");
}
?>
Return current item: Content*Builder