diff options
author | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-11-05 04:50:55 +0000 |
---|---|---|
committer | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-11-05 04:50:55 +0000 |
commit | bc6e36ef4f79132029f4f27f592872311724097b (patch) | |
tree | 612cf91829c5dba2d33dd2ad8bbd81cbf04d0a3b | |
parent | 5b73ad4cbd8c83f1fd5cc5713836e15caff8a045 (diff) | |
download | forums-bc6e36ef4f79132029f4f27f592872311724097b.tar forums-bc6e36ef4f79132029f4f27f592872311724097b.tar.gz forums-bc6e36ef4f79132029f4f27f592872311724097b.tar.bz2 forums-bc6e36ef4f79132029f4f27f592872311724097b.tar.xz forums-bc6e36ef4f79132029f4f27f592872311724097b.zip |
viewforum queries update + a couple of bugfixes.
git-svn-id: file:///svn/phpbb/trunk@3007 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/admin/admin_forums.php | 17 | ||||
-rw-r--r-- | phpBB/db/mysql.php | 4 | ||||
-rw-r--r-- | phpBB/includes/forums_display.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 33 | ||||
-rw-r--r-- | phpBB/includes/usercp_register.php | 18 | ||||
-rw-r--r-- | phpBB/index.php | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_basic.sql | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_schema.sql | 1 | ||||
-rw-r--r-- | phpBB/posting.php | 10 | ||||
-rw-r--r-- | phpBB/search.php | 6 | ||||
-rw-r--r-- | phpBB/viewforum.php | 219 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 22 |
12 files changed, 225 insertions, 111 deletions
diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index 021dbcbb96..3e79720dff 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -222,6 +222,13 @@ switch ($mode) { move_forum($forum_id, $parent_id); } + elseif ($row['forum_name'] != $_POST['forum_name']) + { + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_parents = "" + WHERE left_id > ' . $row['left_id'] . ' AND right_id < ' . $row['right_id']; + $db->sql_query($sql); + } $sql = array( 'forum_name' => (!empty($_POST['forum_name'])) ? $_POST['forum_name'] : $row['forum_name'], @@ -904,7 +911,7 @@ function move_forum($from_id, $to_id) // Resync parents // $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff + SET right_id = right_id - $diff, forum_parents = '' WHERE left_id < " . $from_data['right_id'] . " AND right_id > " . $from_data['right_id']; $db->sql_query($sql); @@ -912,7 +919,7 @@ function move_forum($from_id, $to_id) // Resync righthand side of tree // $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff + SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' WHERE left_id > " . $from_data['right_id']; $db->sql_query($sql); @@ -924,7 +931,7 @@ function move_forum($from_id, $to_id) // Resync new parents // $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id + $diff + SET right_id = right_id + $diff, forum_parents = '' WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id AND forum_id NOT IN (' . implode(', ', $moved_ids) . ')'; $db->sql_query($sql); @@ -933,7 +940,7 @@ function move_forum($from_id, $to_id) // Resync the righthand side of the tree // $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + $diff, right_id = right_id + $diff + SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' WHERE left_id > " . $to_data['right_id'] . ' AND forum_id NOT IN (' . implode(', ', $moved_ids) . ')'; $db->sql_query($sql); @@ -960,7 +967,7 @@ function move_forum($from_id, $to_id) } $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id $diff, right_id = right_id $diff + SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' WHERE forum_id IN (" . implode(', ', $moved_ids) . ')'; $db->sql_query($sql); } diff --git a/phpBB/db/mysql.php b/phpBB/db/mysql.php index 1898d0ce91..8776d3e5ac 100644 --- a/phpBB/db/mysql.php +++ b/phpBB/db/mysql.php @@ -226,7 +226,7 @@ class sql_db } elseif (is_string($var)) { - $values[] = "'" . str_replace('\\\'', '\'\'', $var) . "'"; + $values[] = "'" . sql_quote($var) . "'"; } else { @@ -247,7 +247,7 @@ class sql_db } elseif (is_string($var)) { - $values[] = "$key = '" . str_replace('\\\'', '\'\'', $var) . "'"; + $values[] = "$key = '" . sql_quote($var) . "'"; } else { diff --git a/phpBB/includes/forums_display.php b/phpBB/includes/forums_display.php index 820d7cb2e3..7810118158 100644 --- a/phpBB/includes/forums_display.php +++ b/phpBB/includes/forums_display.php @@ -77,7 +77,7 @@ foreach ($forum_rows as $row) { $last_post = $user->format_date($forum_last_post_time) . '<br />'; - $last_post .= ($forum_last_poster_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $user->lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $forum_last_poster_id . '">' . $username . '</a> '; + $last_post .= ($forum_last_poster_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $user->lang['Guest'] . ' ') : '<a href="profile.' . $phpEx . $SID . '&mode=viewprofile&u=' . $forum_last_poster_id . '">' . $forum_last_poster_name . '</a> '; $last_post .= '<a href="viewtopic.' . $phpEx . $SID . '&f=' . $forum_id . '&p=' . $forum_last_post_id . '#' . $forum_last_post_id . '">' . $user->img('goto_post_latest', 'View_latest_post') . '</a>'; } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 970c727d4d..555a2f0774 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -19,6 +19,11 @@ * ***************************************************************************/ +function sql_addslashes($msg) +{ + return str_replace("'", "''", str_replace('\\', '\\\\', $msg)); +} + function sql_quote($msg) { return str_replace("\'", "''", $msg); @@ -394,7 +399,7 @@ function tz_select($default, $select_name = 'timezone') } // Topic and forum watching common code -function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $match_id) +function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $match_id, $notify_status = 'unset') { global $template, $db, $user, $phpEx, $SID, $start; @@ -407,13 +412,25 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat { $can_watch = TRUE; - $sql = "SELECT notify_status - FROM " . $table_sql . " - WHERE $where_sql = $match_id - AND user_id = $user_id"; - $result = $db->sql_query($sql); + if ($notify_status == 'unset') + { + $sql = "SELECT notify_status + FROM $table_sql + WHERE $where_sql = $match_id + AND user_id = $user_id"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $notify_status = $row['notify_status']; + } + else + { + $notify_status = NULL; + } + } - if ( $row = $db->sql_fetchrow($result) ) + if (!is_null($notify_status)) { if ( isset($_GET['unwatch']) ) { @@ -438,7 +455,7 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat { $is_watching = TRUE; - if ( $row['notify_status'] ) + if ($notify_status) { $sql = "UPDATE " . $table_sql . " SET notify_status = 0 diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php index e443f37e59..81d66f07af 100644 --- a/phpBB/includes/usercp_register.php +++ b/phpBB/includes/usercp_register.php @@ -288,6 +288,13 @@ if (isset($_POST['submit'])) else { $username_sql = "username = '" . sql_quote($username) . "', "; + if ($mode != 'register') + { + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_last_poster_name = '" . sql_quote($username) . "' + WHERE forum_last_poster_id = " . $user_id; + $db->sql_query($sql); + } } } } @@ -359,7 +366,6 @@ if (isset($_POST['submit'])) 'user_dateformat' => $user_dateformat, 'user_lang' => $user_lang, 'user_style' => $user_style, - 'user_level' => 0, 'user_allow_pm' => 1, 'user_active' => $user_active, 'user_actkey' => $user_actkey @@ -367,7 +373,15 @@ if (isset($_POST['submit'])) if ($mode == 'editprofile') { - $db->sql_query_array('UPDATE ' . USERS_TABLE . ' SET WHERE user_id = ' . $user_id, &$sql_ary); + $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user_id); + + if ($config['newest_user_id'] == $user_id) + { + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . sql_quote($username) . "' + WHERE config_name = 'newest_username'"; + $db->sql_query($sql); + } if ( !$user_active ) { diff --git a/phpBB/index.php b/phpBB/index.php index 94651a46f6..7e224d830b 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -109,6 +109,8 @@ if ($cat_id == 0) LEFT JOIN ' . USERS_TABLE . ' u ON f.forum_last_poster_id = u.user_id ORDER BY f.left_id'; } + + $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' ORDER BY left_id'; } else { diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index 0cf0c34fb9..8ed7667703 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -80,7 +80,7 @@ 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, is_dynamic) VALUES ('record_online_users', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_date', '0', 1); -INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '1', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '2', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_username', '', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_users', '1', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_posts', '1', 1); diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index c5d663b60a..c0e216906d 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -113,6 +113,7 @@ CREATE TABLE phpbb_forums ( parent_id smallint(5) UNSIGNED NOT NULL, left_id smallint(5) UNSIGNED NOT NULL, right_id smallint(5) UNSIGNED NOT NULL, + forum_parents text, forum_name varchar(150) NOT NULL, forum_desc text, forum_style tinyint(4) UNSIGNED, diff --git a/phpBB/posting.php b/phpBB/posting.php index 34890ee7eb..5f4f321baf 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -19,6 +19,10 @@ * ***************************************************************************/ +// Grab all data +extract($_GET); +extract($_POST); + define('IN_PHPBB', true); $phpbb_root_path = './'; include($phpbb_root_path . 'extension.inc'); @@ -31,10 +35,6 @@ $user->setup(); $auth->acl($user->data); // End session management -// Grab all data -extract($_GET); -extract($_POST); - // Was cancel pressed? If so then redirect to the appropriate page if ( !empty($cancel) ) { @@ -398,7 +398,7 @@ if (isset($post)) 'forum_last_post_id' => intval($post_id), 'forum_last_post_time' => $current_time, 'forum_last_poster_id' => intval($user->data['user_id']), - 'forum_last_poster_name'=> ($username != '') ? $username : '', + 'forum_last_poster_name'=> ($user->data['user_id'] == ANONYMOUS) ? $username : $user->data['username'], ); $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $forum_sql) . ', forum_posts = forum_posts + 1' . $forum_topics_sql . ' WHERE forum_id = ' . intval($forum_id); $db->sql_query($sql); diff --git a/phpBB/search.php b/phpBB/search.php index e767f7d43c..bbd76ef591 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -135,8 +135,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { - header("Location: login.$phpEx?redirect=search.$phpEx&search_id=newposts", true); - exit; + redirect("login.$phpEx?redirect=search.$phpEx&search_id=newposts"); } $show_results = 'topics'; @@ -153,8 +152,7 @@ if ( $search_keywords != '' || $search_author != '' || $search_id ) } else { - header("Location: login.$phpEx?redirect=search.$phpEx&search_id=egosearch", true); - exit; + redirect("login.$phpEx?redirect=search.$phpEx&search_id=egosearch"); } $show_results = 'topics'; diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index e4ac031b96..423bdbfa0e 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -33,24 +33,8 @@ if (preg_match('/^c([0-9]+)$/', $_POST['f'], $m)) include($phpbb_root_path . 'common.'.$phpEx); // Start initial var setup -if (isset($_GET['f']) || isset($_POST['f'])) -{ - $forum_id = (isset($_GET['f'])) ? intval($_GET['f']) : intval($_POST['f']); -} -else -{ - $forum_id = ''; -} - -if (isset($_GET['mark']) || isset($_POST['mark'])) -{ - $mark_read = (isset($_POST['mark'])) ? $_POST['mark'] : $_GET['mark']; -} -else -{ - $mark_read = ''; -} - +$mark_read = (!empty($_REQUEST['mark'])) ? $_REQUEST['mark'] : ''; +$forum_id = (!empty($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0; $start = (isset($_GET['start'])) ? intval($_GET['start']) : 0; // End initial var setup @@ -59,100 +43,176 @@ $user->start(); // 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)) +if (!$forum_id) { trigger_error('Forum_not_exist'); } -if (!$forum_branch = get_forum_branch($forum_id)) +if ($user->data['user_id'] == ANONYMOUS) +{ + $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $forum_id; +} +else +{ + switch (SQL_LAYER) + { + //TODO + case 'oracle': + break; + + default: + $sql = 'SELECT f.*, fw.notify_status + FROM ' . FORUMS_TABLE . ' f + LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id + WHERE f.forum_id = ' . $forum_id; + } +} +$result = $db->sql_query($sql); +if (!$forum_data = $db->sql_fetchrow($result)) { trigger_error('Forum_not_exist'); } // Configure style, language, etc. -$user->setup(false, $forum_branch['forum_style']); +$user->setup(false, $forum_data['forum_style']); $auth->acl($user->data, $forum_id); // Auth check if (!$auth->acl_gets('f_read', 'm_', 'a_', $forum_id)) { - if (!$user->data['user_id'] != ANONYMOUS) + if ($user->data['user_id'] == ANONYMOUS) { redirect("login.$phpEx$SID&redirect=viewforum.$phpEx&f=$forum_id" . ((isset($start)) ? "&start=$start" : '')); } - trigger_error($user->lang['Sorry_auth_read']); + trigger_error('Sorry_auth_read'); } // End of auth check -// Build subforums list if applicable -//$forum_data = array(); -//$s_has_subforums = forum_nav_links($forum_id, $forum_data); -$type = 'parent'; -$forum_rows = array(); - -foreach ($forum_branch as $row) +// Get forum parents +$forum_parents = array(); +if ($forum_data['parent_id'] > 0) { - if ($type == 'parent') + if (empty($forum_data['forum_parents'])) { - if ($row['forum_status'] == ITEM_CATEGORY) - { - $link = 'index.' . $phpEx . $SID . '&c=' . $row['forum_id']; - } - else - { - $link = 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id']; - } + $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'; - $template->assign_block_vars('navlinks', array( - 'FORUM_NAME' => $row['forum_name'], - 'U_VIEW_FORUM' => $link - )); - - if ($row['forum_id'] == $forum_id) + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) { - $branch_root_id = 0; - $forum_data = $row; - $type = 'child'; + $forum_parents[$row['forum_id']] = $row['forum_name']; } + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_parents = '" . sql_addslashes(serialize($forum_parents)) . "' + WHERE parent_id = " . $forum_data['parent_id']; + $db->sql_query($sql); } else { - if ($row['parent_id'] == $forum_data['forum_id']) + $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 +)); + + +// Get forum children +if ($forum_data['left_id'] != $forum_data['right_id'] - 1) +{ + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . ' + WHERE left_id > ' . $forum_data['left_id'] . ' AND left_id < ' . $forum_data['right_id'] . ' + ORDER BY left_id ASC'; + $result = $db->sql_query($sql); + + $type = 'parent'; + $forum_rows = array(); + + while ($row = $db->sql_fetchrow($result)) + { +/* + if ($type == 'parent') { - // Root-level forum - $forum_rows[] = $row; - $parent_id = $row['forum_id']; if ($row['forum_status'] == ITEM_CATEGORY) { - $branch_root_id = $row['forum_id']; + $link = 'index.' . $phpEx . $SID . '&c=' . $row['forum_id']; } else { - $s_has_subforums = TRUE; + $link = 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id']; } - } - elseif ($row['parent_id'] == $branch_root_id) - { - // Forum directly under a category - $forum_rows[] = $row; - $parent_id = $row['forum_id']; - if ($row['forum_status'] != ITEM_CATEGORY) + $template->assign_block_vars('navlinks', array( + 'FORUM_NAME' => $row['forum_name'], + 'U_VIEW_FORUM' => $link + )); + + if ($row['forum_id'] == $forum_id) { - $s_has_subforums = TRUE; + $branch_root_id = 0; + $forum_data = $row; + $type = 'child'; } } - elseif ($row['forum_status'] != ITEM_CATEGORY) + else { - // Subforum - if ($auth->acl_get('f_list', $row['forum_id'])) +*/ + if ($row['parent_id'] == $forum_data['forum_id']) { - $subforums[$parent_id][] = $row; + // Root-level forum + $forum_rows[] = $row; + $parent_id = $row['forum_id']; + + if ($row['forum_status'] == ITEM_CATEGORY) + { + $branch_root_id = $row['forum_id']; + } + else + { + $s_has_subforums = TRUE; + } } + elseif ($row['parent_id'] == $branch_root_id) + { + // Forum directly under a category + $forum_rows[] = $row; + $parent_id = $row['forum_id']; + + if ($row['forum_status'] != ITEM_CATEGORY) + { + $s_has_subforums = TRUE; + } + } + elseif ($row['forum_status'] != ITEM_CATEGORY) + { + // Subforum + if ($auth->acl_get('f_list', $row['forum_id'])) + { + $subforums[$parent_id][] = $row; + } + } +/* } +*/ } + $db->sql_freeresult(); } // Topic read tracking cookie info @@ -192,7 +252,8 @@ if ($auth->acl_gets('m_prune', 'a_', $forum_id) && $config['prune_enable']) // Forum rules, subscription info and word censors $s_watching_forum = ''; $s_watching_forum_img = ''; -watch_topic_forum('forum', $s_watching_forum, $s_watching_forum_img, $user->data['user_id'], $forum_id); +$notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; +watch_topic_forum('forum', $s_watching_forum, $s_watching_forum_img, $user->data['user_id'], $forum_id, $notify_status); $s_forum_rules = ''; get_forum_rules('forum', $s_forum_rules, $forum_id); @@ -324,18 +385,6 @@ $template->assign_vars(array( 'U_MARK_READ' => 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '&mark=topics') ); -// Do we have subforums? if so, let's include this harmless file -if ($s_has_subforums) -{ - $template->assign_vars(array( - 'S_HAS_SUBFORUM' => TRUE, - 'L_SUBFORUM' => (count($forum_rows) == 1) ? $user->lang['Subforum'] : $user->lang['Subforums'] - )); - - $root_id = $forum_id; - include($phpbb_root_path . 'includes/forums_display.' . $phpEx); -} - // Topic icons $sql = "SELECT * FROM " . ICONS_TABLE . " @@ -552,6 +601,18 @@ $nav_links['up'] = array( 'title' => sprintf($user->lang['Forum_Index'], $config['sitename']) ); +// Do we have subforums? if so, let's include this harmless file +if ($forum_data['left_id'] != $forum_data['right_id'] - 1) +{ + $template->assign_vars(array( + 'S_HAS_SUBFORUM' => TRUE, + 'L_SUBFORUM' => (count($forum_rows) == 1) ? $user->lang['Subforum'] : $user->lang['Subforums'] + )); + + $root_id = $forum_id; + include($phpbb_root_path . 'includes/forums_display.' . $phpEx); +} + include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index aad4076ab3..f0d1c9a5f1 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -137,17 +137,31 @@ if ($user->data['user_id'] != ANONYMOUS) // page the post is on and the correct display of viewtopic) $join_sql_table = (!$post_id) ? '' : ', ' . POSTS_TABLE . ' p, ' . POSTS_TABLE . ' p2 '; $join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = " . TRUE . " AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = " . TRUE . " AND p2.post_id <= $post_id"; -$count_sql = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts"; +$extra_fields = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts"; $order_sql = (!$post_id) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, f.forum_name, f.forum_status, f.forum_id, f.forum_style ORDER BY p.post_id ASC"; -$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_status, f.forum_id, f.forum_style" . $count_sql . " +if ($user->data['user_id'] != ANONYMOUS) +{ + switch (SQL_LAYER) + { + //TODO + case 'oracle': + break; + + default: + $extra_fields .= ', tw.notify_status'; + $join_sql_table .= ' LEFT JOIN ' . TOPICS_WATCH_TABLE . ' tw ON tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id'; + } +} + +$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_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 $order_sql"; $result = $db->sql_query($sql); -if (!(extract($db->sql_fetchrow($result)))) +if (!extract($db->sql_fetchrow($result))) { trigger_error('Topic_post_not_exist'); } @@ -178,7 +192,7 @@ if (!empty($post_id)) $s_watching_topic = ''; $s_watching_topic_img = ''; -watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data['user_id'], $topic_id); +watch_topic_forum('topic', $s_watching_topic, $s_watching_topic_img, $user->data['user_id'], $topic_id, $notify_status); // Post ordering options $previous_days = array(0 => $user->lang['All_Posts'], 1 => $user->lang['1_Day'], 7 => $user->lang['7_Days'], 14 => $user->lang['2_Weeks'], 30 => $user->lang['1_Month'], 90 => $user->lang['3_Months'], 180 => $user->lang['6_Months'], 364 => $user->lang['1_Year']); |