From 5ffd76aa65b25098bdf44d6a863b08103c863ac2 Mon Sep 17 00:00:00 2001 From: Ice Date: Tue, 12 Aug 2008 00:30:57 +0000 Subject: [PATCH] recent.php: f=0 fix, wrong constant functions.php: use a constant --- root/portal/block/recent.php | 22 +++++++++++++++++++--- root/portal/includes/functions.php | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/root/portal/block/recent.php b/root/portal/block/recent.php index b1967568..3ca291a2 100644 --- a/root/portal/block/recent.php +++ b/root/portal/block/recent.php @@ -36,6 +36,22 @@ if ($portal_config['portal_exclude_forums']) } } +// Get a list of forums the user cannot read +$forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true))); + +// Determine first forum the user is able to read (must not be a category) +$sql = 'SELECT forum_id +FROM ' . FORUMS_TABLE . ' +WHERE forum_type = ' . FORUM_POST; + +if (sizeof($forum_ary)) +{ +$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); +} + +$result = $db->sql_query_limit($sql, 1); +$g_forum_id = (int) $db->sql_fetchfield('forum_id'); + // // Recent announcements // @@ -58,7 +74,7 @@ while( ($row = $db->sql_fetchrow($result)) && ($row['topic_title']) ) $template->assign_block_vars('latest_announcements', array( 'TITLE' => character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']), 'FULL_TITLE' => censor_text($row['topic_title']), - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']) + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . ( ($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id'] ) . '&t=' . $row['topic_id']) )); } } @@ -85,7 +101,7 @@ while( ($row = $db->sql_fetchrow($result)) && ($row['topic_title']) ) $template->assign_block_vars('latest_hot_topics', array( 'TITLE' => character_limit($row['topic_title'], $portal_config['portal_recent_title_limit']), 'FULL_TITLE' => censor_text($row['topic_title']), - 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']) + 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . ( ($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id'] ) . '&t=' . $row['topic_id']) )); } } @@ -96,7 +112,7 @@ $db->sql_freeresult($result); // $sql = 'SELECT topic_title, forum_id, topic_id FROM ' . TOPICS_TABLE . ' - WHERE topic_status <> ' . FORUM_LINK . ' + WHERE topic_status <> ' . ITEM_MOVED . ' AND topic_approved = 1 AND topic_type = ' . POST_NORMAL . ' AND topic_moved_id = 0 diff --git a/root/portal/includes/functions.php b/root/portal/includes/functions.php index 335877d5..be731e58 100644 --- a/root/portal/includes/functions.php +++ b/root/portal/includes/functions.php @@ -224,7 +224,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le 'WHERE' => $topic_type . ' ' . $post_time . ' - AND t.topic_status <> 2 + AND t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_approved = 1 AND t.topic_moved_id = 0 ' . $str_where,