mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-04 06:39:14 +02:00
Merge branch 'develop-ascraeus' of https://github.com/phpbb/phpbb into ticket/12407
Conflicts: phpBB/posting.php
This commit is contained in:
commit
01030bb3a9
@ -20,6 +20,7 @@ if (!defined('IN_PHPBB'))
|
||||
* make_jumpbox()
|
||||
* bump_topic_allowed()
|
||||
* get_context()
|
||||
* phpbb_clean_search_string()
|
||||
* decode_message()
|
||||
* strip_bbcode()
|
||||
* generate_text_for_display()
|
||||
@ -359,6 +360,23 @@ function get_context($text, $words, $length = 400)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans a search string by removing single wildcards from it and replacing multiple spaces with a single one.
|
||||
*
|
||||
* @param string $search_string The full search string which should be cleaned.
|
||||
*
|
||||
* @return string The cleaned search string without any wildcards and multiple spaces.
|
||||
*/
|
||||
function phpbb_clean_search_string($search_string)
|
||||
{
|
||||
// This regular expressions matches every single wildcard.
|
||||
// That means one after a whitespace or the beginning of the string or one before a whitespace or the end of the string.
|
||||
$search_string = preg_replace('#(?<=^|\s)\*+(?=\s|$)#', '', $search_string);
|
||||
$search_string = trim($search_string);
|
||||
$search_string = preg_replace(array('#\s+#u', '#\*+#u'), array(' ', '*'), $search_string);
|
||||
return $search_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode text whereby text is coming from the db and expected to be pre-parsed content
|
||||
* We are placing this outside of the message parser because we are often in need of it...
|
||||
|
@ -1575,7 +1575,7 @@ function get_folder_status($folder_id, $folder)
|
||||
*/
|
||||
function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
{
|
||||
global $db, $auth, $config, $phpEx, $template, $user, $phpbb_root_path, $phpbb_container;
|
||||
global $db, $auth, $config, $phpEx, $template, $user, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher;
|
||||
|
||||
// We do not handle erasing pms here
|
||||
if ($mode == 'delete')
|
||||
@ -1585,6 +1585,18 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
|
||||
$current_time = time();
|
||||
|
||||
/**
|
||||
* Get all parts of the PM that are to be submited to the DB.
|
||||
*
|
||||
* @event core.submit_pm_before
|
||||
* @var string mode PM Post mode - post|reply|quote|quotepost|forward|edit
|
||||
* @var string subject Subject of the private message
|
||||
* @var array data The whole row data of the PM.
|
||||
* @since 3.1.0-b3
|
||||
*/
|
||||
$vars = array('mode', 'subject', 'data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.submit_pm_before', compact($vars)));
|
||||
|
||||
// Collect some basic information about which tables and which rows to update/insert
|
||||
$sql_data = array();
|
||||
$root_level = 0;
|
||||
|
@ -1662,6 +1662,18 @@ class install_install extends module
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$_module->move_module_by($row, 'move_down', 4);
|
||||
|
||||
// Move notification options module 4 down...
|
||||
$sql = 'SELECT *
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_basename = 'ucp_notifications'
|
||||
AND module_class = 'ucp'
|
||||
AND module_mode = 'notification_options'";
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$_module->move_module_by($row, 'move_down', 4);
|
||||
}
|
||||
|
||||
// And now for the special ones
|
||||
|
@ -892,7 +892,7 @@ class tools
|
||||
}
|
||||
}
|
||||
|
||||
// Add unqiue indexes?
|
||||
// Add unique indexes?
|
||||
if (!empty($schema_changes['add_unique_index']))
|
||||
{
|
||||
foreach ($schema_changes['add_unique_index'] as $table => $index_array)
|
||||
@ -1303,7 +1303,7 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
|
||||
* Check if a specified index exists in table. Does not return PRIMARY KEY indexes.
|
||||
*
|
||||
* @param string $table_name Table to check the index at
|
||||
* @param string $index_name The index name to check
|
||||
|
@ -558,6 +558,10 @@ class log implements \phpbb\log\log_interface
|
||||
$log[$i]['action'] = make_clickable($log[$i]['action']);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
$log[$i]['action'] = $this->user->lang($log[$i]['action']);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ $current_time = time();
|
||||
|
||||
/**
|
||||
* This event allows you to alter the above parameters, such as submit and mode
|
||||
*
|
||||
*
|
||||
* Note: $refresh must be true to retain previously submitted form data.
|
||||
*
|
||||
* Note: The template class will not work properly until $user->setup() is
|
||||
@ -74,7 +74,7 @@ $current_time = time();
|
||||
* viewtopic or viewforum depending on if the user
|
||||
* is posting a new topic or editing a post)
|
||||
* @var bool refresh Whether or not to retain previously submitted data
|
||||
* @var string mode What action to take if the form has been sumitted
|
||||
* @var string mode What action to take if the form has been submitted
|
||||
* post|reply|quote|edit|delete|bump|smilies|popup
|
||||
* @var array error Any error strings; a non-empty array aborts
|
||||
* form submission.
|
||||
@ -1548,6 +1548,16 @@ $page_data = array(
|
||||
* This event allows you to modify template variables for the posting screen
|
||||
*
|
||||
* @event core.posting_modify_template_vars
|
||||
* @var array post_data Array with post data
|
||||
* @var array moderators Array with forum moderators
|
||||
* @var string mode What action to take if the form is submitted
|
||||
* post|reply|quote|edit|delete|bump|smilies|popup
|
||||
* @var string page_title Title of the mode page
|
||||
* @var bool s_topic_icons Whether or not to show the topic icons
|
||||
* @var string form_enctype If attachments are allowed for this form
|
||||
* "multipart/form-data" or empty string
|
||||
* @var string s_action The URL to submit the POST data to
|
||||
* @var string s_hidden_fields Concatenated hidden input tags of posting form
|
||||
* @var int post_id ID of the post
|
||||
* @var int topic_id ID of the topic
|
||||
* @var int forum_id ID of the forum
|
||||
@ -1559,27 +1569,25 @@ $page_data = array(
|
||||
* @var bool cancel Whether or not to cancel the form (returns to
|
||||
* viewtopic or viewforum depending on if the user
|
||||
* is posting a new topic or editing a post)
|
||||
* @var bool refresh Whether or not to retain previously submitted data
|
||||
* @var string mode What action to take if the form has been sumitted
|
||||
* post|reply|quote|edit|delete|bump|smilies|popup
|
||||
* @var array error Any error strings; a non-empty array aborts
|
||||
* form submission.
|
||||
* NOTE: Should be actual language strings, NOT
|
||||
* language keys.
|
||||
* @var array s_hidden_fields Hidden fields of posting form
|
||||
* @var array post_data Post data of the post to create, edit, etc.
|
||||
* @var bool refresh Whether or not to retain previously submitted data
|
||||
* @var array page_data Posting page data that should be passed to the
|
||||
* posting page via $template->assign_vars()
|
||||
* @var object message_parser The message parser object
|
||||
* @since 3.1-A1
|
||||
* @changed 3.1.0-b3 Introduced variables passed to listener
|
||||
* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
|
||||
* s_topic_icons, form_enctype, s_action, s_hidden_fields
|
||||
* @change 3.1.0-b3 Added vars post_id, topic_id, forum_id, submit, preview,
|
||||
* save, load, delete, cancel, refresh, error, page_data,
|
||||
* message_parser
|
||||
*/
|
||||
$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data', 'message_parser');
|
||||
$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype', 's_action', 's_hidden_fields', 'post_id');
|
||||
$vars += array('topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser');
|
||||
extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars)));
|
||||
|
||||
// Start assigning vars for main posting page ...
|
||||
$template->assign_vars($page_data);
|
||||
|
||||
// Build custom bbcodes array
|
||||
display_custom_bbcodes();
|
||||
|
||||
|
@ -561,9 +561,9 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||
}
|
||||
|
||||
// define some vars for urls
|
||||
$hilit = implode('|', explode(' ', preg_replace('#\s+#u', ' ', str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords))));
|
||||
// Do not allow *only* wildcard being used for hilight
|
||||
$hilit = (strspn($hilit, '*') === strlen($hilit)) ? '' : $hilit;
|
||||
// A single wildcard will make the search results look ugly
|
||||
$hilit = phpbb_clean_search_string(str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords));
|
||||
$hilit = str_replace(' ', '|', $hilit);
|
||||
|
||||
$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));
|
||||
$u_show_results = '&sr=' . $show_results;
|
||||
@ -850,7 +850,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||
$hilit_array = array_filter(explode('|', $hilit), 'strlen');
|
||||
foreach ($hilit_array as $key => $value)
|
||||
{
|
||||
$hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($value, '#'));
|
||||
$hilit_array[$key] = phpbb_clean_search_string($value);
|
||||
$hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#'));
|
||||
$hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]);
|
||||
}
|
||||
$hilit = implode('|', $hilit_array);
|
||||
|
@ -653,6 +653,18 @@ $template->assign_vars(array(
|
||||
$topic_list = ($store_reverse) ? array_merge($announcement_list, array_reverse($topic_list)) : array_merge($announcement_list, $topic_list);
|
||||
$topic_tracking_info = $tracking_topics = array();
|
||||
|
||||
/**
|
||||
* Modify topics data before we display the viewforum page
|
||||
*
|
||||
* @event core.viewforum_modify_topics_data
|
||||
* @var array topic_list Array with current viewforum page topic ids
|
||||
* @var array rowset Array with topics data (in topic_id => topic_data format)
|
||||
* @var int total_topic_count Forum's total topic count
|
||||
* @since 3.1.0-b3
|
||||
*/
|
||||
$vars = array('topic_list', 'rowset', 'total_topic_count');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars)));
|
||||
|
||||
// Okay, lets dump out the page ...
|
||||
if (sizeof($topic_list))
|
||||
{
|
||||
|
@ -422,17 +422,11 @@ else
|
||||
$highlight_match = $highlight = '';
|
||||
if ($hilit_words)
|
||||
{
|
||||
foreach (explode(' ', trim($hilit_words)) as $word)
|
||||
{
|
||||
if (trim($word))
|
||||
{
|
||||
$word = str_replace('\*', '\w+?', preg_quote($word, '#'));
|
||||
$word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
|
||||
$highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
|
||||
}
|
||||
}
|
||||
|
||||
$highlight = urlencode($hilit_words);
|
||||
$highlight_match = phpbb_clean_search_string($hilit_words);
|
||||
$highlight = urlencode($highlight_match);
|
||||
$highlight_match = str_replace('\*', '\w+?', preg_quote($highlight_match, '#'));
|
||||
$highlight_match = preg_replace('#(?<=^|\s)\\\\w\*\?(?=\s|$)#', '\w+?', $highlight_match);
|
||||
$highlight_match = str_replace(' ', '|', $highlight_match);
|
||||
}
|
||||
|
||||
// Make sure $start is set to the last page if it exceeds the amount
|
||||
@ -1674,15 +1668,18 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
|
||||
* @var int start Start item of this page
|
||||
* @var int current_row_number Number of the post on this page
|
||||
* @var int end Number of posts on this page
|
||||
* @var int total_posts Total posts count
|
||||
* @var array row Array with original post and user data
|
||||
* @var array cp_row Custom profile field data of the poster
|
||||
* @var array attachments List of attachments
|
||||
* @var array user_poster_data Poster's data from user cache
|
||||
* @var array post_row Template block array of the post
|
||||
* @var array topic_data Array with topic data
|
||||
* @since 3.1-A1
|
||||
* @change 3.1.0-a3 Added vars start, current_row_number, end, attachments
|
||||
* @change 3.1.0-b3 Added topic_data array, total_posts
|
||||
*/
|
||||
$vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');
|
||||
$vars = array('start', 'current_row_number', 'end', 'total_posts', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row', 'topic_data');
|
||||
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars)));
|
||||
|
||||
$i = $current_row_number;
|
||||
|
38
tests/functions_content/phpbb_clean_search_string_test.php
Normal file
38
tests/functions_content/phpbb_clean_search_string_test.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||
|
||||
class phpbb_functions_content_phpbb_clean_search_string_test extends phpbb_test_case
|
||||
{
|
||||
public function phpbb_clean_search_string_data()
|
||||
{
|
||||
return array(
|
||||
array('*', ''),
|
||||
array('* *', ''),
|
||||
array('test', 'test'),
|
||||
array(' test ', 'test'),
|
||||
array(' test * ', 'test'),
|
||||
array('test* *', 'test*'),
|
||||
array('* *test*', '*test*'),
|
||||
array('test test * test', 'test test test'),
|
||||
array(' some wild*cards * between wo*rds ', 'some wild*cards between wo*rds'),
|
||||
array(' we * now have*** multiple wild***cards * ', 'we now have* multiple wild*cards'),
|
||||
array('pi is *** . * **** * *****', 'pi is .'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider phpbb_clean_search_string_data
|
||||
*/
|
||||
public function test_phpbb_clean_search_string($search_string, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, phpbb_clean_search_string($search_string));
|
||||
}
|
||||
}
|
@ -164,7 +164,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
|
||||
'topic_id' => 45,
|
||||
|
||||
'viewforum' => '',
|
||||
'action' => '{LOG MOD2}',
|
||||
'action' => 'LOG_MOD2',
|
||||
'viewtopic' => '',
|
||||
'viewlogs' => '',
|
||||
),
|
||||
@ -185,7 +185,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
|
||||
'topic_id' => 0,
|
||||
|
||||
'viewforum' => '',
|
||||
'action' => '{LOG USER}<br />admin',
|
||||
'action' => 'LOG_USER admin',
|
||||
),
|
||||
9 => array(
|
||||
'id' => 9,
|
||||
@ -204,7 +204,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
|
||||
'topic_id' => 0,
|
||||
|
||||
'viewforum' => '',
|
||||
'action' => '{LOG USER}<br />guest',
|
||||
'action' => 'LOG_USER guest',
|
||||
),
|
||||
);
|
||||
|
||||
@ -331,6 +331,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
|
||||
// Test sprintf() of the data into the action
|
||||
$user->lang = array(
|
||||
'LOG_INSTALL_INSTALLED' => 'installed: %s',
|
||||
'LOG_USER' => 'User<br /> %s',
|
||||
'LOG_MOD2' => 'Mod2',
|
||||
);
|
||||
|
||||
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user