mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 13:58:54 +00:00
[feature/soft-delete] Update search to use $post_visibility
Todo: Sphinx currently does not respect this setting at all. PHPBB3-9657
This commit is contained in:
parent
5b54ec2d64
commit
a6d3432f8b
5 changed files with 36 additions and 93 deletions
|
@ -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_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 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 $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 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 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
|
* @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
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @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.
|
// No keywords? No posts.
|
||||||
if (!$this->search_query)
|
if (!$this->search_query)
|
||||||
|
@ -292,7 +292,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
|
||||||
$sort_key,
|
$sort_key,
|
||||||
$topic_id,
|
$topic_id,
|
||||||
implode(',', $ex_fid_ary),
|
implode(',', $ex_fid_ary),
|
||||||
// @TODO implode(',', $m_approve_fid_ary),
|
$post_visibility,
|
||||||
implode(',', $author_ary)
|
implode(',', $author_ary)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
@ -354,20 +354,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
|
||||||
break;
|
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 = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : '';
|
||||||
$sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id';
|
$sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id';
|
||||||
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';
|
$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 .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
|
||||||
$sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.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 .= (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 .= $sql_author;
|
||||||
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||||
$sql_where_options .= $sql_match_where;
|
$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_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 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 $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 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 array $author_ary an array of author ids
|
||||||
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
* @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,
|
$sort_key,
|
||||||
$topic_id,
|
$topic_id,
|
||||||
implode(',', $ex_fid_ary),
|
implode(',', $ex_fid_ary),
|
||||||
// @TODO implode(',', $m_approve_fid_ary),
|
$post_visibility,
|
||||||
implode(',', $author_ary),
|
implode(',', $author_ary),
|
||||||
$author_name,
|
$author_name,
|
||||||
)));
|
)));
|
||||||
|
@ -524,19 +510,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (!sizeof($m_approve_fid_ary))
|
$m_approve_fid_sql = ' AND ' . $post_visibility;
|
||||||
{
|
|
||||||
$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) . ')';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// If the cache was completely empty count the results
|
// If the cache was completely empty count the results
|
||||||
$calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS ';
|
$calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS ';
|
||||||
|
|
|
@ -414,7 +414,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
|
||||||
* @param string $sort_dir is either a or d representing ASC and DESC
|
* @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 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 $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 the user can view
|
* @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 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 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
|
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
||||||
|
@ -423,7 +423,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
|
||||||
* @param int $per_page number of ids each page is supposed to contain
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @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.
|
// No keywords? No posts.
|
||||||
if (empty($this->search_query))
|
if (empty($this->search_query))
|
||||||
|
@ -451,7 +451,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
|
||||||
$sort_key,
|
$sort_key,
|
||||||
$topic_id,
|
$topic_id,
|
||||||
implode(',', $ex_fid_ary),
|
implode(',', $ex_fid_ary),
|
||||||
// @TODO implode(',', $m_approve_fid_ary),
|
$post_visibility,
|
||||||
implode(',', $author_ary),
|
implode(',', $author_ary),
|
||||||
$author_name,
|
$author_name,
|
||||||
)));
|
)));
|
||||||
|
@ -628,16 +628,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
|
||||||
$sql_where[] = '(' . implode(' OR ', $is_null_joins) . ')';
|
$sql_where[] = '(' . implode(' OR ', $is_null_joins) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (!sizeof($m_approve_fid_ary))
|
$sql_where[] = $post_visibility;
|
||||||
{
|
|
||||||
$sql_where[] = 'p.post_approved = 1';
|
|
||||||
}
|
|
||||||
else if ($m_approve_fid_ary !== array(-1))
|
|
||||||
{
|
|
||||||
$sql_where[] = '(p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$sql_where[] = $m_approve_fid_sql;
|
|
||||||
|
|
||||||
if ($topic_id)
|
if ($topic_id)
|
||||||
{
|
{
|
||||||
|
@ -810,7 +801,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
|
||||||
* @param string $sort_dir is either a or d representing ASC and DESC
|
* @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 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 $ex_fid_ary specifies an array of forum ids which should not be searched
|
||||||
* @param array $m_approve_fid_sql specifies which posts a user can 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 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 array $author_ary an array of author ids
|
||||||
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
||||||
|
|
|
@ -234,7 +234,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
* @param string $sort_dir is either a or d representing ASC and DESC
|
* @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 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 $ex_fid_ary specifies an array of forum ids which should not be searched
|
||||||
* @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
|
* @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 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 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
|
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
||||||
|
@ -261,7 +261,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
$sort_key,
|
$sort_key,
|
||||||
$topic_id,
|
$topic_id,
|
||||||
implode(',', $ex_fid_ary),
|
implode(',', $ex_fid_ary),
|
||||||
implode(',', $m_approve_fid_ary),
|
$post_visibility,
|
||||||
implode(',', $author_ary)
|
implode(',', $author_ary)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
@ -323,19 +323,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
break;
|
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 = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id';
|
$sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id';
|
||||||
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';
|
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';
|
||||||
$field = ($type == 'posts') ? 'post_id' : 'topic_id';
|
$field = ($type == 'posts') ? 'post_id' : 'topic_id';
|
||||||
|
@ -359,7 +346,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
$sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
|
$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 .= ($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 .= (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 .= $sql_author;
|
||||||
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||||
$sql_where_options .= $sql_match_where;
|
$sql_where_options .= $sql_match_where;
|
||||||
|
@ -418,7 +405,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
* @param string $sort_dir is either a or d representing ASC and DESC
|
* @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 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 $ex_fid_ary specifies an array of forum ids which should not be searched
|
||||||
* @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
|
* @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 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 array $author_ary an array of author ids
|
||||||
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
||||||
|
@ -427,7 +414,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
* @param int $per_page number of ids each page is supposed to contain
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @return boolean|int total number of results
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $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 author_search($type, $firstpost_only, $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 author? No posts.
|
// No author? No posts.
|
||||||
if (!sizeof($author_ary))
|
if (!sizeof($author_ary))
|
||||||
|
@ -446,7 +433,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
$sort_key,
|
$sort_key,
|
||||||
$topic_id,
|
$topic_id,
|
||||||
implode(',', $ex_fid_ary),
|
implode(',', $ex_fid_ary),
|
||||||
implode(',', $m_approve_fid_ary),
|
$post_visibility,
|
||||||
implode(',', $author_ary),
|
implode(',', $author_ary),
|
||||||
$author_name,
|
$author_name,
|
||||||
)));
|
)));
|
||||||
|
@ -496,18 +483,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sizeof($m_approve_fid_ary))
|
$m_approve_fid_sql = ' AND ' . $post_visibility;
|
||||||
{
|
|
||||||
$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) . ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the query for really selecting the post_ids
|
// Build the query for really selecting the post_ids
|
||||||
if ($type == 'posts')
|
if ($type == 'posts')
|
||||||
|
|
|
@ -340,7 +340,7 @@ class phpbb_search_fulltext_sphinx
|
||||||
* @param string $sort_dir is either a or d representing ASC and DESC
|
* @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 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 $ex_fid_ary specifies an array of forum ids which should not be searched
|
||||||
* @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
|
* @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 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 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
|
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
||||||
|
@ -349,7 +349,7 @@ class phpbb_search_fulltext_sphinx
|
||||||
* @param int $per_page number of ids each page is supposed to contain
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @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.
|
// No keywords? No posts.
|
||||||
if (!strlen($this->search_query) && !sizeof($author_ary))
|
if (!strlen($this->search_query) && !sizeof($author_ary))
|
||||||
|
@ -466,6 +466,8 @@ class phpbb_search_fulltext_sphinx
|
||||||
|
|
||||||
if (sizeof($ex_fid_ary))
|
if (sizeof($ex_fid_ary))
|
||||||
{
|
{
|
||||||
|
//@todo: Limit using $post_visibility
|
||||||
|
|
||||||
// All forums that a user is allowed to access
|
// All forums that a user is allowed to access
|
||||||
$fid_ary = array_unique(array_intersect(array_keys($this->auth->acl_getf('f_read', true)), array_keys($this->auth->acl_getf('f_search', true))));
|
$fid_ary = array_unique(array_intersect(array_keys($this->auth->acl_getf('f_read', true)), array_keys($this->auth->acl_getf('f_search', true))));
|
||||||
// All forums that the user wants to and can search in
|
// All forums that the user wants to and can search in
|
||||||
|
@ -541,7 +543,7 @@ class phpbb_search_fulltext_sphinx
|
||||||
* @param string $sort_dir is either a or d representing ASC and DESC
|
* @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 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 $ex_fid_ary specifies an array of forum ids which should not be searched
|
||||||
* @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
|
* @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 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 array $author_ary an array of author ids
|
||||||
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
* @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
|
||||||
|
@ -550,14 +552,14 @@ class phpbb_search_fulltext_sphinx
|
||||||
* @param int $per_page number of ids each page is supposed to contain
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @return boolean|int total number of results
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $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 author_search($type, $firstpost_only, $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)
|
||||||
{
|
{
|
||||||
$this->search_query = '';
|
$this->search_query = '';
|
||||||
|
|
||||||
$this->sphinx->SetMatchMode(SPH_MATCH_FULLSCAN);
|
$this->sphinx->SetMatchMode(SPH_MATCH_FULLSCAN);
|
||||||
$fields = ($firstpost_only) ? 'firstpost' : 'all';
|
$fields = ($firstpost_only) ? 'firstpost' : 'all';
|
||||||
$terms = 'all';
|
$terms = 'all';
|
||||||
return $this->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);
|
return $this->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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -266,8 +266,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
$m_approve_posts_fid_sql = ' AND ' . phpbb_content_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.');
|
$m_approve_posts_fid_sql = phpbb_content_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.');
|
||||||
$m_approve_topics_fid_sql = ' AND ' . phpbb_content_visibility::get_visibility_sql_global('topic', $ex_fid_ary, 't.');
|
$m_approve_topics_fid_sql = phpbb_content_visibility::get_visibility_sql_global('topic', $ex_fid_ary, 't.');
|
||||||
|
|
||||||
if ($reset_search_forum)
|
if ($reset_search_forum)
|
||||||
{
|
{
|
||||||
|
@ -335,7 +335,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
FROM ' . TOPICS_TABLE . " t
|
FROM ' . TOPICS_TABLE . " t
|
||||||
WHERE t.topic_moved_id = 0
|
WHERE t.topic_moved_id = 0
|
||||||
$last_post_time_sql
|
$last_post_time_sql
|
||||||
" . $m_approve_topics_fid_sql . '
|
AND " . $m_approve_topics_fid_sql . '
|
||||||
' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . '
|
' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . '
|
||||||
ORDER BY t.topic_last_post_time DESC';
|
ORDER BY t.topic_last_post_time DESC';
|
||||||
$field = 'topic_id';
|
$field = 'topic_id';
|
||||||
|
@ -373,7 +373,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
WHERE t.topic_replies = 0
|
WHERE t.topic_replies = 0
|
||||||
AND p.topic_id = t.topic_id
|
AND p.topic_id = t.topic_id
|
||||||
$last_post_time
|
$last_post_time
|
||||||
$m_approve_posts_fid_sql
|
AND $m_approve_posts_fid_sql
|
||||||
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
||||||
$sql_sort";
|
$sql_sort";
|
||||||
$field = 'post_id';
|
$field = 'post_id';
|
||||||
|
@ -386,7 +386,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
AND t.topic_moved_id = 0
|
AND t.topic_moved_id = 0
|
||||||
AND p.topic_id = t.topic_id
|
AND p.topic_id = t.topic_id
|
||||||
$last_post_time
|
$last_post_time
|
||||||
$m_approve_topics_fid_sql
|
AND $m_approve_topics_fid_sql
|
||||||
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
" . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
||||||
$sql_sort";
|
$sql_sort";
|
||||||
$field = 'topic_id';
|
$field = 'topic_id';
|
||||||
|
@ -402,7 +402,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
|
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
|
||||||
|
|
||||||
$sql_where = 'AND t.topic_moved_id = 0
|
$sql_where = 'AND t.topic_moved_id = 0
|
||||||
' . $m_approve_topics_fid_sql . '
|
AND ' . $m_approve_topics_fid_sql . '
|
||||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
||||||
|
|
||||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
||||||
|
@ -426,7 +426,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
$sql = 'SELECT p.post_id
|
$sql = 'SELECT p.post_id
|
||||||
FROM ' . POSTS_TABLE . ' p
|
FROM ' . POSTS_TABLE . ' p
|
||||||
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
|
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
|
||||||
' . $m_approve_posts_fid_sql . '
|
AND ' . $m_approve_posts_fid_sql . '
|
||||||
' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
|
||||||
$sql_sort";
|
$sql_sort";
|
||||||
$field = 'post_id';
|
$field = 'post_id';
|
||||||
|
@ -437,7 +437,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
FROM ' . TOPICS_TABLE . ' t
|
FROM ' . TOPICS_TABLE . ' t
|
||||||
WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
|
WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
|
||||||
AND t.topic_moved_id = 0
|
AND t.topic_moved_id = 0
|
||||||
' . $m_approve_topics_fid_sql . '
|
AND ' . $m_approve_topics_fid_sql . '
|
||||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
|
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
|
||||||
$sql_sort";
|
$sql_sort";
|
||||||
/*
|
/*
|
||||||
|
@ -449,7 +449,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
|
WHERE p.post_time > ' . $user->data['user_lastvisit'] . '
|
||||||
AND t.topic_id = p.topic_id
|
AND t.topic_id = p.topic_id
|
||||||
AND t.topic_moved_id = 0
|
AND t.topic_moved_id = 0
|
||||||
' . $m_approve_topics_fid_sql . "
|
AND ' . $m_approve_topics_fid_sql . "
|
||||||
GROUP BY t.topic_id
|
GROUP BY t.topic_id
|
||||||
$sql_sort";
|
$sql_sort";
|
||||||
*/
|
*/
|
||||||
|
@ -550,7 +550,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
{
|
{
|
||||||
$sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary);
|
$sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary);
|
||||||
$sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : '';
|
$sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : '';
|
||||||
$sql_where .= ($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql;
|
$sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($show_results == 'posts')
|
if ($show_results == 'posts')
|
||||||
|
|
Loading…
Add table
Reference in a new issue