From 4be10373b84013f46a7ecb97059dd0dcfd7a9b5e Mon Sep 17 00:00:00 2001 From: Ludovic Arnaud Date: Wed, 22 Jan 2003 20:16:18 +0000 Subject: [PATCH] Merged forum nav for viewtopic/viewforum, fixed cache behavior with an empty icons table. git-svn-id: file:///svn/phpbb/trunk@3359 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 18 ++++++++----- phpBB/viewforum.php | 47 +------------------------------- phpBB/viewtopic.php | 52 +++--------------------------------- 3 files changed, 17 insertions(+), 100 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ea251c47a8..fc14135b36 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -19,7 +19,7 @@ * ***************************************************************************/ -function set_config($config_name, $config_value) +function set_config($config_name, $config_value, $is_dynamic = TRUE) { global $db, $cache, $config; @@ -41,8 +41,11 @@ function set_config($config_name, $config_value) } $config[$config_name] = $config_value; - $cache->put('config', $config); + if (!$is_dynamic) + { + $cache->put('config', $config); + } } function get_userdata($user) @@ -100,7 +103,7 @@ function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $incl // list if currently null, assign basic forum info to template function generate_forum_nav(&$forum_data) { - global $db, $user, $template; + global $db, $user, $template, $phpEx, $SID; // Get forum parents $forum_parents = array(); @@ -683,10 +686,9 @@ function obtain_word_list(&$censors) $censors['replace'][] = $row['replacement']; } while ($row = $db->sql_fetchrow($result)); - - $cache->put('word_censors', $censors); } $db->sql_freeresult($result); + $cache->put('word_censors', $censors); } return true; @@ -697,7 +699,11 @@ function obtain_icons(&$icons) { global $db, $cache; - if (!($icons = $cache->get('icons'))) + if ($cache->exists('icons')) + { + $icons = $cache->get('icons'); + } + else { // Topic icons $sql = "SELECT * diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index cf091624b9..91803c18e8 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -96,53 +96,8 @@ if (!$auth->acl_gets('f_read', 'm_', 'a_', $forum_id)) } // End of auth check -// Get forum parents -$forum_parents = array(); -if ($forum_data['parent_id'] > 0) -{ - if (empty($forum_data['forum_parents'])) - { - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE left_id < ' . $forum_data['left_id'] . ' - AND right_id > ' . $forum_data['right_id'] . ' - ORDER BY left_id ASC'; - - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $forum_parents[$row['forum_id']] = $row['forum_name']; - } - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = '" . sql_escape(serialize($forum_parents)) . "' - WHERE parent_id = " . $forum_data['parent_id']; - $db->sql_query($sql); - } - else - { - $forum_parents = unserialize($forum_data['forum_parents']); - } -} - // Build navigation links -foreach ($forum_parents as $parent_forum_id => $parent_name) -{ - $template->assign_block_vars('navlinks', array( - 'FORUM_NAME' => $parent_name, - 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id - )); -} -$template->assign_block_vars('navlinks', array( - 'FORUM_NAME' => $forum_data['forum_name'], - 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id -)); - -$template->assign_vars(array( - 'FORUM_ID' => $forum_id, - 'FORUM_NAME' => $forum_data['forum_name'], - 'FORUM_DESC' => strip_tags($forum_data['forum_desc']) -)); +generate_forum_nav($forum_data); // Moderators $forum_moderators = array(); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 053be02816..4926ea1440 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -130,11 +130,11 @@ $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.top $order_sql"; $result = $db->sql_query($sql); -if (!extract($db->sql_fetchrow($result))) +if (!$topic_data = $db->sql_fetchrow($result)) { trigger_error('Topic_post_not_exist'); } - +extract($topic_data); @@ -335,52 +335,8 @@ if (sizeof($censors)) } - -// Navigation links ... common to several scripts so we need -// to look at centralising this ... major issue is variable naming -// complicated particularly by viewtopic ... -if ($parent_id > 0) -{ - if (empty($forum_parents)) - { - $sql = 'SELECT forum_id, forum_name - FROM ' . FORUMS_TABLE . ' - WHERE left_id < ' . $left_id . ' - AND right_id > ' . $right_id . ' - ORDER BY left_id ASC'; - - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $forum_parents[$row['forum_id']] = $row['forum_name']; - } - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = '" . $db->sql_escape(serialize($forum_parents)) . "' - WHERE parent_id = " . $parent_id; - $db->sql_query($sql); - } - else - { - $forum_parents = unserialize($forum_parents); - } -} - - - -// Build navigation links -foreach ($forum_parents as $parent_forum_id => $parent_name) -{ - $template->assign_block_vars('navlinks', array( - 'FORUM_NAME' => $parent_name, - 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $parent_forum_id - )); -} -$template->assign_block_vars('navlinks', array( - 'FORUM_NAME' => $forum_name, - 'U_VIEW_FORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id -)); - +// Navigation links +generate_forum_nav($topic_data); // Moderators