- fixed the age calculation (note: turn on your brain before commiting something like this the next time) [Bug #3337]

- removed the split_words array, introduced an enforced search_query
- the forum used for global topics in the search is now a forum, and no longer a category [Bug #2561]
- Bug #3404
- allow accessing reports by report_id, in contrast to mcp_queue this cannot just use the post id, since there can be multiple closed reports per post, so closed reports have to be accessed by report id, open reports, can optionally be accessed by report id or post id [Bug #3149]
- only attempt to unflag reported topics on closing a report when there are any without other reported posts [Bug #3057]
- updated fulltext_mysql to use the the search_query string
- overwrote the old fulltext_native with our improved version since it consumes too much time to maintain boths and we would switch to the improved version later anyway
- always show a link to search a user's posts even if the postcount is zero since he  might only have posted in forums which do not count posts [Bug #3267]


git-svn-id: file:///svn/phpbb/trunk@6211 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Nils Adermann 2006-07-27 19:02:47 +00:00
parent 412cf50689
commit 007f4f6987
12 changed files with 1028 additions and 2111 deletions

View file

@ -61,20 +61,14 @@ class mcp_reports
$post_id = request_var('p', 0);
$post_info = get_post_data(array($post_id), 'm_approve');
// closed reports are accessed by report id
$report_id = request_var('r', 0);
if (!sizeof($post_info))
{
trigger_error('NO_POST_SELECTED');
}
$post_info = $post_info[$post_id];
$sql = 'SELECT r.user_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username
FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . " u
WHERE r.post_id = $post_id
$sql = 'SELECT r.post_id, r.user_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username
FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u
WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id AND r.report_closed = 0") . '
AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id";
AND r.user_id = u.user_id';
$result = $db->sql_query($sql);
$report = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@ -84,6 +78,20 @@ class mcp_reports
trigger_error('NO_POST_REPORT');
}
if ($report_id)
{
$post_id = $report['post_id'];
}
$post_info = get_post_data(array($post_id), 'm_approve');
if (!sizeof($post_info))
{
trigger_error('NO_POST_SELECTED');
}
$post_info = $post_info[$post_id];
$reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]))
{
@ -247,7 +255,7 @@ class mcp_reports
$report_state = 'AND r.report_closed = 1';
}
$sql = 'SELECT p.post_id
$sql = 'SELECT r.report_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . "
WHERE p.forum_id IN ($forum_list)
$report_state
@ -261,36 +269,28 @@ class mcp_reports
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
$i = 0;
$post_ids = array();
$report_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$post_ids[] = $row['post_id'];
$row_num[$row['post_id']] = $i++;
$report_ids[] = $row['report_id'];
$row_num[$row['report_id']] = $i++;
}
$db->sql_freeresult($result);
if (sizeof($post_ids))
if (sizeof($report_ids))
{
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, r.user_id as reporter_id, ru.username as reporter_name, r.report_time
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . USERS_TABLE . " ru
WHERE p.post_id IN (" . implode(', ', $post_ids) . ")
$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, r.user_id as reporter_id, ru.username as reporter_name, r.report_time, r.report_id
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . " ru
WHERE r.report_id IN (" . implode(', ', $report_ids) . ")
AND t.topic_id = p.topic_id
AND r.post_id = p.post_id
AND u.user_id = p.poster_id
AND ru.user_id = r.user_id";
$result = $db->sql_query($sql);
$post_data = $rowset = array();
$report_data = $rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$post_data[$row['post_id']] = $row;
}
$db->sql_freeresult($result);
foreach ($post_ids as $post_id)
{
$row = $post_data[$post_id];
if ($row['poster_id'] == ANONYMOUS)
{
$poster = (!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST'];
@ -309,7 +309,7 @@ class mcp_reports
$template->assign_block_vars('postrow', array(
'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'],
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&p={$row['post_id']}"),
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"),
'U_VIEW_POSTER_PROFILE' => ($row['poster_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['poster_id']) : '',
'U_VIEW_REPORTER_PROFILE' => ($row['reporter_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['reporter_id']) : '',
@ -323,7 +323,8 @@ class mcp_reports
'TOPIC_TITLE' => $row['topic_title'])
);
}
unset($post_data, $post_ids, $row);
$db->sql_freeresult($result);
unset($report_ids, $row);
}
// Now display the page
@ -455,10 +456,13 @@ function close_report($post_id_list, $mode, $action)
WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE topic_id IN (' . implode(', ', $close_report_topics) . ')';
$db->sql_query($sql);
if (sizeof($close_report_topics))
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE topic_id IN (' . implode(', ', $close_report_topics) . ')';
$db->sql_query($sql);
}
$db->sql_transaction('commit');
}

View file

@ -27,8 +27,10 @@ include_once($phpbb_root_path . 'includes/search/search.' . $phpEx);
*/
class fulltext_mysql extends search_backend
{
var $stats;
var $word_length;
var $stats = array();
var $word_length = array();
var $split_words = array();
var $common_words = array();
function fulltext_mysql(&$error)
{
@ -98,6 +100,7 @@ class fulltext_mysql extends search_backend
/**
* Splits keywords entered by a user into an array of words stored in $this->split_words
* Stores the tidied search query in $this->search_query
*
* @param string $keywords Contains the keyword as entered by the user
* @param string $terms is either 'all' or 'any'
@ -157,6 +160,8 @@ class fulltext_mysql extends search_backend
}
}
$this->search_query = implode(' ', $this->split_words);
if (sizeof($this->split_words))
{
$this->split_words = array_values($this->split_words);
@ -637,7 +642,7 @@ class fulltext_mysql extends search_backend
return $error;
}
if (!is_array($this->stats))
if (empty($this->stats))
{
$this->get_stats();
}
@ -670,7 +675,7 @@ class fulltext_mysql extends search_backend
return $error;
}
if (!is_array($this->stats))
if (empty($this->stats))
{
$this->get_stats();
}
@ -695,7 +700,7 @@ class fulltext_mysql extends search_backend
*/
function index_created()
{
if (!is_array($this->stats))
if (empty($this->stats))
{
$this->get_stats();
}
@ -710,7 +715,7 @@ class fulltext_mysql extends search_backend
{
global $user;
if (!is_array($this->stats))
if (empty($this->stats))
{
$this->get_stats();
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -33,8 +33,6 @@ class search_backend
var $ignore_words = array();
var $match_synonym = array();
var $replace_synonym = array();
var $split_words = array();
var $common_words = array();
function search_backend(&$error)
{

View file

@ -185,7 +185,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_store_resul
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_deny', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_empty_referer', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_downloads', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('send_encoding', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('send_encoding', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_name', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_port', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_protocol', '');

View file

@ -105,7 +105,7 @@ $lang = array_merge($lang, array(
'REAL_NAME' => 'Recipient name',
'RECIPIENT' => 'Recipient',
'SEARCH_USER_POSTS' => 'Search users posts',
'SEARCH_USER_POSTS' => 'Search user\'s posts',
'SELECT_MARKED' => 'Select marked',
'SELECT_SORT_METHOD' => 'Select sort method',
'SEND_IM' => 'Instant messaging',

View file

@ -68,7 +68,7 @@ $lang = array_merge($lang, array(
'SEARCH_FORUMS' => 'Search in forums',
'SEARCH_FORUMS_EXPLAIN' => 'Select the forum or forums you wish to search in. For speed all subforums can be searched by selecting the parent and setting enable search subforums below.',
'SEARCH_IN_RESULTS' => 'Search these results',
'SEARCH_KEYWORDS_EXPLAIN' => 'Place <strong>+</strong> in front of a word which must be found and <strong>-</strong> in front of a word which must not be found. If you place <strong>|</strong> in front of words, each result has to contain at least one of these words. Use * as a wildcard for partial matches',
'SEARCH_KEYWORDS_EXPLAIN' => 'Place <strong>+</strong> in front of a word which must be found and <strong>-</strong> in front of a word which must not be found. Put a list of words seperated by <strong>|</strong> into brackets if only one of the words must be found. Use * as a wildcard for partial matches.',
'SEARCH_MSG_ONLY' => 'Message text only',
'SEARCH_OPTIONS' => 'Search Options',
'SEARCH_QUERY' => 'Search Query',

View file

@ -1317,7 +1317,7 @@ function show_profile($data)
{
$time = time() + $user->timezone + $user->dst;
$age = (int) (date('Y', $time) - $bday_year - ((((date('n', $time) - $bday_month) < 0) || ((date('j', $time) - $bday_day) < 0)) ? 1 : 0));
$age = (int) (date('Y', $time) - $bday_year - ((date('n', $time) - $bday_month < 0) ? 1 : ((date('j', $time) - $bday_day < 0) ? 1 : 0)));
}
}

View file

@ -141,7 +141,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
else if ($auth->acl_getf_global('m_approve'))
{
$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
$m_approve_fid_sql = ' AND (p.post_approved = 1' . (($m_approve_fid_ary) ? ' OR p.forum_id NOT IN (' . implode(', ', $m_approve_fid_ary) . ')' : '') . ')';
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR p.forum_id NOT IN (' . implode(', ', $m_approve_fid_ary) . ')' : '') . ')';
}
else
{
@ -230,7 +230,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
if ($keywords)
{
$search->split_keywords($keywords, $search_terms);
if (!sizeof($search->split_words) && !sizeof($author_id_ary) && !$search_id)
if (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id)
{
$ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], htmlspecialchars(implode(' ', $search->common_words))) . '<br />' : '';
trigger_error($ignored . sprintf($user->lang['NO_KEYWORDS'], $search->word_length['min'], $search->word_length['max']));
@ -390,7 +390,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
sort($m_approve_fid_ary);
sort($author_id_ary);
if (sizeof($search->split_words))
if (!empty($search->search_query))
{
$total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $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);
}
@ -434,9 +434,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
// define some vars for urls
$hilit = htmlspecialchars(implode('|', str_replace(array('+', '-', '|'), '', $search->split_words)));
$split_words = (sizeof($search->split_words)) ? htmlspecialchars(implode(' ', $search->split_words)) : '';
$u_hilit = urlencode($split_words);
$hilit = preg_replace('#&amp;(\#[0-9]+;)#', '&$1', htmlspecialchars(implode('|', explode(' ', preg_replace('#\s+#', ' ', str_replace(array('+', '-', '|', '(', ')'), ' ', $keywords))))));
$u_hilit = urlencode($keywords);
$u_show_results = ($show_results != 'posts') ? '&amp;sr=' . $show_results : '';
$u_search_forum = implode('&amp;fid%5B%5D=', $search_forum);
@ -453,7 +452,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$template->assign_vars(array(
'SEARCH_MATCHES' => $l_search_matches,
'SEARCH_WORDS' => $split_words,
'SEARCH_WORDS' => preg_replace('#&amp;(\#[0-9]+;)#', '&$1', htmlspecialchars($search->search_query)),
'IGNORED_WORDS' => (sizeof($search->common_words)) ? htmlspecialchars(implode(' ', $search->common_words)) : '',
'PAGINATION' => generate_pagination($u_search, $total_match_count, $per_page, $start),
'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
@ -585,18 +584,43 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$db->sql_freeresult($result);
}
if ($hilit)
{
// Remove bad highlights
$hilit_array = array_filter(explode('|', $hilit), 'strlen');
foreach ($hilit_array as $key => $value)
{
$hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($value, '#'));
}
$hilit = implode('|', $hilit_array);
}
foreach ($rowset as $row)
{
$forum_id = $row['forum_id'];
$result_topic_id = $row['topic_id'];
$topic_title = censor_text($row['topic_title']);
// we need to select a forum id for this global topic
if (!$forum_id)
{
if (!isset($g_forum_id))
{
$availible_forums = array_values(array_diff(array_keys($auth->acl_getf('f_read', true)), $ex_fid_ary));
$g_forum_id = $availible_forums[0];
// Get a list of forums the user cannot read
$forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true)));
// Determine first forum the user is able to read (must not be a category)
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST;
if (sizeof($forum_ary))
{
$sql .= ' AND forum_id NOT IN ( ' . implode(', ', $forum_ary) . ')';
}
$result = $db->sql_query_limit($sql, 1);
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
}
$u_forum_id = $g_forum_id;
}
@ -678,18 +702,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$row['post_subject'] = censor_text($row['post_subject']);
$row['post_text'] = str_replace("\n", '<br />', censor_text($row['post_text']));
if ($hilit)
{
// Remove bad highlights
$hilit_array = array_filter(explode('|', $hilit), 'strlen');
foreach ($hilit_array as $key => $value)
{
$hilit_array[$key] = preg_quote($value, '#');
}
$hilit = implode('|', $hilit_array);
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">$1</span>', $row['post_text']);
}
// post highlighting
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*>)#i', '<span class="posthilit">$1</span>', $row['post_text']);
$row['post_text'] = smiley_text($row['post_text']);

View file

@ -69,7 +69,7 @@
<!-- ENDIF -->
<tr>
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_TOTAL_POSTS}: </td>
<td><!-- IF POSTS_PCT neq 0 --><b class="gen">{POSTS}</b><br /><span class="genmed">[{POSTS_PCT} / {POSTS_DAY}]<br /><a href="{U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a></span><!-- ELSE --><b class="gen">{POSTS}</b><!-- ENDIF --></td>
<td><b class="gen">{POSTS}</b><!-- IF POSTS_PCT neq 0 --><br /><span class="genmed">[{POSTS_PCT} / {POSTS_DAY}]<!-- ENDIF --><br /><a href="{U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a></span></td>
</tr>
<!-- IF S_SHOW_ACTIVITY -->
<tr>

View file

@ -1072,7 +1072,7 @@ while ($row = $db->sql_fetchrow($result))
if ($bday_year)
{
$user_cache[$poster_id]['age'] = (int) ($today['year'] - $bday_year - ((($today['month'] - $bday_month) < 0) || (($today['day'] - $bday_day) < 0)) ? 1 : 0);
$user_cache[$poster_id]['age'] = (int) ($today['year'] - $bday_year - (($today['month'] - $bday_month < 0) ? 1 : (($today['day'] - $bday_day < 0) ? 1 : 0)));
}
}
}