Line 101 | Line 101 |
---|
if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($config['limit_search_load']))) { $template->assign_var('S_NO_SEARCH', true);
|
if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($config['limit_search_load']))) { $template->assign_var('S_NO_SEARCH', true);
|
trigger_error('NO_SEARCH_TIME');
| trigger_error('NO_SEARCH_LOAD');
|
}
// It is applicable if the configuration setting is non-zero, and the user cannot
| }
// It is applicable if the configuration setting is non-zero, and the user cannot
|
Line 125 | Line 125 |
---|
$phpbb_content_visibility = $phpbb_container->get('content.visibility'); $pagination = $phpbb_container->get('pagination');
|
$phpbb_content_visibility = $phpbb_container->get('content.visibility'); $pagination = $phpbb_container->get('pagination');
|
| /** * This event allows you to alter the above parameters, such as keywords and submit * * @event core.search_modify_submit_parameters * @var string keywords The search keywords * @var string author Specifies the author match, when ANONYMOUS is also a search-match * @var int author_id ID of the author to search by * @var string search_id Predefined search type name * @var bool submit Whether or not the form has been submitted * @since 3.1.10-RC1 */ $vars = array( 'keywords', 'author', 'author_id', 'search_id', 'submit', ); extract($phpbb_dispatcher->trigger_event('core.search_modify_submit_parameters', compact($vars)));
|
if ($keywords || $author || $author_id || $search_id || $submit) {
| if ($keywords || $author || $author_id || $search_id || $submit) {
|
Line 274 | Line 294 |
---|
} // We do some additional checks in the module to ensure it can actually be utilised $error = false;
|
} // We do some additional checks in the module to ensure it can actually be utilised $error = false;
|
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
| $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
|
if ($error) {
| if ($error) {
|
Line 310 | Line 330 |
---|
// define some variables needed for retrieving post_id/topic_id information $sort_by_sql = array('a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'));
|
// define some variables needed for retrieving post_id/topic_id information $sort_by_sql = array('a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'));
|
| /** * Event to modify the SQL parameters before pre-made searches * * @event core.search_modify_param_before * @var string keywords String of the specified keywords * @var array sort_by_sql Array of SQL sorting instructions * @var array ex_fid_ary Array of excluded forum ids * @var array author_id_ary Array of exclusive author ids * @var string search_id The id of the search request * @var array id_ary Array of post or topic ids for search result * @var string show_results 'posts' or 'topics' type of ids * @since 3.1.3-RC1 * @changed 3.1.10-RC1 Added id_ary, show_results */ $vars = array( 'keywords', 'sort_by_sql', 'ex_fid_ary', 'author_id_ary', 'search_id', 'id_ary', 'show_results', ); extract($phpbb_dispatcher->trigger_event('core.search_modify_param_before', compact($vars)));
|
// pre-made searches $sql = $field = $l_search_title = '';
| // pre-made searches $sql = $field = $l_search_title = '';
|
Line 407 | Line 452 |
---|
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); $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
|
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); $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
|
| $template->assign_var('U_MARK_ALL_READ', ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '');
|
break;
case 'newposts':
| break;
case 'newposts':
|
Line 462 | Line 509 |
---|
break; } }
|
break; } }
|
| /** * Event to modify data after pre-made searches * * @event core.search_modify_param_after * @var string l_search_title The title of the search page * @var string search_id Predefined search type name * @var string show_results Display topics or posts * @var string sql SQL query corresponding to the pre-made search id * @since 3.1.7-RC1 */ $vars = array( 'l_search_title', 'search_id', 'show_results', 'sql', ); extract($phpbb_dispatcher->trigger_event('core.search_modify_param_after', compact($vars)));
|
// show_results should not change after this $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
| // show_results should not change after this $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
|
Line 529 | Line 594 |
---|
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? 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_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); }
|
$firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? 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_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); }
|
| /** * Event to search otherwise than by keywords or author * * @event core.search_backend_search_after * @var string show_results 'posts' or 'topics' type of ids * @var string search_fields The data fields to search in * @var string search_terms Is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words) * @var array sort_by_sql Array of SQL sorting instructions * @var string sort_key The sort key * @var string sort_dir The sort direction * @var int sort_days Limit the age of results * @var array ex_fid_ary Array of excluded forum ids * @var string m_approve_posts_fid_sql Specifies which types of posts the user can view in which forums * @var 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 * @var array author_id_ary Array of exclusive author ids * @var string sql_author_match Specifies the author match, when ANONYMOUS is also a search-match * @var array id_ary Array of post or topic ids for search result * @var int start The starting id of the results * @var int per_page Number of ids each page is supposed to contain * @var int total_match_count The total number of search matches * @since 3.1.10-RC1 */ $vars = array( 'show_results', 'search_fields', 'search_terms', 'sort_by_sql', 'sort_key', 'sort_dir', 'sort_days', 'ex_fid_ary', 'm_approve_posts_fid_sql', 'topic_id', 'author_id_ary', 'sql_author_match', 'id_ary', 'start', 'per_page', 'total_match_count', ); extract($phpbb_dispatcher->trigger_event('core.search_backend_search_after', compact($vars)));
|
$sql_where = '';
| $sql_where = '';
|
Line 573 | Line 680 |
---|
$u_search .= (!$search_child) ? '&sc=0' : ''; $u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : ''; $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : '';
|
$u_search .= (!$search_child) ? '&sc=0' : ''; $u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : ''; $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : '';
|
| /** * Event to add or modify search URL parameters * * @event core.search_modify_url_parameters * @var string u_search Search URL parameters string * @var string search_id Predefined search type name * @var string show_results String indicating the show results mode * @var string sql_where The SQL WHERE string used by search to get topic data * @var int total_match_count The total number of search matches * @var array ex_fid_ary Array of excluded forum ids * @since 3.1.7-RC1 * @changed 3.1.10-RC1 Added show_results, sql_where, total_match_count * @changed 3.1.11-RC1 Added ex_fid_ary */ $vars = array( 'u_search', 'search_id', 'show_results', 'sql_where', 'total_match_count', 'ex_fid_ary', ); extract($phpbb_dispatcher->trigger_event('core.search_modify_url_parameters', compact($vars)));
|
if ($sql_where) {
| if ($sql_where) {
|
Line 683 | Line 814 |
---|
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); }
|
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); }
|
| $sql_order_by = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
/** * Event to modify the SQL query before the topic data is retrieved
| /** * Event to modify the SQL query before the topic data is retrieved
|
Line 692 | Line 825 |
---|
* @var string sql_from The SQL FROM string used by search to get topic data * @var string sql_where The SQL WHERE string used by search to get topic data * @var int total_match_count The total number of search matches
|
* @var string sql_from The SQL FROM string used by search to get topic data * @var string sql_where The SQL WHERE string used by search to get topic data * @var int total_match_count The total number of search matches
|
| * @var array sort_by_sql Array of SQL sorting instructions * @var string sort_dir The sorting direction * @var string sort_key The sorting key * @var string sql_order_by The SQL ORDER BY string used by search to get topic data
|
* @since 3.1.0-a1 * @changed 3.1.0-RC5 Added total_match_count
|
* @since 3.1.0-a1 * @changed 3.1.0-RC5 Added total_match_count
|
| * @changed 3.1.7-RC1 Added sort_by_sql, sort_dir, sort_key, sql_order_by
|
*/
|
*/
|
$vars = array('sql_select', 'sql_from', 'sql_where', 'total_match_count');
| $vars = array( 'sql_select', 'sql_from', 'sql_where', 'total_match_count', 'sort_by_sql', 'sort_dir', 'sort_key', 'sql_order_by', );
|
extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars)));
$sql = "SELECT $sql_select FROM $sql_from
|
extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars)));
$sql = "SELECT $sql_select FROM $sql_from
|
WHERE $sql_where"; $sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
| WHERE $sql_where ORDER BY $sql_order_by";
|
} $result = $db->sql_query($sql); $result_topic_id = 0;
| } $result = $db->sql_query($sql); $result_topic_id = 0;
|
Line 777 | Line 924 |
---|
} else {
|
} else {
|
$bbcode_bitfield = $text_only_message = '';
| $text_only_message = '';
|
$attach_list = array();
while ($row = $db->sql_fetchrow($result))
| $attach_list = array();
while ($row = $db->sql_fetchrow($result))
|
Line 797 | Line 944 |
---|
if ($return_chars == -1 || utf8_strlen($text_only_message) < ($return_chars + 3)) { $row['display_text_only'] = false;
|
if ($return_chars == -1 || utf8_strlen($text_only_message) < ($return_chars + 3)) { $row['display_text_only'] = false;
|
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
| |
// Does this post have an attachment? If so, add it to the list if ($row['post_attachment'] && $config['allow_attachments'])
| // Does this post have an attachment? If so, add it to the list if ($row['post_attachment'] && $config['allow_attachments'])
|
Line 816 | Line 962 |
---|
$db->sql_freeresult($result);
unset($text_only_message);
|
$db->sql_freeresult($result);
unset($text_only_message);
|
// Instantiate BBCode if needed if ($bbcode_bitfield !== '') { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); $bbcode = new bbcode(base64_encode($bbcode_bitfield)); }
| |
// Pull attachment data if (sizeof($attach_list))
| // Pull attachment data if (sizeof($attach_list))
|
Line 922 | Line 1061 |
---|
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : '';
|
$posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : '';
|
$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&mode=deleted_topics&t=$result_topic_id", true, $user->session_id) : '';
| $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&mode=deleted_topics&t=$result_topic_id", true, $user->session_id) : $u_mcp_queue;
|
|
|
$row['topic_title'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['topic_title']);
| $row['topic_title'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $row['topic_title']);
|
$tpl_ary = array( 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
| $tpl_ary = array( 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
Line 1007 | Line 1146 |
---|
if ($hilit) { // post highlighting
|
if ($hilit) { // post highlighting
|
$row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_text']); $row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_subject']);
| $row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $row['post_text']); $row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $row['post_subject']);
|
}
$tpl_ary = array(
| }
$tpl_ary = array(
|
Line 1155 | Line 1294 |
---|
* Modify the title and/or load data for the search results page * * @event core.search_results_modify_search_title
|
* Modify the title and/or load data for the search results page * * @event core.search_results_modify_search_title
|
* @var int author_id ID of the author to search by * @var string l_search_title The title of the search page * @var string search_id Predefined search type name * @var string show_results Search results output mode - topics or posts * @var int start The starting id of the results
| * @var int author_id ID of the author to search by * @var string l_search_title The title of the search page * @var string search_id Predefined search type name * @var string show_results Search results output mode - topics or posts * @var int start The starting id of the results * @var int total_match_count The count of search results * @var string keywords The search keywords
|
* @since 3.1.0-RC4
|
* @since 3.1.0-RC4
|
| * @changed 3.1.6-RC1 Added total_match_count and keywords
|
*/
|
*/
|
$vars = array('author_id', 'l_search_title', 'search_id', 'show_results', 'start');
| $vars = array( 'author_id', 'l_search_title', 'search_id', 'show_results', 'start', 'total_match_count', 'keywords', );
|
extract($phpbb_dispatcher->trigger_event('core.search_results_modify_search_title', compact($vars)));
page_header(($l_search_title) ? $l_search_title : $user->lang['SEARCH']);
| extract($phpbb_dispatcher->trigger_event('core.search_results_modify_search_title', compact($vars)));
page_header(($l_search_title) ? $l_search_title : $user->lang['SEARCH']);
|
Line 1176 | Line 1326 |
---|
}
// Search forum
|
}
// Search forum
|
| $rowset = array();
|
$s_forums = ''; $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id FROM ' . FORUMS_TABLE . ' f
| $s_forums = ''; $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.left_id, f.right_id, f.forum_password, f.enable_indexing, fa.user_id FROM ' . FORUMS_TABLE . ' f
|
Line 1183 | Line 1334 |
---|
AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') ORDER BY f.left_id ASC"; $result = $db->sql_query($sql);
|
AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') ORDER BY f.left_id ASC"; $result = $db->sql_query($sql);
|
| while ($row = $db->sql_fetchrow($result)) { $rowset[(int) $row['forum_id']] = $row; } $db->sql_freeresult($result);
|
$right = $cat_right = $padding_inc = 0; $padding = $forum_list = $holding = ''; $pad_store = array('0' => '');
|
$right = $cat_right = $padding_inc = 0; $padding = $forum_list = $holding = ''; $pad_store = array('0' => '');
|
while ($row = $db->sql_fetchrow($result))
| /** * Modify the forum select list for advanced search page * * @event core.search_modify_forum_select_list * @var array rowset Array with the forums list data * @since 3.1.10-RC1 */ $vars = array('rowset'); extract($phpbb_dispatcher->trigger_event('core.search_modify_forum_select_list', compact($vars)));
foreach ($rowset as $row)
|
{ if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) {
| { if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) {
|
Line 1260 | Line 1427 |
---|
$s_forums .= $holding; }
|
$s_forums .= $holding; }
|
$db->sql_freeresult($result);
| |
unset($pad_store);
|
unset($pad_store);
|
| unset($rowset);
|
if (!$s_forums) {
| if (!$s_forums) {
|