diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 95086e906e..ee05349fbf 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -157,7 +157,7 @@ if ($forum_data['forum_postable'])
if ($forum_data['prune_next'] < time() && $forum_data['prune_enable'])
{
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
- auto_prune($forum_id);
+ auto_prune($forum_id, $forum_data['prune_days'], $forum_data['prune_freq']);
}
}
@@ -263,71 +263,41 @@ if ($forum_data['forum_postable'])
$topics_list = '';
$row_ary = array();
-// if (empty($forum_data['topics_list']))
-// {
- $sql = 'SELECT t.*, lr.lastread_time, lr.lastread_type
- FROM (' . TOPICS_TABLE . ' t
- LEFT JOIN ' . LASTREAD_TABLE . ' lr ON lr.topic_id = t.topic_id
- AND lr.user_id = ' . $user->data['user_id'] . ")
- WHERE (t.forum_id = $forum_id
- OR t.forum_id = 0)
- AND t.topic_type = " . POST_ANNOUNCE . "
- ORDER BY $sort_order_sql";
- $result = $db->sql_query_limit($sql, $config['topics_per_page']);
+ $sql = 'SELECT t.*, lr.lastread_time, lr.lastread_type
+ FROM (' . TOPICS_TABLE . ' t
+ LEFT JOIN ' . LASTREAD_TABLE . ' lr ON lr.topic_id = t.topic_id
+ AND lr.user_id = ' . $user->data['user_id'] . ")
+ WHERE (t.forum_id = $forum_id
+ OR t.forum_id = 0)
+ AND t.topic_type = " . POST_ANNOUNCE . "
+ ORDER BY $sort_order_sql";
- while($row = $db->sql_fetchrow($result))
- {
-// $topics_list .= '.' . str_pad(base_convert($row['topic_id'], 10, 36), 5, '0', STR_PAD_LEFT);
- $row_ary[] = $row;
- $total_topics++;
- }
- $db->sql_freeresult($result);
-
- $sql = 'SELECT t.*, lr.lastread_time, lr.lastread_type
- FROM (' . TOPICS_TABLE . ' t
- LEFT JOIN ' . LASTREAD_TABLE . ' lr ON lr.topic_id = t.topic_id
- AND lr.user_id = ' . $user->data['user_id'] . ")
- WHERE t.forum_id = $forum_id
- " . (($auth->acl_gets('m_approve', 'a_', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
- AND t.topic_type <> " . POST_ANNOUNCE . "
- $limit_topics_time
- ORDER BY t.topic_type DESC, $sort_order_sql";
-/* }
- else
- {
-
- $topic_ids = array();
- preg_match_all('/.{5,5}/', $forum_data['topics_list'], $m);// explode('.' ?
- foreach ($m[0] as $topic_id)
- {
- $topic_ids[] = base_convert($topic_id, 36, 10);
- }
-
- $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2
- FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . USERS_TABLE . " u2
- WHERE t.topic_id IN (" . implode(', ', $topic_ids) . ")
- AND u.user_id = t.topic_poster
- AND u2.user_id = t.topic_last_poster_id
- ORDER BY $sort_order";
- }*/
$result = $db->sql_query_limit($sql, $config['topics_per_page']);
while($row = $db->sql_fetchrow($result))
{
-// $topics_list .= str_pad(base_convert($row['topic_id'], 10, 36), 5, '0', STR_PAD_LEFT);
$row_ary[] = $row;
$total_topics++;
}
$db->sql_freeresult($result);
-/*
- if (empty($forum_data['topics_list']) && !empty($topics_list))
+ $sql = 'SELECT t.*, lr.lastread_time, lr.lastread_type
+ FROM (' . TOPICS_TABLE . ' t
+ LEFT JOIN ' . LASTREAD_TABLE . ' lr ON lr.topic_id = t.topic_id
+ AND lr.user_id = ' . $user->data['user_id'] . ")
+ WHERE t.forum_id = $forum_id
+ " . (($auth->acl_gets('m_approve', 'a_', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
+ AND t.topic_type <> " . POST_ANNOUNCE . "
+ $limit_topics_time
+ ORDER BY t.topic_type DESC, $sort_order_sql";
+ $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
+
+ while($row = $db->sql_fetchrow($result))
{
- $sql = 'INSERT INTO ' . TOPICS_PREFETCH_TABLE . " (forum_id, start, sort_key, sort_dir, topics_list)
- VALUES ($forum_id, $start, '$sort_key', '$sort_dir', '$topics_list')";
- $db->sql_query($sql);
+ $row_ary[] = $row;
+ $total_topics++;
}
-*/
+ $db->sql_freeresult($result);
// Okay, lets dump out the page ...
if ($total_topics)
@@ -413,7 +383,7 @@ if ($forum_data['forum_postable'])
// Goto message generation
- $replies = $row['topic_replies'];
+ $replies = ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'];
if (($replies + 1) > intval($config['posts_per_page']))
{
@@ -475,7 +445,7 @@ if ($forum_data['forum_postable'])
'LAST_POST_TIME' => $last_post_time,
'LAST_POST_AUTHOR' => $last_post_author,
'GOTO_PAGE' => $goto_page,
- 'REPLIES' => $row['topic_replies'],
+ 'REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'],
'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'],
'TOPIC_TYPE' => $topic_type,
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index de952d0fe8..38f60b6b22 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -153,7 +153,7 @@ if ($user->data['user_id'] != ANONYMOUS)
// whereupon we join on the forum_id passed as a parameter ... this
// is done so navigation, forum name, etc. remain consistent with where
// user clicked to view a global topic
-$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style" . $extra_fields . "
+$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, " . (($auth->acl_get('m_approve')) ? 't.topic_replies_real AS topic_replies' : 't.topic_replies') . " , t.topic_time, t.topic_type, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style" . $extra_fields . "
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
WHERE $join_sql
AND (f.forum_id = t.forum_id
@@ -167,6 +167,7 @@ if (!$topic_data = $db->sql_fetchrow($result))
{
trigger_error('NO_TOPIC');
}
+$topic_data['topic_replies'] = max(0, $topic_data['topic_replies']);
extract($topic_data);
@@ -350,8 +351,9 @@ $template->assign_vars(array(
'MCP' => ($auth->acl_get('m_', $forum_id)) ? sprintf($user->lang['MCP'], "session_id . "&t=$topic_id&start=$start&sort_days=$sort_days&sort_key=$sort_key&sort_dir=$sort_dir&posts_per_page=" . $config['posts_per_page'] . '">', '') : '',
'MODERATORS' => (sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : $user->lang['NONE'],
- 'POST_IMG' => $post_img,
- 'REPLY_IMG' => $reply_img,
+ 'POST_IMG' => $post_img,
+ 'REPLY_IMG' => $reply_img,
+ 'REPORT_IMG' => $user->img('icon_report', $user->lang['REPORT_TO_ADMIN']),
'REPORTED_IMG' => $user->img('item_reported', 'POST_BEEN_REPORTED'),
'UNAPPROVED_IMG' => $user->img('item_unapproved', 'POST_NOT_BEEN_APPROVED'),
@@ -859,8 +861,6 @@ if ($row = $db->sql_fetchrow($result))
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_gets('m_', $forum_id)) ? TRUE : FALSE,
'U_REPORT' => "report.$phpEx$SID&p=" . $row['post_id'],
'U_MCP_REPORT' => "mcp.$phpEx$SID&mode=post_details&p=" . $row['post_id'],
-// no img yet as I could not get the subSilver to work with PSP - Ashe
- 'REPORT_IMG' => $user->img('icon_report', $user->lang['REPORT_TO_ADMIN']),
'POST_ICON' => (!empty($row['icon_id'])) ? '' : '',