Seite 1 von 2

Nur bestimmte Kategorien anzeigen

Verfasst: 03.05.2003 18:55
von Chaze
Weiß jemand, wie ich bei der folgenden php-Datei (index.php mit Categories with Hierarchy Options-Mod) angeben kann, dass nur die Kategorien X,Y und Z angezeigt werden sollen?

Code: Alles auswählen

<?php
/***************************************************************************
 *                                index.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: index.php,v 1.99.2.1 2002/12/19 17:17:40 psotfx Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
//-- add v1.0.1
//
// enhance categories informations : description, last post, numbers of posts/topics, and so
function enhance_cat($cat_id)
{
//-- fix v 1.0.6
	global $HTTP_COOKIE_VARS, $category_rows, $forum_data, $is_auth_ary, $tracking_forums, $tracking_topics, $new_topic_data, $images, $lang, $board_config, $userdata, $phpEx;
//--

	if ($cat_id < 0) $cat_id=0;

	// default values
	$ind = -1;
	//-- v 1.0.5
	$categories_desc = ''; // all the sub-cat titles
	$forums_desc = ''; // all the sub-forum titles
	//--
	$cat_display = false;
	$cat_locked = true;
	$cat_unread_topics = false;
	$cat_posts = 0;
	$cat_topics = 0;
	$cat_post_time = 0;
	$cat_last_post = '';

	// look up for sub-categories
	for ($i=0; $i < count($category_rows); $i++)
	{
		// let's fix the cat_main : attached to  index : lvl 0
		if ($category_rows[$i]['cat_main']==$category_rows[$i]['cat_id']) $category_rows[$i]['cat_main'] = 0;

		// get the tab index for $cat_id
		if ( ($cat_id > 0) && ($category_rows[$i]['cat_id']==$cat_id) ) $ind = $i;

		// identify category which are daughters of the one running
		if ( $category_rows[$i]['cat_main']==$cat_id && $category_rows[$i]['cat_id']>0 )
		{
			// enhance sub-categories
			enhance_cat($category_rows[$i]['cat_id']);

			// get the result
			//-- v 1.0.5
			$categories_desc .= empty($categories_desc) ? '':', ';
			$categories_desc .= $category_rows[$i]['cat_title'];
			//--
			if ( $category_rows[$i]['cat_display'] ) $cat_display = true;
			if ( !($category_rows[$i]['cat_locked']) ) $cat_locked = false;
			if ( $category_rows[$i]['unread_topics'] ) $cat_unread_topics = true;
			$cat_posts = $cat_posts + $category_rows[$i]['posts'];
			$cat_topics = $cat_topics + $category_rows[$i]['topics'];
			if ( $cat_post_time < $category_rows[$i]['post_time'])
			{
				$cat_post_time = $category_rows[$i]['post_time'];
				$cat_last_post = $category_rows[$i]['last_post'];
			}
		} //  if ($category_rows[$i]['cat_main']==$cat_id) || ( ($cat_id==0) && ($category_rows[$i]['cat_main']==$category_rows[$i]['cat_id']) )
	} // for ($i=0; $i < count($category_rows); $i++)

	// deal with the forums of the category
	if ($ind > -1)
	{
		// Raz
		$category_rows[$ind]['cat_display'] = false;
		$category_rows[$ind]['cat_locked'] = true;
		$category_rows[$ind]['unread_topics'] = false;
		$category_rows[$ind]['posts'] = 0;
		$category_rows[$ind]['topics'] = 0;
		$category_rows[$ind]['post_time'] = 0;
		$category_rows[$ind]['last_post'] = '';

		// look up for the forums of the category
		for ($j=0;$j<count($forum_data);$j++)
		{
			if ($forum_data[$j]['cat_id'] == $cat_id)
			{
				$forum_id = $forum_data[$j]['forum_id'];
				// valeur par défaut
				$display_forum = false;
				$unread_topics = false;
				$last_post = "";

				// forum visible ?
				if ( $display_forum = $is_auth_ary[$forum_id]['auth_view'])
				{
					if ($forum_data[$j]['forum_status'] != FORUM_LOCKED)
					{
						if ( $userdata['session_logged_in'] && !empty($new_topic_data[$forum_id]) )
						{
							$forum_last_post_time = 0;
							while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
							{
								if ( empty($tracking_topics[$check_topic_id]) )
								{
									$unread_topics = true;
									$forum_last_post_time = max($check_post_time, $forum_last_post_time);
								}
								else
								{
									if ( $tracking_topics[$check_topic_id] < $check_post_time )
									{
										$unread_topics = true;
										$forum_last_post_time = max($check_post_time, $forum_last_post_time);
									}
								}
							} //  end while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
							if ( !empty($tracking_forums[$forum_id]) )
							{
								if ( $tracking_forums[$forum_id] > $forum_last_post_time )
								{
									$unread_topics = false;
								}
							}
							if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
							{
								if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
								{
									$unread_topics = false;
								}
							}
						} //  if ( $userdata['session_logged_in'] && !empty($new_topic_data[$forum_id]) )
					} //  if ($forum_data[$j]['forum_status'] != FORUM_LOCKED)

					$posts = $forum_data[$j]['forum_posts'];
					$topics = $forum_data[$j]['forum_topics'];

					$last_post = $lang['No_Posts'];
					if ( $forum_data[$j]['forum_last_post_id'] )
					{
						$last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);
						$last_post = $last_post_time . '<br />';
						$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
						$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
					}

				} //  if ($display_forums = $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view'])

				// enhanced forum row
				$forum_data[$j]['display_forum'] = $display_forum;
				$forum_data[$j]['unread_topics'] = $unread_topics;
				$forum_data[$j]['last_post'] = $last_post;

				// ok : add forum informations to the category
				if ($forum_data[$j]['display_forum'])
				{
					//-- v 1.0.5
					$forums_desc .= empty($forums_desc) ? '':', ';
					$forums_desc .= $forum_data[$j]['forum_name'];
					//--
					$category_rows[$ind]['cat_display'] = true;
					if ( $forum_data[$j]['forum_status'] != FORUM_LOCKED ) $category_rows[$ind]['cat_locked'] = false;
					if ( $forum_data[$j]['unread_topics'] ) $category_rows[$ind]['unread_topics'] = true;
					$category_rows[$ind]['posts'] = $category_rows[$ind]['posts'] + $forum_data[$j]['forum_posts'];
					$category_rows[$ind]['topics'] = $category_rows[$ind]['topics'] + $forum_data[$j]['forum_topics'];
					if ( $forum_data[$j]['post_time'] > $category_rows[$ind]['post_time'])
					{
						$category_rows[$ind]['post_time'] = $forum_data[$j]['post_time'];
						$category_rows[$ind]['last_post'] = $forum_data[$j]['last_post'];
					}
				} //  if ($display_forum)
			} // if ($forum_data['cat_id'] == $cat_id)
		} // for ($j=0;$j<count($forum_data);$j++)

		// all is done for the forums : add the sub-categories informations
		//-- v 1.0.5
		if ( empty($category_rows[$ind]['cat_desc']) )
		{
			$category_rows[$ind]['cat_desc']  = $forums_desc;
			$category_rows[$ind]['cat_desc'] .= ( empty($forums_desc) || empty($categories_desc) ) ? '': ', ';
			$category_rows[$ind]['cat_desc'] .= $categories_desc;
		}
		//--
		if ( $cat_display ) $category_rows[$ind]['cat_display'] = true;
		if ( !$cat_locked ) $category_rows[$ind]['cat_locked'] = false;
		if ( $cat_unread_topics ) $category_rows[$ind]['unread_topics'] = true;
		$category_rows[$ind]['posts'] = $category_rows[$ind]['posts'] + $cat_posts;
		$category_rows[$ind]['topics'] = $category_rows[$ind]['topics'] + $cat_topics;
		if ( $cat_post_time > $category_rows[$ind]['post_time'])
		{
			$category_rows[$ind]['post_time'] = $cat_post_time;
			$category_rows[$ind]['last_post'] = $cat_last_post;
		}
	} // if ($ind > -1)
} // function enhance_cat_forum

function display_index_cat($catrow, $sub_forum, $main, $cur_depth = 0)
{
	global $total_categories, $category_rows, $total_forums, $forum_data, $forum_moderators, $images, $lang, $template, $phpEx;
	global $max_depth;
	if ( $sub_forum ) $cur_depth = 0;

	$cat_id = $catrow['cat_id'];
	if ($catrow['cat_display'])
	{
		// display cat title
		$class_catLeft = "catLeft";
		$class_rowpic  = "rowpic";
		if (!$sub_forum && $main)
		{
			$class_catLeft = "catRupt";
			$class_rowpic  = "catRupt";
		}
		$template->assign_block_vars('catrow', array(
			'INC_SPAN'		=> $max_depth-$cur_depth + 2,
			'CLASS_CATLEFT' => $class_catLeft,
			'CLASS_ROWPIC'  => $class_rowpic,
			'CAT_ID'        => $cat_id,
			'CAT_DESC'      => $catrow['cat_title'],
			'U_VIEWCAT'     => append_sid("content.$phpEx?" . POST_CAT_URL . "=$cat_id"))
		);
		$color = true;
		$inc_row = true;
		for ($k=0; $k < $cur_depth; $k++ )
		{
			$template->assign_block_vars('catrow.inc', array('INC_ROW' => $inc_row ? "row1" : "row2" ) );
			$inc_row = !$inc_row;
		}

		// display forums
		for($j = 0; $j < $total_forums; $j++)
		{
			if ( ($forum_data[$j]['cat_id']==$cat_id) && $forum_data[$j]['display_forum'] )
			{
				$forum_id = $forum_data[$j]['forum_id'];
				$folder_image = ( $forum_data[$j]['unread_topics'] ) ? $images['forum_new'] : $images['forum'];
				$folder_alt   = ( $forum_data[$j]['unread_topics'] ) ? $lang['New_posts'] : $lang['No_new_posts'];
				if ($forum_data[$j]['forum_status'] == FORUM_LOCKED )
				{
					$folder_image = $images['forum_locked'];
					$folder_alt = $lang['Forum_locked'];
				}
				$l_moderators = '&';
				$moderator_list = '&';
				if ( count($forum_moderators[$forum_id]) > 0 )
				{
					$l_moderators = ( count($forum_moderators[$forum_id]) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
					$moderator_list = implode(', ', $forum_moderators[$forum_id]);
				}
				$row_color = ( $color ) ? $theme['td_color1'] : $theme['td_color2'];
				$row_class = ( $color ) ? $theme['td_class1'] : $theme['td_class2'];
				$color = !$color;
				$odd = ( $sub_forum || ( intval($cur_depth / 2) == ($cur_depth/2) ) );
				$template->assign_block_vars('catrow.forumrow',	array(
					'INC_SPAN'		=> $max_depth-$cur_depth+1,
					'INC_ROW'		=> ( $odd ? "row1" : "row2" ),
					'ROW_COLOR' => '#' . $row_color,
					'ROW_CLASS' => $row_class,
					'FORUM_FOLDER_IMG' => $folder_image,
					'FORUM_NAME' => $forum_data[$j]['forum_name'],
					'FORUM_DESC' => $forum_data[$j]['forum_desc'],
					'POSTS' => $forum_data[$j]['forum_posts'],
					'TOPICS' => $forum_data[$j]['forum_topics'],
					'LAST_POST' => $forum_data[$j]['last_post'],
					'MODERATORS' => $moderator_list,
					'L_MODERATOR' => $l_moderators,
					'L_FORUM_FOLDER_ALT' => $folder_alt,
					'U_VIEWFORUM' => append_sid("contentforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
				);
				$inc_row = true;
				for ($k=0; $k < $cur_depth; $k++ )
				{
					$template->assign_block_vars('catrow.forumrow.inc', array('INC_ROW' => $inc_row ? "row1" : "row2" ) );
					$inc_row = !$inc_row;
				}
			} //  if ( ($forum_data[$j]['cat_id']==$cat_id) && $forum_data[$j]['display_forum'] )
		} //  for($j = 0; $j < $total_forums; $j++)

		// display sub-cat title
		for ($j=0; $j < $total_categories; $j++)
		{
			if (($category_rows[$j]['cat_main']==$cat_id) && ($category_rows[$j]['cat_display']))
			{
				if (!$sub_forum)
				{
					display_index_cat($category_rows[$j], $sub_forum, false, $cur_depth+1);
				}
				if ($sub_forum)
				{
					$subcat_id = $category_rows[$j]['cat_id'];
					$folder_image = ( $category_rows[$j]['unread_topics'] ) ? $images['category_new'] : $images['category'];
					$folder_alt   = ( $category_rows[$j]['unread_topics'] ) ? $lang['New_posts'] : $lang['No_new_posts'];
					if ($category_rows[$j]['cat_locked'] )
					{
						$folder_image = $images['category_locked'];
						$folder_alt = $lang['Forum_locked'];
					}
					$row_color = ( $color ) ? $theme['td_color1'] : $theme['td_color2'];
					$row_class = ( $color ) ? $theme['td_class1'] : $theme['td_class2'];
					$color = !$color;
					$template->assign_block_vars('catrow.forumrow',	array(
						'INC_ROW'   => "row1",
						'ROW_COLOR' => '#' . $row_color,
						'ROW_CLASS' => $row_class,
						'FORUM_FOLDER_IMG' => $folder_image,
						'FORUM_NAME' => $category_rows[$j]['cat_title'],
						'FORUM_DESC' => $category_rows[$j]['cat_desc'],
						'POSTS' => $category_rows[$j]['posts'],
						'TOPICS' => $category_rows[$j]['topics'],
						'LAST_POST' => $category_rows[$j]['last_post'],
						'MODERATORS' => "",
						'L_MODERATOR' => "",
						'L_FORUM_FOLDER_ALT' => $folder_alt,
						'U_VIEWFORUM' => append_sid("content.$phpEx?" . POST_CAT_URL . "=$subcat_id"))
					);
				} //  if ($sub_forum)
			} //  if ($category_rows[$j]['cat_main']==$cat_id)
		} // for ($j=0; $j < $total_categories; $j++)
	} //  if ($catrow['cat_display'])
} // end function display_index_cat($catrow, $sub_forum, $main)
//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

$viewcat = ( !empty($HTTP_GET_VARS[POST_CAT_URL]) ) ? $HTTP_GET_VARS[POST_CAT_URL] : -1;

if( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
{
	$mark_read = ( isset($HTTP_POST_VARS['mark']) ) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
}
else
{
	$mark_read = '';
}

//
// Handle marking posts
//
if( $mark_read == 'forums' )
{

//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
	if ( $viewcat < 0 )
	{
//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------

	if( $userdata['session_logged_in'] )
	{
		setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
	}

	$template->assign_vars(array(
		"META" => '<meta http-equiv="refresh" content="3;url='  .append_sid("content.$phpEx") . '">')
	);

//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
//-- add v 1.0.9
	}
	else
	{
		if( $userdata['session_logged_in'] )
		{
			// get the list of the involved cats
			$catrows = array();
			$catrows = get_cat($viewcat);

			// build the string list
			$catids = array();
			for ( $i=0; $i < count($catrows); $i++) $catids[] = $catrows[$i]['cat_id'];
			$s_cat = implode(', ', $catids);

			// get the list of the involved forums
			$forumids = array();
			$sql = "select * from " . FORUMS_TABLE . " where cat_id in ($s_cat)";
			if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query new forums information', '', __LINE__, __FILE__, $sql);
			while ( $row = $db->sql_fetchrow($result) ) $forumids[] = $row;

			// mark each forums
			for ( $i=0; $i < count($forumids); $i++ )
			{
				$forum_id = $forumids[$i]['forum_id'];
				$sql = "SELECT MAX(post_time) AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id";
				if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
				if ( $row = $db->sql_fetchrow($result) )
				{
					$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
					$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();

					if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
					{
						asort($tracking_forums);
						unset($tracking_forums[key($tracking_forums)]);
					}

					if ( $row['last_post'] > $userdata['user_lastvisit'] )
					{
						$tracking_forums[$forum_id] = time();
						setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
					}
				}
			}
		}

		$template->assign_vars(array(
			"META" => '<meta http-equiv="refresh" content="3;url='  .append_sid("content.$phpEx?" . POST_CAT_URL . "=$viewcat") . '">')
		);
	}
//-- fin mod : hiérarchie des rubriques -----------------------------------------------------------

	$message = $lang['Forums_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("content.$phpEx") . '">', '</a> ');

	message_die(GENERAL_MESSAGE, $message);
}
//
// End handle marking posts
//

$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();

//
// If you don't use these stats on your index you may want to consider
// removing them
//
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];

if( $total_posts == 0 )
{
	$l_total_post_s = $lang['Posted_articles_zero_total'];
}
else if( $total_posts == 1 )
{
	$l_total_post_s = $lang['Posted_article_total'];
}
else
{
	$l_total_post_s = $lang['Posted_articles_total'];
}

if( $total_users == 0 )
{
	$l_total_user_s = $lang['Registered_users_zero_total'];
}
else if( $total_users == 1 )
{
	$l_total_user_s = $lang['Registered_user_total'];
}
else
{
	$l_total_user_s = $lang['Registered_users_total'];
}


//
// Start page proper
//
//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
//-- delete
// $sql = "SELECT c.cat_id, c.cat_title, c.cat_order
// 	FROM " . CATEGORIES_TABLE . " c
// 	ORDER BY c.cat_order";
// if( !($result = $db->sql_query($sql)) )
// {
// 	message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
// }
//
// while( $category_rows[] = $db->sql_fetchrow($result) );
//-- add
//
// get the nav sentence
$nav_cat_desc = make_cat_nav_tree($viewcat, false);
//
// categories array
$category_rows = get_cat($viewcat);
//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------

if( ( $total_categories = count($category_rows) ) )
{
	//
	// Define appropriate SQL
	//
	switch(SQL_LAYER)
	{
		case 'postgresql':
			$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
				FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
				WHERE p.post_id = f.forum_last_post_id
					AND u.user_id = p.poster_id
					UNION (
						SELECT f.*, NULL, NULL, NULL, NULL
						FROM " . FORUMS_TABLE . " f
						WHERE NOT EXISTS (
							SELECT p.post_time
							FROM " . POSTS_TABLE . " p
							WHERE p.post_id = f.forum_last_post_id
						)
					)
					ORDER BY cat_id, forum_order";
			break;

		case 'oracle':
			$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
				FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
				WHERE p.post_id = f.forum_last_post_id(+)
					AND u.user_id = p.poster_id(+)
				ORDER BY f.cat_id, f.forum_order";
			break;

		default:
			$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
				FROM (( " . FORUMS_TABLE . " f
				LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
				LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
				ORDER BY f.cat_id, f.forum_order";
			break;
	}
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
	}

	$forum_data = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_data[] = $row;
	}

	if ( !($total_forums = count($forum_data)) )
	{
		message_die(GENERAL_MESSAGE, $lang['No_forums']);
	}

	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
	if ( $userdata['session_logged_in'] )
	{
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time
			FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
			WHERE p.post_id = t.topic_last_post_id
				AND p.post_time > " . $userdata['user_lastvisit'] . "
				AND t.topic_moved_id = 0";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
		}

		$new_topic_data = array();
		while( $topic_data = $db->sql_fetchrow($result) )
		{
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
		}
	}

	//
	// Obtain list of moderators of each forum
	// First users, then groups ... broken into two queries
	//
	$sql = "SELECT aa.forum_id, u.user_id, u.username
		FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
		WHERE aa.auth_mod = " . TRUE . "
			AND g.group_single_user = 1
			AND ug.group_id = aa.group_id
			AND g.group_id = aa.group_id
			AND u.user_id = ug.user_id
		GROUP BY u.user_id, u.username, aa.forum_id
		ORDER BY aa.forum_id, u.user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}

	$forum_moderators = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
	}

	$sql = "SELECT aa.forum_id, g.group_id, g.group_name
		FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
		WHERE aa.auth_mod = " . TRUE . "
			AND g.group_single_user = 0
			AND g.group_type <> " . GROUP_HIDDEN . "
			AND ug.group_id = aa.group_id
			AND g.group_id = aa.group_id
		GROUP BY g.group_id, g.group_name, aa.forum_id
		ORDER BY aa.forum_id, g.group_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}

	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
	}

	//
	// Find which forums are visible for this user
	//
	$is_auth_ary = array();
	$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);

	//
	// Start output of page
	//
	define('SHOW_ONLINE', true);
	$page_title = $lang['Index'];
	include($phpbb_root_path . 'includes/page_header.'.$phpEx);

	$template->set_filenames(array(
		'body' => 'content_body.tpl')
	);

//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
//-- add
	if ($nav_cat_desc != "") $nav_cat_desc = $nav_separator . $nav_cat_desc;
	$mark = ($viewcat == -1 ) ? '' : '&' . POST_CAT_URL . '=' . $viewcat;
//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------

	$template->assign_vars(array(
		'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
		'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
		'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),

		'FORUM_IMG' => $images['forum'],
		'FORUM_NEW_IMG' => $images['forum_new'],
		'FORUM_LOCKED_IMG' => $images['forum_locked'],

		'L_FORUM' => $lang['Forum'],
		'L_TOPICS' => $lang['Topics'],
		'L_REPLIES' => $lang['Replies'],
		'L_VIEWS' => $lang['Views'],
		'L_POSTS' => $lang['Posts'],
		'L_LASTPOST' => $lang['Last_Post'],
		'L_NO_NEW_POSTS' => $lang['No_new_posts'],
		'L_NEW_POSTS' => $lang['New_posts'],
		'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
		'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
		'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
		'L_NAVIGATION' => $lang['Navigation'],
		'L_MODERATOR' => $lang['Moderators'],
		'L_FORUM_LOCKED' => $lang['Forum_is_locked'],
		'L_MARK_FORUMS_READ' => $lang['Mark_all_forums'],
		'L_OVERVIEW' => $lang['Overview'],

		'U_CONTENT' => append_sid("content.$phpEx"),

		//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
		//-- delete
		//		'U_MARK_READ' => append_sid("content.$phpEx?mark=forums"))
		//-- add v 1.0.9
				'U_MARK_READ' => append_sid("content.$phpEx?mark=forums$mark"))
		//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------
	);

		//-- mod : hiérarchie des rubriques ----------------------------------------------------------------
		//-- add
			$template->assign_vars(array(
				'NAV_CAT_DESC' => $nav_cat_desc)
			);
		//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------

	//
	// Okay, let's build the index
	//
	//-- mod : hiérarchie des rubriques ----------------------------------------------------------------

	//-- add v 1.0.9
		// récupérer la profondeur max
		$max_depth = ( !$sub_forum ) ? get_max_depth($viewcat) : 0;
		$template->assign_vars(array(
			'INC_SPAN' => $max_depth + 2)
		);
	//-- add v1.0.1
		//
		// enhance cat & forum informations
		enhance_cat($viewcat);

		// display the index
		$found=false;
		for ($i=0; ($i < $total_categories) && !$found; $i++)
		{
			if ( ($viewcat==-1 && $category_rows[$i]['cat_main']==0) || ($viewcat > 0 && $category_rows[$i]['cat_id']==$viewcat) )
			{
				display_index_cat($category_rows[$i], $sub_forum, true);
				$found = ($viewcat > 0);
			}
		} //  end for ($i=0; ($i < $total_categories) && !$found; $i++)
	//-- fin mod : hiérarchie des rubriques ------------------------------------------------------------


}// if ... total_categories
else
{
	message_die(GENERAL_MESSAGE, $lang['No_forums']);
}

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>

Verfasst: 04.05.2003 11:15
von Chaze
Hab mir schon ´nen Wolf probiert :-(

Mit einer entsprechenden Bedingung in den SQL-Anweisungen gehts nicht.

Verfasst: 04.05.2003 11:42
von Acid
Ich würde eher auf die functions.php tippen..

Verfasst: 04.05.2003 12:29
von Murphy
wenn ich das richtig verstanden habe, sollen bestimmte foren (teile)
nicht jedem sichtbar sein, oder?

sollte es so sein, dann richte doch eine gruppe mit "versteckt" ein.
stelle dann deine foren auf ansicht -> "privat" (die, die unsichtbar bleiben sollen)
der gruppe kannst du leute hinzufügen, oder nicht.

das klappt auch in hirarchies - foren.

der vorteil wäre ja dann auch, dass du die index.php nicht jedesmal ändern müsstest.
würde ja dann alles über's acp gehen.

Verfasst: 04.05.2003 16:24
von Chaze
@Acid: Auf die functions.php bin ich auch schon gekommen. Aber auch hier reichen meine äußerst bescheidenen PHP Kenntnisse nicht aus.

@Murphy: Das Problem ist, daß die Kategorien für jeden sichtbar sein sollen. In der einen Ansicht soll alles sichtbar bleiben (standart index.php) in der anderen Ansicht (siehe die gepostete Datei. Soll ´ne Art CMS werden) sollen bloß die Foren X,Y und Z zu sehen sein.

Hier sind mal die betreffenden Stellen aus der functions.php

Code: Alles auswählen

$nav_separator = "&nbsp;->&nbsp;";
$nav_link_active = true;

// get the depth level
function get_max_depth($cat_id)
{
	global $db;
	if ($cat_id < 0) $cat_id = 0;
	$local_depth = 0;
	$sql = "select * from " . CATEGORIES_TABLE . " where cat_main = $cat_id";
	if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categorie parm', '', __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) )
	{
		$branch_depth = get_max_depth( $row['cat_id'] );
		if ( $cat_id > 0 ) $branch_depth++;
		if ( $branch_depth > $local_depth ) $local_depth = $branch_depth;
	}
	return $local_depth;
}

// build the cat list sorted
function get_auth_cat_order(&$cat_row, &$cat_list, $cat_main=0, $level=0)
{
	global $db;

	// read daughter cats
	$sql = "select * from " . CATEGORIES_TABLE . " where cat_main = $cat_main order by cat_order, cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) ) $rowlevel[] = $row;
	// push and get the sub- daughter cat
	for ($i = 0; $i < count($rowlevel); $i++ )
	{
		if ( in_array( $rowlevel[$i]['cat_id'], $cat_list ) )
		{
			$rowlevel[$i]['level'] = $level;
			$cat_row[] = $rowlevel[$i];
			get_auth_cat_order( $cat_row, $cat_list, $rowlevel[$i]['cat_id'], ($level+1) );
		}
	}
}

// build the auth cat list
function get_auth_cat()
{
	global $db, $userdata;

	// get the cat id of all auth forums
	$catlist = array();
	$sql = "select * from " . FORUMS_TABLE;
	if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Couldn't obtain forum list.", "", __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) )
	{
		$is_auth = array();
		$is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
		if ( $is_auth['auth_view'] ) $catlist[] = $row['cat_id'];
	}

	// get the mother cat
	$t_cat = $catlist;
	while ( count($t_cat) > 0 )
	{
		$s_cat = implode( ', ', $t_cat );
		$t_cat = array();
		$sql = "select * from " . CATEGORIES_TABLE . " where cat_id in ($s_cat)";
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
		while ( $row = $db->sql_fetchrow($result) )
		{
			if ( !in_array($row['cat_main'], $catlist) )
			{
				$catlist[] = $row['cat_main'];
				$t_cat[] =  $row['cat_main'];
			}
		}
	}

	// read cat sorted
	$catrows = array();
	get_auth_cat_order( $catrows, $catlist );

	return $catrows;
}
//-- add
// build the nav sentence
function make_cat_nav_tree($cat_id, $with_link)
{
	global $db,$phpEx;
	global $nav_separator, $nav_link_active;

	if ($nav_link_active) $with_link = true;

	$this_cat = "";
	if ($cat_id > 0)
	{
		$sql = "SELECT * FROM ".CATEGORIES_TABLE." WHERE cat_id=$cat_id";
		if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categorie parm '.$sql, '', __LINE__, __FILE__, $sql);
		if ( $catw = $db->sql_fetchrow($result) )
		{
			$cat_main  = $catw['cat_main'];
			$cat_title = $catw['cat_title'];
			$this_cat = ($with_link) ? '<a href="'.append_sid("index.$phpEx?c=$cat_id").'" class="nav">'.$cat_title.'</a>' : $cat_title;
			// vérifier si un parent
			if ($cat_main != $cat_id && $cat_main > 0)
			{
				$this_cat = make_cat_nav_tree($cat_main, true) . $nav_separator . $this_cat;
			}
		}
	}
	return $this_cat;
}

//
// build sub categories list
function get_sub_cat($cat_main, $catrow )
{
	global $db;

	if ($cat_main > 0)
	{
		// lire les rubriques dépendantes
		$sql= "SELECT * FROM ".CATEGORIES_TABLE." WHERE cat_id <> $cat_main AND cat_main=$cat_main";
		if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categorie sons '.$sql, '', __LINE__, __FILE__, $sql);
		while ( $catw = $db->sql_fetchrow($result) )
		{
			// ajouter la catégorie
			$i = count($catrow);
			$catrow[$i] = $catw;
			// aller chercher les sous-catégories
			if ($catw['cat_id'] > 0) $catrow = get_sub_cat($catw['cat_id'],$catrow);
		}
	}
	return $catrow;
}

// build sorted cats array
function get_cat($cat_id)
{
	global $db;

	// vérifier la catégorie
	if ($cat_id <= 0) $cat_id = -1;
	if ($cat_id > 0)
	{
		$sql = "SELECT * FROM " . CATEGORIES_TABLE . " WHERE cat_id=$cat_id";
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query this categories', '', __LINE__, __FILE__, $sql);
		if ( !($row = $db->sql_fetchrow($result)) ) $cat_id = -1;
	}
	//
	// no cat selected : get all
	if ($cat_id <= 0)
	{
		//-- v 1.0.5
		$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
		//--
		if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
		while ( $row = $db->sql_fetchrow($result) ) $category_rows[] = $row;
	}
	//
	// a cat selected : get it and its sub-cats
	if ($cat_id > 0)
	{
		// add the current one
		$catrow[] = $row;
		// get sub-cats
		$catrow = get_sub_cat($cat_id,$catrow);
		// get cats
		//-- v 1.0.5
		$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
		//--
		if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
		while ($row = $db->sql_fetchrow($result) )
		{
			$found = false;
			for ($i=0;( $i<count($catrow) && (!$found) );$i++) $found = ($row['cat_id'] == $catrow[$i]['cat_id']);
			if ($found) $category_rows[] = $row;
		}
	}
	return $category_rows;
}

Verfasst: 04.05.2003 18:57
von Acid
..da gibt´s ja mehrere SELECT Abfragen zu den Kategorien (verschiedene Funktionen)... theoretisch müsste (als Beispiel) cat_id = 1 bei jeder WHERE Klausel eingefügt werden (da ´s ja verschiedene Funktionen betrifft).. einfach ma testen.

Verfasst: 04.05.2003 20:20
von Chaze
Der Tip hat mich schon mal einen Schritt weiter gebracht. Leider funktioniert das nur mit cat_id = 1. Bei cat_id = 2 oder cat_id = 3 wird nichts angezeigt.

[EDIT]Es werden lediglich keine Unterkategorien aus dem Mod angezeigt. Mal schauen, ob ich das mit einem Array hinkriege :roll: [/EDIT]

Verfasst: 06.05.2003 14:19
von Chaze
Ich kriegs nicht hin. Ich kann nur eine einzige Kategorie gezielt anzeigen lassen. Vielleicht noch ´ne Idee oder einen Denkansatz?

Verfasst: 06.05.2003 14:28
von Acid
Wie hast es denn nun probiert ?

Verfasst: 06.05.2003 14:36
von Chaze
Also die derzeitige Situation (nur eine Kategorie kann selektiert werden) habe ich hinbekommen, indem ich in jede Funktion ein cat_id=1 eingesetzt habe.

Die erfolglosen Versuche habe ich z.B. mit
$cat_id[] = 1;
$cat_id[] = 5;
in der index.php (bei mir --> content.php). Und in den Funktionen z.B. mit ...WHERE cat_id in ($cat_id). (<-- Arrays sind noch immer nicht meine Stärke... :-( )