aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorHenry Sudhof <kellanved@phpbb.com>2007-07-23 17:03:37 +0000
committerHenry Sudhof <kellanved@phpbb.com>2007-07-23 17:03:37 +0000
commite8ae63daf6c693fb02883e33b8f561168507d449 (patch)
treececeb147a4c90e4ae9956cc3efa9ee41d71a5d13 /phpBB
parentd4fb1870be8f2aee08b7788b6293bb5691f6c345 (diff)
downloadforums-e8ae63daf6c693fb02883e33b8f561168507d449.tar
forums-e8ae63daf6c693fb02883e33b8f561168507d449.tar.gz
forums-e8ae63daf6c693fb02883e33b8f561168507d449.tar.bz2
forums-e8ae63daf6c693fb02883e33b8f561168507d449.tar.xz
forums-e8ae63daf6c693fb02883e33b8f561168507d449.zip
#13579
This changes the signature of author_search. Search backends will need adjustment. git-svn-id: file:///svn/phpbb/trunk@7930 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/docs/CHANGELOG.html2
-rw-r--r--phpBB/includes/search/fulltext_mysql.php8
-rwxr-xr-xphpBB/includes/search/fulltext_native.php12
-rw-r--r--phpBB/search.php3
4 files changed, 18 insertions, 7 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index de9f00a2bd..795d986473 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -269,7 +269,7 @@ p a {
<li>[Fix] Finer error conditions for sending IM messages (Bugs #13681, #13683)</li>
<li>[Fix] Add a confirmation for log deletion in the MCP (Bug #13693)</li>
<li>[Fix] Do not erase ranks and avatars when changing default groups (Bugs #13701, #13697)</li>
- <li>[Fix] Propagate forum_id in the MCP (Bug #13731)</li>
+ <li>[Fix] Limit author searches to firstpost, if selected (Bug #13579)</li>
</ul>
</div>
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 951ef5b69f..38022a21c4 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -494,7 +494,7 @@ class fulltext_mysql extends search_backend
* @param int $per_page number of ids each page is supposed to contain
* @return total number of results
*/
- function author_search($type, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
+ 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, &$id_ary, $start, $per_page)
{
global $config, $db;
@@ -508,6 +508,7 @@ class fulltext_mysql extends search_backend
$search_key = md5(implode('#', array(
'',
$type,
+ ($firstpost_only) ? 'firstpost' : '',
'',
'',
$sort_days,
@@ -532,6 +533,7 @@ class fulltext_mysql extends search_backend
$sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
+ $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
// Build sql strings for sorting
$sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
@@ -574,9 +576,10 @@ class fulltext_mysql extends search_backend
if ($type == 'posts')
{
$sql = "SELECT {$calc_results}p.post_id
- FROM " . $sql_sort_table . POSTS_TABLE . " p
+ FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . "
WHERE $sql_author
$sql_topic_id
+ $sql_firstpost
$m_approve_fid_sql
$sql_fora
$sql_sort_join
@@ -590,6 +593,7 @@ class fulltext_mysql extends search_backend
FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
WHERE $sql_author
$sql_topic_id
+ $sql_firstpost
$m_approve_fid_sql
$sql_fora
AND t.topic_id = p.topic_id
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index 1f375c8f51..9cad77dd7f 100755
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -759,7 +759,7 @@ class fulltext_native extends search_backend
*
* @access public
*/
- function author_search($type, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
+ 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, &$id_ary, $start, $per_page)
{
global $config, $db;
@@ -773,6 +773,7 @@ class fulltext_native extends search_backend
$search_key = md5(implode('#', array(
'',
$type,
+ ($firstpost_only) ? 'firstpost' : '',
'',
'',
$sort_days,
@@ -797,6 +798,7 @@ class fulltext_native extends search_backend
$sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
+ $sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
// Build sql strings for sorting
$sql_sort = $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
@@ -850,9 +852,10 @@ class fulltext_native extends search_backend
if ($type == 'posts')
{
$sql = 'SELECT COUNT(p.post_id) as total_results
- FROM ' . POSTS_TABLE . " p
+ FROM ' . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t ' : ' ') . "
WHERE $sql_author
$sql_topic_id
+ $sql_firstpost
$m_approve_fid_sql
$sql_fora
$sql_time";
@@ -872,6 +875,7 @@ class fulltext_native extends search_backend
$sql .= ' FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
WHERE $sql_author
$sql_topic_id
+ $sql_firstpost
$m_approve_fid_sql
$sql_fora
AND t.topic_id = p.topic_id
@@ -894,9 +898,10 @@ class fulltext_native extends search_backend
if ($type == 'posts')
{
$sql = "SELECT $select
- FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($topic_id) ? ', ' . TOPICS_TABLE . ' t' : '') . "
+ FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($topic_id || $firstpost_only) ? ', ' . TOPICS_TABLE . ' t' : '') . "
WHERE $sql_author
$sql_topic_id
+ $sql_firstpost
$m_approve_fid_sql
$sql_fora
$sql_sort_join
@@ -910,6 +915,7 @@ class fulltext_native extends search_backend
FROM " . $sql_sort_table . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
WHERE $sql_author
$sql_topic_id
+ $sql_firstpost
$m_approve_fid_sql
$sql_fora
AND t.topic_id = p.topic_id
diff --git a/phpBB/search.php b/phpBB/search.php
index 16840a4c6d..d40dcebb1c 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -419,7 +419,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
else if (sizeof($author_id_ary))
{
- $total_match_count = $search->author_search($show_results, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
+ $firstpost_only = ($search_fields === 'firstpost') ? true : false;
+ $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $id_ary, $start, $per_page);
}
// For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options.