diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-10-27 13:18:06 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-10-27 13:18:06 +0000 |
commit | edbe99feb66b67eaa1a0a29b093dbdf56bd789fb (patch) | |
tree | 5ee974d07e409a2863acf93d2ff3be855fe56ea2 /phpBB/search.php | |
parent | 6114414650e8dca9420776d5eef9c3db59596581 (diff) | |
download | forums-edbe99feb66b67eaa1a0a29b093dbdf56bd789fb.tar forums-edbe99feb66b67eaa1a0a29b093dbdf56bd789fb.tar.gz forums-edbe99feb66b67eaa1a0a29b093dbdf56bd789fb.tar.bz2 forums-edbe99feb66b67eaa1a0a29b093dbdf56bd789fb.tar.xz forums-edbe99feb66b67eaa1a0a29b093dbdf56bd789fb.zip |
Fix a few items, ability to read private forums, etc. ... must look at reducing need to join on posts table when not absolutely necessary
git-svn-id: file:///svn/phpbb/trunk@4626 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index b54d9082f8..c026f0c104 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -100,6 +100,8 @@ if ($search_keywords || $search_author || $search_id) $sql_forums = array(); while ($row = $db->sql_fetchrow($result)) { +// echo "<br />" . $row['forum_id'] . " -> " . $row['forum_name'] . " :: " . $auth->acl_get('f_read', $row['forum_id']) . " && " . ((!$row['forum_password'] || $row['user_id'] == $user->data['user_id'])); + if ($search_child) { if (in_array($row['forum_id'], $search_forum) && $row['right_id'] > $right_id) @@ -119,7 +121,12 @@ if ($search_keywords || $search_author || $search_id) } $db->sql_freeresult($result); - $sql_forums = (sizeof($search_forum)) ? ' AND p.forum_id IN (' . implode(', ', $sql_forums) . ')' : ''; + if (!sizeof($sql_forums)) + { + trigger_error($user->lang['NO_SEARCH_RESULTS']); + } + + $sql_forums = ' AND p.forum_id IN (' . implode(', ', $sql_forums) . ')'; unset($search_forum); @@ -160,16 +167,20 @@ if ($search_keywords || $search_author || $search_id) if ($show_results == 'posts') { $sql = 'SELECT p.post_id - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t WHERE t.topic_replies = 0 - AND p.post_id = t.topic_id'; + AND p.topic_id = t.topic_id + $sql_forums"; $field = 'post_id'; } else { - $sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE topic_replies = 0'; + $sql = 'SELECT t.topic_id + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t + WHERE t.topic_replies = 0 + AND p.topic_id = t.topic_id + $sql_forums + GROUP BY p.topic_id"; $field = 'topic_id'; } $result = $db->sql_query($sql); @@ -189,18 +200,20 @@ if ($search_keywords || $search_author || $search_id) case 'newposts': if ($show_results == 'posts') { - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . ' - WHERE post_time > ' . $user->data['user_lastvisit']; + $sql = 'SELECT p.post_id + FROM ' . POSTS_TABLE . ' p + WHERE p.post_time > ' . $user->data['user_lastvisit'] . " + $sql_forums"; $field = 'post_id'; } else { $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p - WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' - AND t.topic_id = p.topic_id - GROUP by t.topic_id'; + WHERE p.post_time > ' . $user->data['user_lastvisit'] . " + AND t.topic_id = p.topic_id + $sql_forums + GROUP by p.topic_id"; $field = 'topic_id'; } $result = $db->sql_query($sql); |