From a6d3432f8bb39f20a93a65f9145eec608ea7fd37 Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Thu, 30 Aug 2012 22:20:52 +0200 Subject: [feature/soft-delete] Update search to use $post_visibility Todo: Sphinx currently does not respect this setting at all. PHPBB3-9657 --- phpBB/includes/search/fulltext_mysql.php | 40 ++++++-------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) (limited to 'phpBB/includes/search/fulltext_mysql.php') diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 73bf5c52f2..81fb82de93 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -265,7 +265,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param array $m_approve_fid_sql specifies which types of posts a user may view, based on permissions + * @param string $post_visibility specifies which types of posts the user can view in which forums * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match @@ -274,7 +274,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) { // No keywords? No posts. if (!$this->search_query) @@ -292,7 +292,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $sort_key, $topic_id, implode(',', $ex_fid_ary), -// @TODO implode(',', $m_approve_fid_ary), + $post_visibility, implode(',', $author_ary) ))); @@ -354,20 +354,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base break; } -/* if (!sizeof($m_approve_fid_ary)) - { - $m_approve_fid_sql = ' AND p.post_approved = 1'; - } - else if ($m_approve_fid_ary === array(-1)) - { - $m_approve_fid_sql = ''; - } - else - { - $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; - } -*/ - $sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : ''; $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id'; $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; @@ -390,7 +376,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : ''; $sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : ''; $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : ''; - $sql_where_options .= $m_approve_fid_sql; + $sql_where_options .= ' AND ' . $post_visibility; $sql_where_options .= $sql_author; $sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; $sql_where_options .= $sql_match_where; @@ -446,7 +432,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param array $m_approve_fid_sql specifies which types of posts a user may view, based on permissions + * @param string $post_visibility specifies which types of posts the user can view in which forums * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array $author_ary an array of author ids * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match @@ -474,7 +460,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $sort_key, $topic_id, implode(',', $ex_fid_ary), -// @TODO implode(',', $m_approve_fid_ary), + $post_visibility, implode(',', $author_ary), $author_name, ))); @@ -524,19 +510,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base break; } -/* if (!sizeof($m_approve_fid_ary)) - { - $m_approve_fid_sql = ' AND p.post_approved = 1'; - } - else if ($m_approve_fid_ary == array(-1)) - { - $m_approve_fid_sql = ''; - } - else - { - $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; - } -*/ + $m_approve_fid_sql = ' AND ' . $post_visibility; // If the cache was completely empty count the results $calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS '; -- cgit v1.2.1