Subforums handling part 2, it almost works. Also added: the "Explain" link at the bottom page, can be removed easily before official release if necessary.

git-svn-id: file:///svn/phpbb/trunk@2913 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Ludovic Arnaud 2002-10-03 02:43:41 +00:00
parent 1666e7d3e7
commit 268d936f46
12 changed files with 367 additions and 250 deletions

View file

@ -231,7 +231,7 @@ switch ($mode)
'prune_enable' => (!empty($_POST['prune_enable'])) ? 1 : 0,
'prune_days' => intval($_POST['prune_days']),
'prune_freq' => intval($_POST['prune_freq']),
'display_on_index' => (!empty($_POST['display_on_index'])) ? 0 : 1,
'display_on_index' => (!isset($_POST['display_on_index']) || !empty($_POST['display_on_index'])) ? 1 : 0,
'post_count_inc' => (!empty($_POST['disable_post_count'])) ? 0 : 1
);
@ -477,13 +477,22 @@ switch ($mode)
<td class="row2">
<input type="checkbox" name="disable_post_count" <?php echo ((!empty($post_count_inc)) ? '' : 'checked="checked" ') ?>/><?php echo $lang['Disable_post_count'] ?>
<?php
if ($mode == 'edit')
if ($mode == 'edit' && $parent_id > 0)
{
//
// if this forum is a subforum put the "display on index" checkbox
//
if ($parent_info = get_forum_info($parent_id))
{
if ($parent_info['parent_id'] > 0 || $parent_info['forum_status'] != ITEM_CATEGORY)
{
?>
<br />
<input type="checkbox" name="display_on_index" <?php echo ((!empty($display_on_index)) ? '' : 'checked="checked" ') ?>/><?php echo $lang['Display_on_index'] ?>
<?php
}
}
}
?>
</td></tr>
<?php

View file

