Location: PHPKode > projects > Content*Builder > modules/forum/showThreads.inc.php
<?php

/**
 * Übersicht über alle Threads
 *
 * @version $Id: showThreads.inc.php,v 1.3 2004/09/29 17:27:45 cb_fog Exp $
 * @copyright 2003 C*B Development Team
**/

/*
* Thread PageSplit Option
*/
// Offset überprüfen und auf DefaultWert setzen
if(!preg_match("/^([0-9]*)$/", $threadOffset) || $threadOffset == "") {
	$threadOffset = 0;
}

// Limit abrufen, überprüfen und auf DefaultWert setzen
$threadLimit = $forum_option->getSingleOption("threads_per_page");
if(!preg_match("/^([0-9]*)$/", $threadLimit) || $threadLimit == 0) {
	$threadLimit = 3;
}

// Gesamte Anzahl an Threads im Forum herausfinden
$threadAmountQuery = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS counter FROM ".TABLE."_forum_message AS message, ".TABLE."_forum_thread AS thread WHERE message.messageID = thread.rootID AND thread.categoryID = '".$_REQUEST[forumID]."'"));
$threadAmount = $threadAmountQuery[counter];

// Page Split Objekt anlegen
$threadPageSplitObj = & new CB_pageSplit($threadLimit, $threadOffset, $threadAmount);
 
/*
* Threads abfragen
* Alle Rootnodes auslesen, limiert auf 20.
*/
$additionalSQL = array (
	"field"   => ", user.fullname AS userName, luser.fullname AS lastUserName, thread.lastModified, thread.lastModifiedBy",
	"join"    => ", ".TABLE."_forum_thread AS thread".
				 " LEFT JOIN ".TABLE."_community_user AS user ON n.userID = user.userID".
				 " LEFT JOIN ".TABLE."_community_user AS luser ON thread.lastModifiedBy = luser.userID",
	"where"   => "AND n.messageID = thread.rootID AND thread.categoryID = '".$_REQUEST[forumID]."'",
	"orderby" => "ORDER BY thread.lastModified DESC",
	"append"  => "LIMIT $threadOffset,$threadLimit"
);

// nur wenn User eingeloggt ist, Datums Objekt erzeugen
if($forum_logged_in == 1) {
	$userLastLogin = $_SESSION[community_data]->lastLogin;
	$_uYear   = substr($userLastLogin,0,4);
	$_uMonth  = substr($userLastLogin,5,2);
	$_uDay    = substr($userLastLogin,8,2);
	$_uHour   = substr($userLastLogin,11,2);
	$_uMinute = substr($userLastLogin,14,2);
	$_uSecond = substr($userLastLogin,17,2);
	$userLastVisit = mktime($_uHour, $_uMinute, $_uSecond, $_uMonth, $_uDay, $_uYear);
}

$threadQuery = $nestedSet_message->getRootNodes(true, $additionalSQL);
$threadSet = 0;
if($threadQuery != false) {
	foreach($threadQuery as $threadRow) {
		$threadSet = 1;
		
		/*
		* Code zum Markieren der Threads seit dem letzten Login
		*/
		$_threadNew = 0;
		// nur wenn User eingeloggt ist, Berechnungen durchführen
		if($forum_logged_in == 1) {
			$_threadLM = $threadRow[lastModified];
			$_tYear   = substr($_threadLM,0,4);
			$_tMonth  = substr($_threadLM,5,2);
			$_tDay    = substr($_threadLM,8,2);
			$_tHour   = substr($_threadLM,11,2);
			$_tMinute = substr($_threadLM,14,2);
			$_tSecond = substr($_threadLM,17,2);
			$_threadLMTimestamp = mktime($_tHour, $_tMinute, $_tSecond, $_tMonth, $_tDay, $_tYear);
			if($_threadLMTimestamp > $userLastVisit) {
				$_threadNew = 1;
			}
		}
		
		$threadNew[]          = $_threadNew;
		$threadAnswers[]      = ($threadRow[r] - $threadRow[l] - 1) / 2;
		$threadMessageID[]    = $threadRow[id];
		$threadUserID[]       = $threadRow[userID];
		$threadUserName[]     = $threadRow[userName];
		$threadLastUserName[] = $threadRow[lastUserName];
		$threadTitle[]        = $threadRow[title];
		$threadLastModified[] = $threadRow[lastModified];
		$threadInsertDate[]   = $threadRow[insertDate];
	}
}

/*
* Ans Template senden
*/
$tpl->assign(
	array ( "thread_set"          => $threadSet,
			"thread_new"          => $threadNew,
			"thread_answers"      => $threadAnswers,
			"thread_messageID"    => $threadMessageID,
			"thread_userID"       => $threadUserID,
			"thread_userName"     => $threadUserName,
			"thread_lastUserName" => $threadLastUserName,
			"thread_title"        => $threadTitle,
			"thread_lastModified" => $threadLastModified,
			"thread_insertDate"   => $threadInsertDate
	)
);

$tpl->assign("thread_pageNav",
	array ( "split_status" => $threadPageSplitObj->isSplitInPages(),
			"next_set"     => $threadPageSplitObj->nextPageExists(),
			"last_set"     => $threadPageSplitObj->lastPageExists(),
			"next_offset"  => $threadPageSplitObj->getNextOffset(),
			"last_offset"  => $threadPageSplitObj->getLastOffset(),
			"pages"        => $threadPageSplitObj->getPages(),
			"actual_page"  => $threadPageSplitObj->getActualPage()
	)
);

$tpl->assign("thread_options", 
	array ( "allow_top_level_posting" => $forum_option->getSingleOption("allow_top_level_posting"))
);
/*
* Template ausgeben
*/
$forum_content[] = $tpl->fetch("threadOverview.template");
?>
Return current item: Content*Builder