aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-04-16 11:08:31 +0200
committerMarc Alexander <admin@m-a-styles.de>2014-04-16 11:08:31 +0200
commit01030bb3a9dbc158f39a190d2ff187de52e606f4 (patch)
treed1052bf785dbb70af81b50fce964ce253f1a8096
parent61f4802b5a40c0d30de8398a058a24baf2cab182 (diff)
parentb305364b278cb224346a4a98cfdace24b2f3b845 (diff)
downloadforums-01030bb3a9dbc158f39a190d2ff187de52e606f4.tar
forums-01030bb3a9dbc158f39a190d2ff187de52e606f4.tar.gz
forums-01030bb3a9dbc158f39a190d2ff187de52e606f4.tar.bz2
forums-01030bb3a9dbc158f39a190d2ff187de52e606f4.tar.xz
forums-01030bb3a9dbc158f39a190d2ff187de52e606f4.zip
Merge branch 'develop-ascraeus' of https://github.com/phpbb/phpbb into ticket/12407
Conflicts: phpBB/posting.php
-rw-r--r--phpBB/includes/functions_content.php18
-rw-r--r--phpBB/includes/functions_privmsgs.php14
-rw-r--r--phpBB/install/install_install.php12
-rw-r--r--phpBB/phpbb/db/tools.php4
-rw-r--r--phpBB/phpbb/log/log.php4
-rw-r--r--phpBB/posting.php32
-rw-r--r--phpBB/search.php9
-rw-r--r--phpBB/viewforum.php12
-rw-r--r--phpBB/viewtopic.php21
-rw-r--r--tests/functions_content/phpbb_clean_search_string_test.php38
-rw-r--r--tests/log/function_view_log_test.php8
11 files changed, 138 insertions, 34 deletions
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index dd9201165b..b1f69c5756 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -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()
@@ -360,6 +361,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...
*/
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 17d67b4a23..9b44984dfa 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -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;
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index c749b54f40..db8156a831 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -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
diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php
index 7616849465..3d480b7e1c 100644
--- a/phpBB/phpbb/db/tools.php
+++ b/phpBB/phpbb/db/tools.php
@@ -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
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php
index 24eb408b63..44fba06d9d 100644
--- a/phpBB/phpbb/log/log.php
+++ b/phpBB/phpbb/log/log.php
@@ -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++;
}
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 7a90a473a7..7f374338ff 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -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();
diff --git a/phpBB/search.php b/phpBB/search.php
index 4756a941f5..44335e2927 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -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('+', '-', '|', '(', ')', '&quot;'), ' ', $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('+', '-', '|', '(', ')', '&quot;'), ' ', $keywords));
+ $hilit = str_replace(' ', '|', $hilit);
$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));
$u_show_results = '&amp;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);
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 4da0267284..a7396f9c72 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -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))
{
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 1a74ad3e38..ad7e8c29bc 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -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;
diff --git a/tests/functions_content/phpbb_clean_search_string_test.php b/tests/functions_content/phpbb_clean_search_string_test.php
new file mode 100644
index 0000000000..de642c9040
--- /dev/null
+++ b/tests/functions_content/phpbb_clean_search_string_test.php
@@ -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));
+ }
+}
diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php
index 9148d23bb4..2ddf7522f4 100644
--- a/tests/log/function_view_log_test.php
+++ b/tests/log/function_view_log_test.php
@@ -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);