@ -30,6 +30,8 @@ class sql_db
var $query_result;
var $return_on_error = false;
var $transaction = false;
var $sql_report = '';
var $sql_time = 0;
//
// Constructor
@ -63,14 +65,14 @@ class sql_db
//
function sql_close()
{
if ( !$this->db_connect_id )
if (!$this->db_connect_id)
{
return false;
}
if ( count($this->open_queries) )
if (count($this->open_queries))
{
foreach($this->open_queries as $query_id)
foreach ($this->open_queries as $query_id)
{
@mysql_free_result($query_id);
}
@ -117,15 +119,60 @@ class sql_db
//
function sql_query($query = '', $transaction = false)
{
if ( $query != '' )
if ($query != '')
{
$this->query_result = false;
$this->num_queries++;
if ( !($this->query_result = @mysql_query($query, $this->db_connect_id)) )
if (!empty($_REQUEST['explain']))
{
global $starttime;
$curtime = explode(' ', microtime());
$curtime = $curtime[0] + $curtime[1] - $starttime;
}
if (!$this->query_result = @mysql_query($query, $this->db_connect_id))
{
$this->sql_error($query);
}
if (!empty($_REQUEST['explain']))
{
$endtime = explode(' ', microtime());
$endtime = $endtime[0] + $endtime[1] - $starttime;
$this->sql_report .= "<pre>Query:\t" . preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n\t", $query) . "\n\n";
if ($this->query_result)
{
$this->sql_report .= "Time before: $curtime\nTime after: $endtime\nElapsed time: <b>" . ($endtime - $curtime) . "</b>\n</pre>";
}
else
{
$error = $this->sql_error();
$this->sql_report .= '<b>FAILED</b> - MySQL Error ' . $error['code'] . ': ' . $error['message'] . '<br><br><pre>';
}
$this->sql_time += $endtime - $curtime;
if (preg_match('/^SELECT/', $query))
{
$html_table = FALSE;
if ($result = mysql_query("EXPLAIN $query", $this->db_connect_id))
{
while ($row = mysql_fetch_assoc($result))
{
if (!$html_table && count($row))
{
$html_table = TRUE;
$this->sql_report .= "<table width=100% border=1 cellpadding=2 cellspacing=1>\n";
$this->sql_report .= "<tr>\n<td><b>" . implode("</b></td>\n<td><b>", array_keys($row)) . "</b></td>\n</tr>\n";
}
$this->sql_report .= "<tr>\n<td>" . implode("&nbsp;</td>\n<td>", array_values($row)) . "&nbsp;</td>\n</tr>\n";
}
}
if ($html_table)
{
$this->sql_report .= '</table><br>';
}
}
$this->sql_report .= "<hr>\n";
}
$this->open_queries[] = $this->query_result;
}

View file

@ -583,6 +583,29 @@ function on_page($num_items, $per_page, $start)
return sprintf($lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) );
}
function format_subforums_list($subforums)
{
if (empty($subforums))
{
return '';
}
global $phpEx, $SID;
foreach ($subforums as $row)
{
$alist[$row['forum_id']] = $row['forum_name'];
}
asort($alist);
$links = array();
foreach ($alist as $forum_id => $forum_name)
{
$links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">' . htmlspecialchars($forum_name) . '</a>';
}
return implode(', ', $links);
}
//
// Obtain list of naughty words and build preg style replacement arrays for use by the
// calling script, note that the vars are passed as references this just makes it easier

View file

@ -1,6 +1,6 @@
<?php
/***************************************************************************
* functions_post.php
* functions_posting.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
@ -19,11 +19,6 @@
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die('Hacking attempt');
}
$html_entities_match = array('#&#', '#<#', '#>#');
$html_entities_replace = array('&amp;', '&lt;', '&gt;');

View file

@ -19,21 +19,28 @@
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die('Hacking attempt');
}
//
// Close our DB connection.
//
$db->sql_close();
//
// Output page creation time
//
if ( defined('DEBUG') )
if (defined('DEBUG'))
{
$mtime = microtime();
$mtime = explode(' ', $mtime);
$totaltime = ( $mtime[1] + $mtime[0] ) - $starttime;
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' ]', $totaltime);
if (!empty($_REQUEST['explain']))
{
echo $db->sql_report;
echo "<pre><b>Page generated in $totaltime seconds with " . $db->num_queries . " queries,\nspending " . $db->sql_time . ' doing MySQL queries and ' . ($totaltime - $db->sql_time) . ' doing PHP things.</b></pre>';
exit;
}
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' | <a href="' . $_SERVER['REQUEST_URI'] . '&explain=1">Explain</a> ]', $totaltime);
}
$template->assign_vars(array(
@ -44,11 +51,5 @@ $template->assign_vars(array(
$template->display('body');
//
// Close our DB connection.
//
$db->sql_close();
exit;
?>

View file

@ -171,9 +171,15 @@ class Template {
*/
function display($handle)
{
if (!empty($_REQUEST['explain']))
{
global $db;
echo $this->sql_report();
return TRUE;
}
$_str = '';
if ( !($this->compile_load($_str, $handle, true)) )
if (!$this->compile_load($_str, $handle, true))
{
if ( !$this->loadfile($handle) )
{

View file

@ -24,12 +24,9 @@ $phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$viewcat = (!empty($HTTP_GET_VARS['c'])) ? intval($HTTP_GET_VARS['c']) : -1;
$forum_id = (!empty($HTTP_GET_VARS['f'])) ? intval($HTTP_GET_VARS['f']) : 0;
if (isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']))
if (isset($_GET['mark']) || isset($_POST['mark']))
{
$mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
$mark_read = (isset($_POST['mark'])) ? $_POST['mark'] : $_GET['mark'];
}
else
{
@ -77,7 +74,6 @@ $mark_forums = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'])) ?
//
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
//
$total_posts = 0;
$total_users = $board_config['num_users'];
$newest_user = $board_config['newest_username'];
$newest_uid = $board_config['newest_user_id'];
@ -98,182 +94,116 @@ else
$forum_moderators = array();
get_moderators($forum_moderators);
$branch_root_id = 0;
$cat_id = (!empty($_GET['c'])) ? intval($_GET['c']) : 0;
$root_id = $branch_root_id = $cat_id;
$forum_rows = $subforums = array();
$result = $db->sql_query('SELECT * FROM ' . FORUMS_TABLE . ' ORDER BY left_id');
if ($cat_id == 0)
{
$total_posts = 0;
switch (SQL_LAYER)
{
case 'oracle':
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u
WHERE f.forum_last_poster_id = u.user_id(+)
ORDER BY f.left_id';
break;
default:
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id
ORDER BY f.left_id';
}
}
else
{
if (!$acl->get_acl($cat_id, 'forum', 'list'))
{
//
// TODO: Deal with hidden categories
//
message_die(ERROR, $lang['Category_not_exist']);
}
$sql = 'SELECT SUM(forum_posts) AS total
FROM ' . FORUMS_TABLE . '
WHERE post_count_inc = 1
AND forum_status <> ' . ITEM_CATEGORY;
$result = $db->sql_query($sql);
$total_posts = $db->sql_fetchfield('total', 0, $result);
//
// TODO: change this to get both parents and children
//
$result = $db->sql_query('SELECT left_id, right_id, parent_id FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $cat_id);
$catrow = $db->sql_fetchrow($result);
switch (SQL_LAYER)
{
case 'oracle':
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . 'u
WHERE (f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . '
AND f.forum_last_poster_id = u.user_id(+)
ORDER BY left_id';
break;
default:
$sql = 'SELECT f.*, u.username
FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id
WHERE f.left_id BETWEEN ' . $catrow['left_id'] . ' AND ' . $catrow['right_id'] . '
ORDER BY f.left_id';
}
}
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if ($row['parent_id'] == 0)
if (!$cat_id && $row['post_count_inc'])
{
$total_posts += $row['forum_posts'];
}
if ($row['forum_id'] == $cat_id)
{
$forum_rows[] = $row;
}
elseif ($row['parent_id'] == $cat_id)
{
//
// Root-level forum
//
$forum_rows[] = $row;
$parent_id = $row['forum_id'];
if ($row['forum_status'] == ITEM_CATEGORY)
if (!$cat_id && $row['forum_status'] == ITEM_CATEGORY)
{
$branch_root_id = $row['forum_id'];
}
else
{
$branch_root_id = 0;
}
}
elseif ($row['parent_id'] == $branch_root_id)
{
//
// Forum directly under a category
//
$forum_rows[] = $row;
$forum_root_id = $row['forum_id'];
$parent_id = $row['forum_id'];
}
elseif ($row['display_on_index'] && $row['forum_status'] != ITEM_CATEGORY)
{
if ($acl->get_acl($row['forum_id'], 'forum', 'list'))
{
$subforums[$forum_root_id][] = $row;
$subforums[$parent_id][] = $row;
}
}
}
function format_subforums_list($subforums)
{
if (empty($subforums))
{
return '';
}
global $phpEx, $SID;
foreach ($subforums as $row)
{
$alist[$row['forum_id']] = $row['forum_name'];
}
asort($alist);
$links = array();
foreach ($alist as $forum_id => $forum_name)
{
$links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">' . htmlspecialchars($forum_name) . '</a>';
}
return implode(', ', $links);
}
foreach ($forum_rows as $row)
{
extract($row);
if ($parent_id == 0)
{
if ($forum_status == ITEM_CATEGORY)
{
$branch_root_id = $forum_id;
$stored_cat = $row;
continue;
}
else
{
$branch_root_id = 0;
unset($stored_cat);
}
}
elseif (!empty($stored_cat))
{
$template->assign_block_vars('forumrow', array(
'S_IS_CAT' => TRUE,
'CAT_ID' => $stored_cat['forum_id'],
'CAT_NAME' => $stored_cat['forum_name'],
'U_VIEWCAT' => 'index.' . $phpEx . $SID . '&amp;c=' . $stored_cat['forum_id']
));
unset($stored_cat);
}
if ($acl->get_acl($forum_id, 'forum', 'list'))
{
if ($forum_status == ITEM_LOCKED)
{
$folder_image = $theme['forum_locked'];
$folder_alt = $lang['Forum_locked'];
}
else
{
$unread_topics = false;
if ($userdata['user_id'] && $forum_last_post_time > $userdata['user_lastvisit'])
{
$unread_topics = true;
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 (isset($mark_topics[$forum_id]) || isset($mark_forums[$forum_id]))
{
if ($mark_forums[$forum_id] > $userdata['user_lastvisit'] || !max($mark_topics[$forum_id]))
{
$unread_topics = false;
}
}
}
$folder_image = ($unread_topics) ? $theme['forum_new'] : $theme['forum'];
$folder_alt = ($unread_topics) ? $lang['New_posts'] : $lang['No_new_posts'];
}
if ($forum_last_post_id)
{
$last_post = create_date($board_config['default_dateformat'], $forum_last_post_time, $board_config['board_timezone']) . '<br />';
$last_post .= ($user_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $user_id . '">' . $username . '</a> ';
$last_post .= '<a href="viewtopic.' . $phpEx . '$SID&amp;f=' . $forum_id . '&amp;p=' . $forum_last_post_id . '#' . $forum_last_post_id . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';
}
else
{
$last_post = $lang['No_Posts'];
}
if (!empty($forum_moderators[$forum_id]))
{
$l_moderators = (count($forum_moderators[$forum_id]) == 1) ? $lang['Moderator'] . ':' : $lang['Moderators'] . ':' ;
$moderator_list = implode(', ', $forum_moderators[$forum_id]);
}
else
{
$l_moderators = '&nbsp;';
$moderator_list = '&nbsp;';
}
if (isset($subforums[$forum_id]))
{
$subforums_list = format_subforums_list($subforums[$forum_id]);
$l_subforums = '<br />' . (count($subforums[$forum_id]) == 1) ? $lang['Subforum'] : $lang['Subforums'];
}
else
{
$subforums_list = '';
$l_subforums = '';
}
$template->assign_block_vars('forumrow', array(
'S_IS_ROOTFORUM' => TRUE,
'FORUM_FOLDER_IMG' => create_img($folder_image, $folder_alt),
'FORUM_NAME' => $forum_name,
'FORUM_DESC' => $forum_desc,
'POSTS' => $forum_posts,
'TOPICS' => $forum_topics,
'LAST_POST' => $last_post,
'MODERATORS' => $moderator_list,
'SUBFORUMS' => $subforums_list,
'FORUM_IMG' => $forum_image,
'L_SUBFORUM' => $l_subforums,
'L_MODERATOR' => $l_moderators,
'L_FORUM_FOLDER_ALT' => $folder_alt,
'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id
));
}
}
$root_id = ($cat_id) ? $catrow['parent_id'] : 0;
include($phpbb_root_path . 'includes/forums_display.' . $phpEx);
if ($total_posts == 0)
{
@ -303,6 +233,7 @@ $template->assign_vars(array(
'L_VIEWS' => $lang['Views'],
'L_POSTS' => $lang['Posts'],
'L_LASTPOST' => $lang['Last_Post'],
'L_MODERATORS' => $lang['Moderators'],
'L_NO_NEW_POSTS' => $lang['No_new_posts'],
'L_NEW_POSTS' => $lang['New_posts'],
'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],

View file

@ -85,7 +85,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '2.1.0 [20020817]');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '2.1.0 [20021003]');
# -- auth options

View file

@ -37,8 +37,8 @@ $lang['DATE_FORMAT'] = 'd M Y'; // This should be changed to the default date f
// Common, these terms are used extensively on several pages
//
$lang['Forum'] = 'Forum';
$lang['Subforum'] = 'Subforum: ';
$lang['Subforums'] = 'Subforums: ';
$lang['Subforum'] = 'Subforum';
$lang['Subforums'] = 'Subforums';
$lang['Category'] = 'Category';
$lang['Topic'] = 'Topic';
$lang['Topics'] = 'Topics';
@ -47,6 +47,7 @@ $lang['Views'] = 'Views';
$lang['Post'] = 'Post';
$lang['Posts'] = 'Posts';
$lang['Posted'] = 'Posted';
$lang['Rating'] = 'Rating';
$lang['Username'] = 'Username';
$lang['Password'] = 'Password';
$lang['Email'] = 'Email';
@ -221,6 +222,7 @@ $lang['Error_login'] = 'You have specified an incorrect or inactive username or
$lang['Index'] = 'Index';
$lang['No_Posts'] = 'No Posts';
$lang['No_forums'] = 'This board has no forums';
$lang['Category_not_exist'] = 'The category you selected does not exist';
$lang['Private_Message'] = 'Private Message';
$lang['Private_Messages'] = 'Private Messages';

View file

@ -4,7 +4,11 @@
<tr>
<td width="100%" align="left" valign="bottom"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left" valign="bottom"><p><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span></p><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
<td align="left" valign="bottom"><p><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span></p><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a>
<!-- BEGIN navlinks -->
-> <a class="nav" href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a>
<!-- END navlinks -->
</span></td>
<td align="right" class="gensmall" valign="bottom"><!-- IF S_USER_LOGGED_IN --><a href="{U_SEARCH_NEW}" class="gensmall">{L_SEARCH_NEW}</a><br /><a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a><br /><!-- ENDIF --><a href="{U_SEARCH_UNANSWERED}" class="gensmall">{L_SEARCH_UNANSWERED}</a><br /><br /><!-- IF S_USER_LOGGED_IN -->{LAST_VISIT_DATE}<br /><!-- ENDIF -->{CURRENT_TIME}</td>
</tr>
</table></td>
@ -13,37 +17,63 @@
<table class="forumline" width="100%" cellspacing="1" cellpadding="2" border="0">
<tr>
<th class="thCornerL" colspan="2" height="25" nowrap="nowrap">&nbsp;{L_FORUM}&nbsp;</th>
<th class="thCornerL" colspan="3" height="25" nowrap="nowrap">&nbsp;{L_FORUM}&nbsp;</th>
<th class="thTop" width="50" nowrap="nowrap">&nbsp;{L_TOPICS}&nbsp;</th>
<th class="thTop" width="50" nowrap="nowrap">&nbsp;{L_POSTS}&nbsp;</th>
<th class="thCornerR" nowrap="nowrap">&nbsp;{L_LASTPOST}&nbsp;</th>
<th class="thTop" nowrap="nowrap">&nbsp;{L_LASTPOST}&nbsp;</th>
<th class="thCornerR">&nbsp;{L_MODERATORS}&nbsp;</th>
</tr>
<!-- BEGIN forumrow -->
<!-- IF forumrow.S_IS_CAT -->
<tr>
<td class="catLeft" colspan="2" height="28"><span class="cattitle"><a href="{forumrow.U_VIEWCAT}" class="cattitle">{forumrow.CAT_NAME}</a></span></td>
<td class="rowpic" colspan="3" align="right">&nbsp;</td>
<td class="catLeft" colspan="3" height="28"><span class="cattitle"><a href="{forumrow.U_VIEWCAT}" class="cattitle">{forumrow.CAT_NAME}</a></span></td>
<td class="rowpic" colspan="4" align="right">&nbsp;</td>
</tr>
<!-- ENDIF -->
<!-- IF forumrow.S_IS_ROOTFORUM -->
<tr>
<td class="row1" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td>
<td class="row1" width="100%" height="50"><span class="forumlink"><a href="{forumrow.U_VIEWFORUM}" class="forumlink">{forumrow.FORUM_NAME}</a><br /></span> <span class="genmed">{forumrow.FORUM_DESC}<br /></span>
<!-- IF forumrow.MODERATORS -->
<span class="gensmall">{forumrow.L_MODERATOR} {forumrow.MODERATORS}</span><br />
<!-- ENDIF -->
<td class="row1" colspan="2" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td>
<td class="row1" width="100%" height="50"><span class="forumlink"><a href="{forumrow.U_VIEWFORUM}" class="forumlink">{forumrow.FORUM_NAME}</a><br /></span> <span class="genmed">{forumrow.FORUM_DESC}</span><br />
<!-- IF forumrow.SUBFORUMS -->
<span class="gensmall">{forumrow.L_SUBFORUM} {forumrow.SUBFORUMS}</span>
<span class="gensmall"><b>{forumrow.L_SUBFORUM}</b> {forumrow.SUBFORUMS}</span>
<!-- ENDIF -->
</td>
&nbsp;</td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.TOPICS}</span></td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.POSTS}</span></td>
<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{forumrow.LAST_POST}</span></td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.MODERATORS}</span></td>
</tr>
<!-- ENDIF -->
<!-- IF forumrow.S_IS_FORUM -->
<tr>
<td class="spaceRow" width="8"></td>
<td class="row1" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td>
<td class="row1" width="100%" height="50"><span class="forumlink"><a href="{forumrow.U_VIEWFORUM}" class="forumlink">{forumrow.FORUM_NAME}</a><br /></span> <span class="genmed">{forumrow.FORUM_DESC}</span><br />
<!-- IF forumrow.SUBFORUMS -->
<span class="gensmall"><b>{forumrow.L_SUBFORUM}</b> {forumrow.SUBFORUMS}</span>
<!-- ENDIF -->
&nbsp;</td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.TOPICS}</span></td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.POSTS}</span></td>
<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{forumrow.LAST_POST}</span></td>
<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{forumrow.MODERATORS}</span></td>
</tr>
<!-- ENDIF -->
<!-- IF forumrow.S_IS_SUBCAT -->
<tr>
<td class="spaceRow" width="8"></td>
<td class="row1" width="50" height="50" align="center" valign="middle">{forumrow.FORUM_FOLDER_IMG}</td>
<td class="row1" width="100%" height="50"><span class="forumlink"><a href="{forumrow.U_VIEWFORUM}" class="forumlink">{forumrow.FORUM_NAME}</a><br /></span> <span class="genmed">{forumrow.FORUM_DESC}</span><br />
<!-- IF forumrow.SUBFORUMS -->
<span class="gensmall"><b>{forumrow.L_SUBFORUM}</b> {forumrow.SUBFORUMS}</span>
<!-- ENDIF -->
&nbsp;</td>
<td class="row2" colspan="4">&nbsp;</td>
</tr>
<!-- ENDIF -->
<!-- BEGINELSE -->
<tr>
<td class="row1" colspan="5" height="28" align="center"><span class="gen">{L_NO_FORUMS}</span></td>
<td class="row1" colspan="7" height="28" align="center"><span class="gen">{L_NO_FORUMS}</span></td>
</tr>
<!-- END forumrow -->
</table>

View file

@ -11,7 +11,11 @@
</tr>
<tr>
<td width="50" align="left" valign="middle"><a href="{U_POST_NEW_TOPIC}"><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a></a></td>
<td class="nav" width="100%" align="left" valign="middle"><span class="nav">&nbsp; &nbsp;<a href="{U_INDEX}" class="nav">{L_INDEX}</a> -> <a class="nav" href="{U_VIEW_FORUM}">{FORUM_NAME}</a></span></td>
<td class="nav" width="100%" align="left" valign="middle"><span class="nav">&nbsp; &nbsp;<a href="{U_INDEX}" class="nav">{L_INDEX}</a>
<!-- BEGIN navlinks -->
-> <a class="nav" href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a>
<!-- END navlinks -->
</span></td>
<td class="nav" align="right" valign="bottom" nowrap="nowrap"><span class="gensmall"><a href="{U_MARK_READ}">{L_MARK_TOPICS_READ}</a></span></td>
</tr>
</table>
@ -21,9 +25,9 @@
<th class="thCornerL" colspan="3" height="25" align="center" nowrap="nowrap">&nbsp;{L_TOPICS}&nbsp;</th>
<th class="thTop" width="100" align="center" nowrap="nowrap">&nbsp;{L_AUTHOR}&nbsp;</th>
<th class="thTop" width="50" align="center" nowrap="nowrap">&nbsp;{L_REPLIES}&nbsp;</th>
<th width="50" align="center" nowrap="nowrap">&nbsp;{L_VIEWS}&nbsp;</th>
<th class="thTop" width="50" align="center" nowrap="nowrap">&nbsp;{L_VIEWS}&nbsp;</th>
<th class="thTop" align="center" nowrap="nowrap">&nbsp;{L_LASTPOST}&nbsp;</th>
<th class="thCornerR">Rating</th>
<th class="thCornerR" align="center" nowrap="nowrap">&nbsp;{L_RATING}&nbsp;</th>
</tr>
<!-- BEGIN topicrow -->
<tr>
@ -49,7 +53,11 @@
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" width="50" valign="middle"><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a></td>
<td align="left" width="100%" valign="middle"><span class="nav">&nbsp; &nbsp;<a class="nav" href="{U_INDEX}">{L_INDEX}</a> -> <a class="nav" href="{U_VIEW_FORUM}">{FORUM_NAME}</a></span></td>
<td class="nav" width="100%" align="left" valign="middle"><span class="nav">&nbsp; &nbsp;<a href="{U_INDEX}" class="nav">{L_INDEX}</a>
<!-- BEGIN navlinks -->
-> <a class="nav" href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a>
<!-- END navlinks -->
</span></td>
<td align="right" valign="middle" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span></td>
</tr>
<tr>

View file

@ -63,19 +63,13 @@ $acl = new acl($userdata, $forum_id);
// Check if the user has actually sent a forum ID with his/her request
// If not give them a nice error page.
//
if ( !empty($forum_id) )
{
$sql = "SELECT *
FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
$result = $db->sql_query($sql);
}
else
if (empty($forum_id))
{
message_die(MESSAGE, 'Forum_not_exist');
}
if ( !($forum_data = $db->sql_fetchrow($result)) )
if (!$forum_branch = get_forum_branch($forum_id))
{
message_die(MESSAGE, 'Forum_not_exist');
}
@ -89,7 +83,7 @@ $session->configure($userdata);
//
// Auth check
//
if ( !$acl->get_acl($forum_id, 'forum', 'read') )
if (!$acl->get_acl($forum_id, 'forum', 'read'))
{
if ( $userdata['user_id'] )
{
@ -108,6 +102,67 @@ if ( !$acl->get_acl($forum_id, 'forum', 'read') )
// End of auth check
//
$type = 'parent';
$forum_rows = array();
foreach ($forum_branch as $row)
{
if ($type == 'parent')
{
if ($row['forum_status'] == ITEM_CATEGORY)
{
$link = 'index.' . $phpEx . $SID . '&amp;c=' . $row['forum_id'];
}
else
{
$link = 'viewforum.' . $phpEx . $SID . '&amp;f=' . $row['forum_id'];
}
$template->assign_block_vars('navlinks', array(
'FORUM_NAME' => $row['forum_name'],
'U_VIEW_FORUM' => $link
));
if ($row['forum_id'] == $forum_id)
{
$branch_root_id = 0;
$forum_data = $row;
$type = 'child';
}
}
else
{
if ($row['parent_id'] == $forum_data['forum_id'])
{
//
// Root-level forum
//
$forum_rows[] = $row;
$parent_id = $row['forum_id'];
if ($row['forum_status'] == ITEM_CATEGORY)
{
$branch_root_id = $row['forum_id'];
}
}
elseif ($row['parent_id'] == $branch_root_id)
{
//
// Forum directly under a category
//
$forum_rows[] = $row;
$parent_id = $row['forum_id'];
}
elseif ($row['forum_status'] != ITEM_CATEGORY)
{
if ($acl->get_acl($row['forum_id'], 'forum', 'list'))
{
$subforums[$parent_id][] = $row;
}
}
}
}
//
// Topic read tracking cookie info
//
@ -236,14 +291,10 @@ $select_sort_dir = '<select name="sort_dir">';
$select_sort_dir .= ( $sort_dir == 'a' ) ? '<option value="a" selected="selected">' . $lang['Ascending'] . '</option><option value="d">' . $lang['Descending'] . '</option>' : '<option value="a">' . $lang['Ascending'] . '</option><option value="d" selected="selected">' . $lang['Descending'] . '</option>';
$select_sort_dir .= '</select>';
$post_alt = ( $forum_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_data['forum_name'],
'POST_IMG' => '<img src=' . (( $forum_data['forum_status'] == FORUM_LOCKED ) ? $theme['post_locked'] : $theme['post_new'] ) . ' border="0" alt="' . $post_alt . '" title="' . $post_alt . '" />',
'PAGINATION' => generate_pagination("viewforum.$phpEx$SID&amp;f=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
@ -264,6 +315,7 @@ $template->assign_vars(array(
'L_VIEWS' => $lang['Views'],
'L_POSTS' => $lang['Posts'],
'L_LASTPOST' => $lang['Last_Post'],
'L_RATING' => $lang['Rating'],
'L_VIEW_MODERATORS' => $lang['View_moderators'],
'L_DISPLAY_TOPICS' => $lang['Display_topics'],
'L_SORT_BY' => $lang['Sort_by'],
@ -290,11 +342,24 @@ $template->assign_vars(array(
'S_FORUM_ACTION' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . "&amp;start=$start",
'U_POST_NEW_TOPIC' => 'posting.' . $phpEx . $SID . '&amp;mode=newtopic&amp;f=' . $forum_id,
'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id,
'U_VIEW_MODERATORS' => 'memberslist.' . $phpEx . $SID . '&amp;mode=moderators&amp;f=' . $forum_id,
'U_MARK_READ' => 'viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;mark=topics')
);
//
// Do we have subforums? if so, let's include this harmless file
//
if (count($forum_rows))
{
$template->assign_vars(array(
'S_HAS_SUBFORUM' => TRUE,
'L_SUBFORUM' => (count($forum_rows) == 1) ? $lang['Subforum'] : $lang['Subforums']
));
$root_id = $forum_id;
include($phpbb_root_path . 'includes/forums_display.' . $phpEx);
}
//
// Grab all the basic data. If we're not on page 1 we also grab any
// announcements that may exist.
@ -530,8 +595,8 @@ $nav_links['up'] = array(
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'viewforum_body.html')
);
'body' => 'viewforum_body.html'
));
make_jumpbox('viewforum.'.$phpEx);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);