From 53169b1303d3b9be66c6b67ab031060c41a1280f Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 11 Jan 2015 20:42:42 +0100 Subject: [PATCH 001/239] [ticket/13469] Fall back to soft_delete if no permissions for delete PHPBB3-13469 --- phpBB/posting.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 10c3b696e6..695a71140a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -330,14 +330,17 @@ switch ($mode) { $is_authed = true; } - break; + + // no break; case 'soft_delete': - if ($user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) + if (!$is_authed && $user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) { + // Fall back to soft_delete if we have no permissions to delete posts but to soft delete them $is_authed = true; + $mode = 'soft_delete'; } - else + else if (!$is_authed) { // Display the same error message for softdelete we use for delete $mode = 'delete'; From 9a03b3aab6033b52492296730c30849f96f430bf Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Jan 2015 12:49:58 +0100 Subject: [PATCH 002/239] [ticket/13522] Remove empty answers from possible answers in Q&A PHPBB3-13522 --- phpBB/phpbb/captcha/plugins/qa.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index a7ba994cc3..13ff3d7f91 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -827,13 +827,22 @@ class qa function acp_get_question_input() { $answers = utf8_normalize_nfc(request_var('answers', '', true)); + + // Convert answers into array and filter if answers are set + if (strlen($answers)) + { + $answers = array_filter(explode("\n", $answers), function ($value) { + return trim($value) !== ''; + }); + } + + $question = array( 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), - 'answers' => (strlen($answers)) ? explode("\n", $answers) : '', + 'answers' => $answers, ); - return $question; } From 874f3584e2713cd332215b159b740e53330a900c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Jan 2015 13:40:42 +0100 Subject: [PATCH 003/239] [ticket/13522] Remove unused variables and unexpected returns PHPBB3-13522 --- phpBB/phpbb/captcha/plugins/qa.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index 13ff3d7f91..12da64c750 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -125,7 +125,7 @@ class qa */ public function is_available() { - global $config, $db, $phpbb_root_path, $phpEx, $user; + global $config, $db, $user; // load language file for pretty display in the ACP dropdown $user->add_lang('captcha_qa'); @@ -263,7 +263,7 @@ class qa */ function garbage_collect($type = 0) { - global $db, $config; + global $db; $sql = 'SELECT c.confirm_id FROM ' . $this->table_qa_confirm . ' c @@ -310,8 +310,6 @@ class qa $db_tool = new \phpbb\db\tools($db); - $tables = array($this->table_captcha_questions, $this->table_captcha_answers, $this->table_qa_confirm); - $schemas = array( $this->table_captcha_questions => array ( 'COLUMNS' => array( @@ -366,7 +364,7 @@ class qa */ function validate() { - global $config, $db, $user; + global $user; $error = ''; @@ -414,7 +412,7 @@ class qa if (!sizeof($this->question_ids)) { - return false; + return; } $this->confirm_id = md5(unique_id($user->ip)); $this->question = (int) array_rand($this->question_ids); @@ -440,7 +438,7 @@ class qa if (!sizeof($this->question_ids)) { - return false; + return; } $this->question = (int) array_rand($this->question_ids); @@ -611,8 +609,8 @@ class qa */ function acp_page($id, &$module) { - global $db, $user, $auth, $template; - global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + global $user, $template; + global $config; $user->add_lang('acp/board'); $user->add_lang('captcha_qa'); @@ -674,7 +672,6 @@ class qa else { // okay, show the editor - $error = false; $input_question = request_var('question_text', '', true); $input_answers = request_var('answers', '', true); $input_lang = request_var('lang_iso', '', true); @@ -819,6 +816,8 @@ class qa return $question; } + + return false; } /** From 25b54791f9cc64f3e861a169a8a70d69c0cc2131 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 11 Feb 2015 13:03:22 +0100 Subject: [PATCH 004/239] [ticket/13493] Append page name to base url if it doesn't contain it PHPBB3-13493 --- phpBB/phpbb/controller/helper.php | 6 +++ tests/controller/common_helper_route.php | 7 +++- tests/controller/helper_route_slash_test.php | 43 ++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/controller/helper_route_slash_test.php diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index c6c470e91b..dc802751fb 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -142,6 +142,12 @@ class helper $base_url = $context->getBaseUrl(); + // Append page name if base URL does not contain it + if (!empty($page_name) && strpos($base_url, '/' . $page_name) === false) + { + $base_url .= '/' . $page_name; + } + // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url); diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 6723e3bc52..ff1af8119b 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -51,6 +51,11 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case return '/app.php'; } + protected function get_base_uri() + { + return $this->get_uri(); + } + protected function get_script_name() { return 'app.php'; @@ -66,7 +71,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->request = new phpbb_mock_request(); $this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER); $this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER); - $this->request->overwrite('REQUEST_URI', $this->get_uri(), \phpbb\request\request_interface::SERVER); + $this->request->overwrite('REQUEST_URI', $this->get_base_uri(), \phpbb\request\request_interface::SERVER); $this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER); $this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER); diff --git a/tests/controller/helper_route_slash_test.php b/tests/controller/helper_route_slash_test.php new file mode 100644 index 0000000000..cb405d6317 --- /dev/null +++ b/tests/controller/helper_route_slash_test.php @@ -0,0 +1,43 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_slash_test extends phpbb_controller_common_helper_route +{ + protected function get_phpbb_root_path() + { + return './../'; + } + + protected function get_uri() + { + return '/phpBB3/app.php'; + } + + protected function get_base_uri() + { + return '/phpBB3'; + } + + protected function get_script_name() + { + return 'app.php'; + } + + protected function path_to_app() + { + return 'phpBB3/'; + } +} From 957b23765f60f1f4d3a2cdb660cfb48024b88ece Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 15 Feb 2015 14:20:42 +0000 Subject: [PATCH 005/239] [ticket/13621] Prepend $where_sql and postpend closing parentheses on return Prepend $where_sql and postpend closing parentheses on statements with return PHPBB3-13621 --- phpBB/phpbb/content_visibility.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index c8516d6c85..ec73abc721 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -206,7 +206,7 @@ class content_visibility if (!sizeof($forum_ids)) { // The user can see all posts/topics in all specified forums - return $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums); + return $where_sql . $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ')'; } else { @@ -217,8 +217,8 @@ class content_visibility else { // The user is just a normal user - return $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' - AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true); + return $where_sql . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' + AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true) . ')'; } $where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' From 6f56dc8568da4cdf6e1fce0dc46f8174ce58b5fd Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 16 Feb 2015 19:51:09 +0100 Subject: [PATCH 006/239] [ticket/11424] Handle race condition properly for Quick-Mod Tools PHPBB3-11424 --- phpBB/includes/mcp/mcp_main.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 1241b8bd0e..8933a6f2ac 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -226,6 +226,31 @@ class mcp_main break; default: + if($quickmod) + { + switch($action) + { + case 'lock': + case 'unlock': + case 'make_announce': + case 'make_sticky': + case 'make_global': + case 'make_normal': + case 'make_onindex': + case 'move': + case 'fork': + case 'delete_topic': + trigger_error('TOPIC_NOT_EXIST'); + break; + + case 'lock_post': + case 'unlock_post': + case 'delete_post': + trigger_error('POST_NOT_EXIST'); + break; + } + } + trigger_error('NO_MODE', E_USER_ERROR); break; } From 8d6ab63fea22edd6b57435891cd0cd28c9774b20 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Thu, 19 Feb 2015 22:07:26 +0100 Subject: [PATCH 007/239] [ticket/11424] Add space between control flow keywords and parenthesis PHPBB3-11424 --- phpBB/includes/mcp/mcp_main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 8933a6f2ac..10f1a5b8c1 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -226,9 +226,9 @@ class mcp_main break; default: - if($quickmod) + if ($quickmod) { - switch($action) + switch ($action) { case 'lock': case 'unlock': From 12fe882741db91a155620d5870c6127798125720 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Jan 2015 13:53:22 +0100 Subject: [PATCH 008/239] [ticket/13522] Trim array elements before processing further PHPBB3-13522 --- phpBB/phpbb/captcha/plugins/qa.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index 12da64c750..824e6db3b0 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -830,12 +830,11 @@ class qa // Convert answers into array and filter if answers are set if (strlen($answers)) { - $answers = array_filter(explode("\n", $answers), function ($value) { - return trim($value) !== ''; + $answers = array_filter(array_map('trim', explode("\n", $answers)), function ($value) { + return $value !== ''; }); } - $question = array( 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), From d15e5372caf1d0811e1f2bc87d5deddba171cb09 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Jan 2015 22:52:40 +0100 Subject: [PATCH 009/239] [ticket/13522] Use acp_get_question_input() for retrieving input data PHPBB3-13522 --- phpBB/phpbb/captcha/plugins/qa.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index 824e6db3b0..3a2652d02c 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -672,10 +672,7 @@ class qa else { // okay, show the editor - $input_question = request_var('question_text', '', true); - $input_answers = request_var('answers', '', true); - $input_lang = request_var('lang_iso', '', true); - $input_strict = request_var('strict', false); + $question_input = $this->acp_get_question_input(); $langs = $this->get_languages(); foreach ($langs as $lang => $entry) @@ -694,12 +691,12 @@ class qa { if ($question = $this->acp_get_question_data($question_id)) { - $answers = (isset($input_answers[$lang])) ? $input_answers[$lang] : implode("\n", $question['answers']); + $answers = (isset($question_input['answers'][$lang])) ? $question_input['answers'][$lang] : implode("\n", $question['answers']); $template->assign_vars(array( - 'QUESTION_TEXT' => ($input_question) ? $input_question : $question['question_text'], - 'LANG_ISO' => ($input_lang) ? $input_lang : $question['lang_iso'], - 'STRICT' => (isset($_REQUEST['strict'])) ? $input_strict : $question['strict'], + 'QUESTION_TEXT' => ($question_input['question_text']) ? $question_input['question_text'] : $question['question_text'], + 'LANG_ISO' => ($question_input['lang_iso']) ? $question_input['lang_iso'] : $question['lang_iso'], + 'STRICT' => (isset($_REQUEST['strict'])) ? $question_input['strict'] : $question['strict'], 'ANSWERS' => $answers, )); } @@ -711,10 +708,10 @@ class qa else { $template->assign_vars(array( - 'QUESTION_TEXT' => $input_question, - 'LANG_ISO' => $input_lang, - 'STRICT' => $input_strict, - 'ANSWERS' => $input_answers, + 'QUESTION_TEXT' => $question_input['question_text'], + 'LANG_ISO' => $question_input['lang_iso'], + 'STRICT' => $question_input['strict'], + 'ANSWERS' => $question_input['answers'], )); } From 5bfcc7e70780438b339731273e7793a74b24e59b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 Jan 2015 20:57:21 +0100 Subject: [PATCH 010/239] [ticket/13522] Add test file for Q&A captcha PHPBB3-13522 --- tests/captcha/qa_test.php | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/captcha/qa_test.php diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php new file mode 100644 index 0000000000..51bc09d309 --- /dev/null +++ b/tests/captcha/qa_test.php @@ -0,0 +1,46 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class phpbb_qa_test extends \phpbb_database_test_case +{ + protected $request; + + /** @var \phpbb\captcha\plugins\qa */ + protected $qa; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml'); + } + + public function setUp() + { + global $db; + + $db = $this->new_dbal(); + + parent::setUp(); + + $this->request = new \phpbb_mock_request(); + $this->qa = new \phpbb\captcha\plugins\qa($this->request, 'phpbb_captcha_questions', 'phpbb_captcha_answers', 'phpbb_qa_confirm'); + } + + public function test_is_installed() + { + $this->assertFalse($this->qa->is_installed()); + + $this->qa->install(); + + $this->assertTrue($this->qa->is_installed()); + } +} \ No newline at end of file From 4167be1e2c5dc5ea9fcc7ed6b39f54cc68fef5b2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 31 Jan 2015 12:19:03 +0100 Subject: [PATCH 011/239] [ticket/13522] Add tests for acp_get_question_input and set/get name PHPBB3-13522 --- tests/captcha/qa_test.php | 47 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php index 51bc09d309..fdf0c799f3 100644 --- a/tests/captcha/qa_test.php +++ b/tests/captcha/qa_test.php @@ -43,4 +43,49 @@ class phpbb_qa_test extends \phpbb_database_test_case $this->assertTrue($this->qa->is_installed()); } -} \ No newline at end of file + + public function test_set_get_name() + { + $this->assertNull($this->qa->get_service_name()); + $this->qa->set_name('foobar'); + $this->assertSame('foobar', $this->qa->get_service_name()); + } + + public function data_acp_get_question_input() + { + return array( + array("foobar\ntest\nyes", array( + 'question_text' => '', + 'strict' => false, + 'lang_iso' => '', + 'answers' => array('foobar', 'test', 'yes') + )), + array("foobar\ntest\n \nyes", array( + 'question_text' => '', + 'strict' => false, + 'lang_iso' => '', + 'answers' => array( + 0 => 'foobar', + 1 => 'test', + 3 => 'yes', + ) + )), + array('', array( + 'question_text' => '', + 'strict' => false, + 'lang_iso' => '', + 'answers' => '', + )), + ); + } + + /** + * @dataProvider data_acp_get_question_input + */ + public function test_acp_get_question_input($value, $expected) + { + $this->request->overwrite('answers', $value); + + $this->assertEquals($expected, $this->qa->acp_get_question_input()); + } +} From 8e737e483e2fbd20712bbcd1b3bb96d623ac0f24 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 31 Jan 2015 12:39:58 +0100 Subject: [PATCH 012/239] [ticket/13522] Remove unneeded variables and correctly output input on error PHPBB3-13522 --- phpBB/phpbb/captcha/plugins/qa.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index 3a2652d02c..04052b3406 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -691,13 +691,11 @@ class qa { if ($question = $this->acp_get_question_data($question_id)) { - $answers = (isset($question_input['answers'][$lang])) ? $question_input['answers'][$lang] : implode("\n", $question['answers']); - $template->assign_vars(array( 'QUESTION_TEXT' => ($question_input['question_text']) ? $question_input['question_text'] : $question['question_text'], 'LANG_ISO' => ($question_input['lang_iso']) ? $question_input['lang_iso'] : $question['lang_iso'], 'STRICT' => (isset($_REQUEST['strict'])) ? $question_input['strict'] : $question['strict'], - 'ANSWERS' => $answers, + 'ANSWERS' => implode("\n", $question['answers']), )); } else @@ -711,15 +709,13 @@ class qa 'QUESTION_TEXT' => $question_input['question_text'], 'LANG_ISO' => $question_input['lang_iso'], 'STRICT' => $question_input['strict'], - 'ANSWERS' => $question_input['answers'], + 'ANSWERS' => (is_array($question_input['answers'])) ? implode("\n", $question_input['answers']) : '', )); } if ($submit && check_form_key($form_key)) { - $data = $this->acp_get_question_input(); - - if (!$this->validate_input($data)) + if (!$this->validate_input($question_input)) { $template->assign_vars(array( 'S_ERROR' => true, @@ -729,11 +725,11 @@ class qa { if ($question_id) { - $this->acp_update_question($data, $question_id); + $this->acp_update_question($question_input, $question_id); } else { - $this->acp_add_question($data); + $this->acp_add_question($question_input); } add_log('admin', 'LOG_CONFIG_VISUAL'); From 94b72cfbdb3eae2822ba0fddb88369373ebd5b85 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 2 Feb 2015 16:19:07 +0100 Subject: [PATCH 013/239] [ticket/13522] Add captcha to test file class name PHPBB3-13522 --- tests/captcha/qa_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php index fdf0c799f3..8d0d77d0e3 100644 --- a/tests/captcha/qa_test.php +++ b/tests/captcha/qa_test.php @@ -11,7 +11,7 @@ * */ -class phpbb_qa_test extends \phpbb_database_test_case +class phpbb_captcha_qa_test extends \phpbb_database_test_case { protected $request; From c63bc6ee93f143fbc97ddb826fb310962a8320c7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 21 Feb 2015 17:53:25 +0100 Subject: [PATCH 014/239] [ticket/13522] Fix QA tests for request_var() use PHPBB3-13522 --- tests/captcha/qa_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php index 8d0d77d0e3..1f2f9f3070 100644 --- a/tests/captcha/qa_test.php +++ b/tests/captcha/qa_test.php @@ -11,6 +11,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + class phpbb_captcha_qa_test extends \phpbb_database_test_case { protected $request; @@ -32,7 +34,8 @@ class phpbb_captcha_qa_test extends \phpbb_database_test_case parent::setUp(); $this->request = new \phpbb_mock_request(); - $this->qa = new \phpbb\captcha\plugins\qa($this->request, 'phpbb_captcha_questions', 'phpbb_captcha_answers', 'phpbb_qa_confirm'); + request_var(false, false, false, false, $this->request); + $this->qa = new \phpbb\captcha\plugins\qa('phpbb_captcha_questions', 'phpbb_captcha_answers', 'phpbb_qa_confirm'); } public function test_is_installed() From b650f45d5597fd6a2864ddcd658df3603deb001f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 24 Feb 2015 11:43:33 +0100 Subject: [PATCH 015/239] [ticket/12368] Correctly check if avatars migration is installed Try to set the avatar type to string value to check if new avatar types are supported. PHPBB3-12368 --- .../phpbb/db/migration/data/v310/avatars.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v310/avatars.php b/phpBB/phpbb/db/migration/data/v310/avatars.php index 2698adeed5..51e222532b 100644 --- a/phpBB/phpbb/db/migration/data/v310/avatars.php +++ b/phpBB/phpbb/db/migration/data/v310/avatars.php @@ -17,7 +17,29 @@ class avatars extends \phpbb\db\migration\migration { public function effectively_installed() { - return isset($this->config['allow_avatar_gravatar']); + // Get current avatar type of guest user + $sql = 'SELECT user_avatar_type + FROM ' . $this->table_prefix . 'users + WHERE user_id = ' . ANONYMOUS; + $result = $this->db->sql_query($sql); + $backup_type = $this->db->sql_fetchfield('user_avatar_type'); + $this->db->sql_freeresult($result); + + // Try to set avatar type to string + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_avatar_type = 'avatar.driver.upload' + WHERE user_id = " . ANONYMOUS; + $this->db->sql_return_on_error(true); + $effectively_installed = $this->db->sql_query($sql); + $this->db->sql_return_on_error(); + + // Return avatar type of guest user to previous state + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_avatar_type = '{$backup_type}' + WHERE user_id = " . ANONYMOUS; + $this->db->sql_query($sql); + + return $effectively_installed !== false; } static public function depends_on() From 8b23272c3363fa7bd83f4e6831929b4336ecf55b Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 28 Feb 2015 08:45:34 +0000 Subject: [PATCH 016/239] [ticket/13660] Allow changing the query for total reports in mcp_front PHPBB3-13660 --- phpBB/includes/mcp/mcp_front.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 500db55456..145ac16ff4 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -157,6 +157,18 @@ function mcp_front_view($id, $mode, $action) AND r.pm_id = 0 AND r.report_closed = 0 AND ' . $db->sql_in_set('p.forum_id', $forum_list); + + /** + * Alter sql query to count the number of reported posts + * + * @event core.mcp_front_reports_count_query_before + * @var int sql The query string used to get the number of reports that exist + * @var array forum_list List of forums that contain the posts + * @since 3.1.0-RC3 + */ + $vars = array('sql', 'forum_list'); + extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars))); + $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); From dbc09bf0d4d2537d0570f6de5958d5f2e38a864e Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 28 Feb 2015 20:34:25 +0000 Subject: [PATCH 017/239] [ticket/13661] Transform queries to get logs and log count into built queries PHPBB3-13661 --- phpBB/phpbb/log/log.php | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0c5205530b..6fb8dc79c6 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -521,15 +521,30 @@ class log implements \phpbb\log\log_interface $sql_keywords = $this->generate_sql_keyword($keywords); } - if ($count_logs) - { - $sql = 'SELECT COUNT(l.log_id) AS total_entries - FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u - WHERE l.log_type = ' . (int) $log_type . ' - AND l.user_id = u.user_id + $get_logs_sql_ary = array( + 'SELECT' => 'l.*, u.username, u.username_clean, u.user_colour', + 'FROM' => $this->log_table . ' l, ' . USERS_TABLE . ' u', + 'WHERE' => 'l.user_id = u.user_id AND l.log_time >= ' . (int) $log_time . " $sql_keywords - $sql_additional"; + $sql_additional", + + 'ORDER_BY' => $sort_by, + ); + + if($log_type){ + $get_logs_sql_ary['WHERE'] = 'l.log_type = ' . (int) $log_type . ' + AND ' . $get_logs_sql_ary['WHERE']; + } + + if ($count_logs) + { + $count_logs_sql_ary = $get_logs_sql_ary; + + $count_logs_sql_ary['SELECT'] = 'COUNT(l.log_id) AS total_entries'; + unset($count_logs_sql_ary['ORDER_BY']); + + $sql = $this->db->sql_build_array('SELECT', $count_logs_sql_ary); $result = $this->db->sql_query($sql); $this->entry_count = (int) $this->db->sql_fetchfield('total_entries'); $this->db->sql_freeresult($result); @@ -548,14 +563,7 @@ class log implements \phpbb\log\log_interface } } - $sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour - FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u - WHERE l.log_type = ' . (int) $log_type . ' - AND u.user_id = l.user_id - ' . (($log_time) ? 'AND l.log_time >= ' . (int) $log_time : '') . " - $sql_keywords - $sql_additional - ORDER BY $sort_by"; + $sql = $this->db->sql_build_array('SELECT', $get_logs_sql_ary); $result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset); $i = 0; From d66a53a53127f9c50dd62c34bf08fdabacdea001 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 10:07:18 +0000 Subject: [PATCH 018/239] [ticket/13661] Add event to allow editing the queries used to get the logs PHPBB3-13661 --- phpBB/phpbb/log/log.php | 47 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 6fb8dc79c6..1aa9e073f0 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -537,6 +537,49 @@ class log implements \phpbb\log\log_interface AND ' . $get_logs_sql_ary['WHERE']; } + /** + * Modify the query to obtain the logs data + * + * @event core.get_logs_main_query_before + * @var array get_logs_sql_ary The array in the format of the query builder with the query + * to get the log count and the log list + * @var string mode Mode of the entries we display + * @var bool count_logs Do we count all matching entries? + * @var int limit Limit the number of entries + * @var int offset Offset when fetching the entries + * @var mixed forum_id Limit entries to the forum_id, + * can also be an array of forum_ids + * @var int topic_id Limit entries to the topic_id + * @var int user_id Limit entries to the user_id + * @var int log_time Limit maximum age of log entries + * @var string sort_by SQL order option + * @var string keywords Will only return entries that have the + * keywords in log_operation or log_data + * @var string profile_url URL to the users profile + * @var int log_type Limit logs to a certain type. If log_type + * is false, no entries will be returned. + * @var string sql_additional Additional conditions for the entries, + * e.g.: 'AND l.forum_id = 1' + * @since 3.1.0-a1 + */ + $vars = array( + 'get_logs_sql_ary', + 'mode', + 'count_logs', + 'limit', + 'offset', + 'forum_id', + 'topic_id', + 'user_id', + 'log_time', + 'sort_by', + 'keywords', + 'profile_url', + 'log_type', + 'sql_additional', + ); + extract($this->dispatcher->trigger_event('core.get_logs_main_query_before', compact($vars))); + if ($count_logs) { $count_logs_sql_ary = $get_logs_sql_ary; @@ -544,7 +587,7 @@ class log implements \phpbb\log\log_interface $count_logs_sql_ary['SELECT'] = 'COUNT(l.log_id) AS total_entries'; unset($count_logs_sql_ary['ORDER_BY']); - $sql = $this->db->sql_build_array('SELECT', $count_logs_sql_ary); + $sql = $this->db->sql_build_query('SELECT', $count_logs_sql_ary); $result = $this->db->sql_query($sql); $this->entry_count = (int) $this->db->sql_fetchfield('total_entries'); $this->db->sql_freeresult($result); @@ -563,7 +606,7 @@ class log implements \phpbb\log\log_interface } } - $sql = $this->db->sql_build_array('SELECT', $get_logs_sql_ary); + $sql = $this->db->sql_build_query('SELECT', $get_logs_sql_ary); $result = $this->db->sql_query_limit($sql, $limit, $this->last_page_offset); $i = 0; From c887eedaa5c9efeeec82cf29117325480905c9f3 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 14:01:57 +0000 Subject: [PATCH 019/239] [ticket/13661] Fixed the "FROM" in the built query. I was doing it wrong by giving a string to the FROM clause in the built query. PHPBB3-13661 --- phpBB/phpbb/log/log.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 1aa9e073f0..e2802ba3e1 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -523,7 +523,10 @@ class log implements \phpbb\log\log_interface $get_logs_sql_ary = array( 'SELECT' => 'l.*, u.username, u.username_clean, u.user_colour', - 'FROM' => $this->log_table . ' l, ' . USERS_TABLE . ' u', + 'FROM' => array( + $this->log_table => 'l', + USERS_TABLE => 'u', + ), 'WHERE' => 'l.user_id = u.user_id AND l.log_time >= ' . (int) $log_time . " $sql_keywords From fb71e6dde6a0a3b35f51f992930f8d929c709d46 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 1 Mar 2015 17:37:26 +0100 Subject: [PATCH 020/239] [ticket/8494] Ignore errors from the database schema preparation This allows installing phpBB twice in the same database with a different prefix PHPBB3-8494 --- phpBB/install/install_install.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 3a6858a254..6f7fbd9d5f 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1164,12 +1164,10 @@ class install_install extends module foreach ($sql_query as $sql) { - //$sql = trim(str_replace('|', ';', $sql)); - if (!$db->sql_query($sql)) - { - $error = $db->sql_error(); - $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); - } + // Ignore errors when the functions or types already exist + // to allow installing phpBB twice in the same database with + // a different prefix + $db->sql_query($sql); } unset($sql_query); } From d0a1650a04fc74fb81c0123505854a09352d49c1 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 18:35:11 +0000 Subject: [PATCH 021/239] [ticket/13661] bugfix: The conditional is the log_time, not log_type I mistakenly made the log_type the conditional instead of log_time. Thankfully, the automated tests helped finding this mistake. PHPBB3-13661 --- phpBB/phpbb/log/log.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index e2802ba3e1..735d595bb5 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -527,8 +527,8 @@ class log implements \phpbb\log\log_interface $this->log_table => 'l', USERS_TABLE => 'u', ), - 'WHERE' => 'l.user_id = u.user_id - AND l.log_time >= ' . (int) $log_time . " + 'WHERE' => 'l.log_type = ' . (int) $log_type . " + AND l.user_id = u.user_id $sql_keywords $sql_additional", @@ -536,7 +536,7 @@ class log implements \phpbb\log\log_interface ); if($log_type){ - $get_logs_sql_ary['WHERE'] = 'l.log_type = ' . (int) $log_type . ' + $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } From 5ad69bbecf49522734c340356f5d9e8303720a9c Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 19:55:43 +0000 Subject: [PATCH 022/239] [ticket/13664] From string query in mcp_front unapproved posts to built query PHPBB3-13664 --- phpBB/includes/mcp/mcp_front.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 500db55456..81960e5cd2 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -41,10 +41,15 @@ function mcp_front_view($id, $mode, $action) if (!empty($forum_list)) { - $sql = 'SELECT COUNT(post_id) AS total - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' - AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)); + $sql_ary = array( + 'SELECT' => 'COUNT(post_id) AS total', + 'FROM' => array( + POSTS_TABLE => '', + ), + 'WHERE' => $db->sql_in_set('forum_id', $forum_list) . ' + AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); From 772bbdfeae879b17aa2b62f10469bc8b63230093 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 19:58:57 +0000 Subject: [PATCH 023/239] [ticket/13661] Removed superfluous whitespace PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 735d595bb5..0fd33b4618 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -582,7 +582,7 @@ class log implements \phpbb\log\log_interface 'sql_additional', ); extract($this->dispatcher->trigger_event('core.get_logs_main_query_before', compact($vars))); - + if ($count_logs) { $count_logs_sql_ary = $get_logs_sql_ary; From 5fa6871ebf486eb70052c2e5a07b96d6b23d88c0 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 19:56:50 +0000 Subject: [PATCH 024/239] [ticket/13664] Add event to allow changing number of unapproved posts listed PHPBB3-13664 --- phpBB/includes/mcp/mcp_front.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 81960e5cd2..41953a71e6 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -49,6 +49,18 @@ function mcp_front_view($id, $mode, $action) 'WHERE' => $db->sql_in_set('forum_id', $forum_list) . ' AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) ); + + /** + * Allow altering the query to get the number of unapproved posts + * + * @event core.mcp_front_queue_unapproved_total_before + * @var int sql_ary Query to get the total number of unapproved posts + * @var array forum_list List of forums to look for unapproved posts + * @since 3.1.4-RC1 + */ + $vars = array('sql_ary', 'forum_list'); + extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); From d53b584c9a5ac247bfb88aa230dc064b7a73e72c Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 20:12:37 +0000 Subject: [PATCH 025/239] [ticket/13661] Wrong event @since version PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 0fd33b4618..8e5f75807c 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -563,7 +563,7 @@ class log implements \phpbb\log\log_interface * is false, no entries will be returned. * @var string sql_additional Additional conditions for the entries, * e.g.: 'AND l.forum_id = 1' - * @since 3.1.0-a1 + * @since 3.1.4-RC1 */ $vars = array( 'get_logs_sql_ary', From 21cc1fda8562dcb20f0d850da232d69281d6df51 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 20:57:06 +0000 Subject: [PATCH 026/239] [ticket/13664] Added alias to table to make modding easier. PHPBB3-13664 --- phpBB/includes/mcp/mcp_front.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 41953a71e6..4278511c01 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -44,10 +44,10 @@ function mcp_front_view($id, $mode, $action) $sql_ary = array( 'SELECT' => 'COUNT(post_id) AS total', 'FROM' => array( - POSTS_TABLE => '', + POSTS_TABLE => 'p', ), - 'WHERE' => $db->sql_in_set('forum_id', $forum_list) . ' - AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) + 'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . ' + AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) ); /** From c7cc8a098e2a38bbe822468cead4ee9df1745104 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sun, 1 Mar 2015 21:17:06 +0000 Subject: [PATCH 027/239] [ticket/13661] Re-Fixed $log_type -> $log_time Thanks to goof for pointing it out... PHPBB3-13661 --- phpBB/phpbb/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 8e5f75807c..3d89e7403f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -535,7 +535,7 @@ class log implements \phpbb\log\log_interface 'ORDER_BY' => $sort_by, ); - if($log_type){ + if($log_time){ $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } From 134a5e0391aa4d05d347a77c0218b29ab9b60a1b Mon Sep 17 00:00:00 2001 From: brunoais Date: Mon, 2 Mar 2015 08:34:52 +0000 Subject: [PATCH 028/239] [ticket/13661] Brackets in their own line I didn't even notice that I used my own coding guidelines there... Thanks to MGaetan89 for pointing it out. PHPBB3-13661 --- phpBB/phpbb/log/log.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 3d89e7403f..1aba5851a5 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -535,7 +535,8 @@ class log implements \phpbb\log\log_interface 'ORDER_BY' => $sort_by, ); - if($log_time){ + if($log_time) + { $get_logs_sql_ary['WHERE'] = 'l.log_time >= ' . (int) $log_time . ' AND ' . $get_logs_sql_ary['WHERE']; } From fa474c4378dc22e586f46f7a0e32df83d6a5c801 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 5 Mar 2015 16:19:36 +0000 Subject: [PATCH 029/239] [ticket/13668] Convert the mcp report_details query to a built query PHPBB3-13668 --- phpBB/includes/mcp/mcp_reports.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 804d48ea97..856c8794e2 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -73,14 +73,23 @@ class mcp_reports // closed reports are accessed by report id $report_id = request_var('r', 0); + $sql_ary = array( + 'SELECT' => 'r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour', - $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour - FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u - WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' + 'FROM' => array( + REPORTS_TABLE => 'r', + REPORTS_REASONS_TABLE => 'rr', + USERS_TABLE => 'u', + ), + + 'WHERE' => '' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id - AND r.pm_id = 0 - ORDER BY report_closed ASC'; + AND r.pm_id = 0', + + 'ORDER_BY' => 'report_closed ASC', + ); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); From 8a6d55520d5165e2abdd3a48ef70be2a2b4e8308 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 5 Mar 2015 16:21:23 +0000 Subject: [PATCH 030/239] [ticket/13668] Allow changing the query to obtain the user-submitted report. PHPBB3-13668 --- phpBB/includes/mcp/mcp_reports.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 856c8794e2..5d3732e12c 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -89,6 +89,25 @@ class mcp_reports 'ORDER_BY' => 'report_closed ASC', ); + + /** + * Allow changing the query to obtain the user-submitted report. + * + * @event core.mcp_reports_report_details_query_before + * @var array sql_ary The array in the format of the query builder with the query + * @var mixed forum_id The forum_id, the number in the f GET parameter + * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) + * @var int report_id The report_id of the report being viewed + * @since 3.1.4-RC1 + */ + $vars = array( + 'sql_ary', + 'forum_id', + 'post_id', + 'report_id', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_before', compact($vars))); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); From 4cdcb6d5d347eccead34853c011083b519922da8 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 5 Mar 2015 16:48:10 +0000 Subject: [PATCH 031/239] [ticket/13672] Allow changing the data from the user-submitted report PHPBB3-13672 --- phpBB/includes/mcp/mcp_reports.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 856c8794e2..f6acec31e3 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -94,6 +94,26 @@ class mcp_reports $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); + /** + * Allow changing the data obtained from the user-submitted report. + * + * @event core.mcp_reports_report_details_query_after + * @var array sql_ary The array in the format of the query builder with the query that had been executted + * @var mixed forum_id The forum_id, the number in the f GET parameter + * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) + * @var int report_id The report_id of the report being viewed + * @var int report The query's resulting row. + * @since 3.1.4-RC1 + */ + $vars = array( + 'sql_ary', + 'forum_id', + 'post_id', + 'report_id', + 'report', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_after', compact($vars))); + if (!$report) { trigger_error('NO_REPORT'); From 94da39cd883cc83102551cc4ed71ac385db85ba7 Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 10 Mar 2015 15:42:07 +0000 Subject: [PATCH 032/239] [ticket/13660] Fix @since version. PHPBB3-13660 --- phpBB/includes/mcp/mcp_front.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 145ac16ff4..8697223a54 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -164,7 +164,7 @@ function mcp_front_view($id, $mode, $action) * @event core.mcp_front_reports_count_query_before * @var int sql The query string used to get the number of reports that exist * @var array forum_list List of forums that contain the posts - * @since 3.1.0-RC3 + * @since 3.1.4-RC1 */ $vars = array('sql', 'forum_list'); extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars))); From c3a0e09ddbb53dc77d2d78725f934625266065f3 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 11 Mar 2015 17:46:42 +0000 Subject: [PATCH 033/239] [ticket/13685] Add phpbb_dispatcher to fulltext search constructors PHPBB3-13685 --- phpBB/develop/search_fill.php | 2 +- phpBB/includes/acp/acp_main.php | 2 +- phpBB/includes/acp/acp_search.php | 4 ++-- phpBB/includes/functions_admin.php | 2 +- phpBB/includes/functions_posting.php | 2 +- phpBB/includes/mcp/mcp_main.php | 4 ++-- phpBB/includes/mcp/mcp_post.php | 2 +- phpBB/install/install_convert.php | 4 ++-- phpBB/install/install_install.php | 4 ++-- phpBB/phpbb/search/fulltext_mysql.php | 10 +++++++++- phpBB/phpbb/search/fulltext_native.php | 10 +++++++++- phpBB/phpbb/search/fulltext_postgres.php | 10 +++++++++- phpBB/phpbb/search/fulltext_sphinx.php | 10 +++++++++- phpBB/search.php | 2 +- 14 files changed, 50 insertions(+), 18 deletions(-) diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php index 2a4dfb212c..3a013a2162 100644 --- a/phpBB/develop/search_fill.php +++ b/phpBB/develop/search_fill.php @@ -40,7 +40,7 @@ if (!class_exists($search_type)) } $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, $phpbb_dispatcher, $user); if ($error) { diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 48ca05a118..3d8991fb37 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -632,7 +632,7 @@ class acp_main { $error = false; $search_type = $config['search_type']; - $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, $phpbb_dispatcher, $user); if (!$search->index_created()) { diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index eddc6871f8..37b890c777 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -599,7 +599,7 @@ class acp_search */ function init_search($type, &$search, &$error) { - global $phpbb_root_path, $phpEx, $user, $auth, $config, $db; + global $phpbb_root_path, $phpEx, $user, $auth, $config, $db, $phpbb_dispatcher; if (!class_exists($type) || !method_exists($type, 'keyword_search')) { @@ -608,7 +608,7 @@ class acp_search } $error = false; - $search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); + $search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user); return $error; } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 79f9db2f3f..55087ebf59 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -920,7 +920,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } $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, $phpbb_dispatcher, $user); if ($error) { diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index a06d6f4c35..9769e1a517 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2209,7 +2209,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $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, $phpbb_dispatcher, $user); if ($error) { diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 1241b8bd0e..479a48fa05 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1119,7 +1119,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', function mcp_fork_topic($topic_ids) { global $auth, $user, $db, $template, $config; - global $phpEx, $phpbb_root_path; + global $phpEx, $phpbb_root_path, $phpbb_dispatcher; if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) { @@ -1197,7 +1197,7 @@ function mcp_fork_topic($topic_ids) } $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, $phpbb_dispatcher, $user); $search_mode = 'post'; if ($error) diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 1687409198..bc1090a550 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -497,7 +497,7 @@ function change_poster(&$post_info, $userdata) { // 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, $phpbb_dispatcher, $user); if (!$error && method_exists($search, 'destroy_cache')) { diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index e16c79474b..b132ece0d0 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -619,7 +619,7 @@ class install_convert extends module { global $template, $user, $phpbb_root_path, $phpEx, $db, $lang, $config, $cache, $auth; global $convert, $convert_row, $message_parser, $skip_rows, $language; - global $request, $phpbb_config_php_file; + global $request, $phpbb_config_php_file, $phpbb_dispatcher; extract($phpbb_config_php_file->get_all()); @@ -796,7 +796,7 @@ class install_convert extends module } $error = false; - $convert->fulltext_search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); + $convert->fulltext_search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user); if ($error) { diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 3a6858a254..f9bd5db204 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1461,7 +1461,7 @@ class install_install extends module */ function build_search_index($mode, $sub) { - global $db, $lang, $phpbb_root_path, $phpEx, $config, $auth, $user; + global $db, $lang, $phpbb_root_path, $phpbb_dispatcher, $phpEx, $config, $auth, $user; // Obtain any submitted data $data = $this->get_submitted_data(); @@ -1494,7 +1494,7 @@ class install_install extends module set_config_count(null, null, null, $config); $error = false; - $search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); + $search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user); $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id FROM ' . POSTS_TABLE; diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 1a0aba096f..5ca39f1683 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -42,6 +42,12 @@ class fulltext_mysql extends \phpbb\search\base */ protected $db; + /** + * PhpBB event dispatcher object + * @var \phpbb\event\dispatcher_interface + */ + protected $phpbb_dispatcher; + /** * User object * @var \phpbb\user @@ -78,12 +84,14 @@ class fulltext_mysql extends \phpbb\search\base * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object * @param \phpbb\db\driver\driver_interface Database object + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object * @param \phpbb\user $user User object */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) + public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user) { $this->config = $config; $this->db = $db; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->user = $user; $this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']); diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index 93ea46ca60..d4c1bbc4b9 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -86,6 +86,12 @@ class fulltext_native extends \phpbb\search\base */ protected $db; + /** + * PhpBB event dispatcher object + * @var \phpbb\event\dispatcher_interface + */ + protected $phpbb_dispatcher; + /** * User object * @var \phpbb\user @@ -96,13 +102,15 @@ class fulltext_native extends \phpbb\search\base * Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded * * @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) + public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user) { $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $phpEx; $this->config = $config; $this->db = $db; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->user = $user; $this->word_length = array('min' => $this->config['fulltext_native_min_chars'], 'max' => $this->config['fulltext_native_max_chars']); diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index b6af371d13..9425719c29 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -55,6 +55,12 @@ class fulltext_postgres extends \phpbb\search\base */ protected $db; + /** + * PhpBB event dispatcher object + * @var \phpbb\event\dispatcher_interface + */ + protected $phpbb_dispatcher; + /** * User object * @var \phpbb\user @@ -91,12 +97,14 @@ class fulltext_postgres extends \phpbb\search\base * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object * @param \phpbb\db\driver\driver_interface Database object + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object * @param \phpbb\user $user User object */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) + public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user) { $this->config = $config; $this->db = $db; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->user = $user; $this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']); diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index eb53ca6d40..a09f5cbbe5 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -95,6 +95,12 @@ class fulltext_sphinx */ protected $dbtype; + /** + * PhpBB event dispatcher object + * @var \phpbb\event\dispatcher_interface + */ + protected $phpbb_dispatcher; + /** * User object * @var \phpbb\user @@ -124,13 +130,15 @@ class fulltext_sphinx * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object * @param \phpbb\db\driver\driver_interface Database object + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object * @param \phpbb\user $user User object */ - public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user) + public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $phpbb_dispatcher, $user) { $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $phpEx; $this->config = $config; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->user = $user; $this->db = $db; $this->auth = $auth; diff --git a/phpBB/search.php b/phpBB/search.php index cece37f29c..d4349f4bf6 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -274,7 +274,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } // 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, $phpbb_dispatcher, $user); if ($error) { From 7112058d7ba1cd77a165434c3a732a1cb0d22e01 Mon Sep 17 00:00:00 2001 From: brunoais Date: Thu, 12 Mar 2015 08:30:53 +0000 Subject: [PATCH 034/239] [ticket/13685] Fix tests for fulltext search PHPBB3-13685 --- tests/search/mysql_test.php | 3 ++- tests/search/native_test.php | 3 ++- tests/search/postgres_test.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index c0c16456f4..da3f23bbf4 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -37,8 +37,9 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case $config['fulltext_mysql_max_word_len'] = 254; $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_mysql'); - $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); + $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $phpbb_dispatcher, $user); } } diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 61fde7d098..cf65a4a4de 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -33,11 +33,12 @@ class phpbb_search_native_test extends phpbb_search_test_case $cache = new phpbb_mock_cache(); $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_native'); $config['fulltext_native_min_chars'] = 2; $config['fulltext_native_max_chars'] = 14; - $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); + $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $phpbb_dispatcher, $user); } public function keywords() diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index f96d71e2bc..ece99b4500 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -37,8 +37,9 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case $config['fulltext_postgres_max_word_len'] = 254; $this->db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_postgres'); - $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); + $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $phpbb_dispatcher, $user); } } From 3bda9a3c1142d1c3504eb65d581d810de7d6f016 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 11 Mar 2015 18:04:10 +0000 Subject: [PATCH 035/239] [ticket/13686] Allow modify query used for counting in fulltext_native PHPBB3-13686 --- phpBB/phpbb/search/fulltext_native.php | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index d4c1bbc4b9..594799e856 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -720,6 +720,68 @@ class fulltext_native extends \phpbb\search\base $sql_where[] = $post_visibility; + $search_query = $this->search_query; + $must_exclude_one_ids = $this->must_exclude_one_ids; + $must_not_contain_ids = $this->must_not_contain_ids; + $must_contain_ids = $this->must_contain_ids; + + /** + * Allow changing the query used for counting for posts using fulltext_native + * + * @event core.search_native_keywords_count_query_before + * @var string search_query The parsed keywords used for this search + * @var array must_not_contain_ids Ids that cannot be taken into account for the results + * @var array must_exclude_one_ids Ids that cannot be on the results + * @var array must_contain_ids Ids that must be on the results + * @var int result_count The previous result count for the format of the query + * Set to 0 to force a re-count + * @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED + * @var array author_ary Array of user_id containing the users to filter the results to + * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) + * @var array ex_fid_ary Which forums not to search on + * @var int topic_id Limit the search to this topic_id only + * @var string sql_sort_table Extra tables to include in the SQL query. + * Used in conjunction with sql_sort_join + * @var string sql_sort_join SQL conditions to join all the tables used together. + * Used in conjunction with sql_sort_table + * @var int sort_days Time, in days, of the oldest possible post to list + * @var string sql_where An array of the current WHERE clause conditions + * @var string sql_match Which columns to do the search on + * @var string sql_match_where Extra conditions to use to properly filter the matching process + * @var string group_by Whether or not the SQL query requires a GROUP BY for the elements in the SELECT clause + * @var string sort_by_sql The possible predefined sort types + * @var string sort_key The sort type used from the possible sort types + * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used + * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir + * @var int start How many posts to skip in the search results (used for pagination) + * @since 3.1.4-RC1 + */ + $vars = array( + 'search_query', + 'must_not_contain_ids', + 'must_exclude_one_ids', + 'must_contain_ids', + 'result_count', + 'join_topic', + 'author_ary', + 'author_name', + 'ex_fid_ary', + 'topic_id', + 'sql_sort_table', + 'sql_sort_join', + 'sort_days', + 'sql_where', + 'sql_match', + 'sql_match_where', + 'group_by', + 'sort_by_sql', + 'sort_key', + 'sort_dir', + 'sql_sort', + 'start', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_native_keywords_count_query_before', compact($vars))); + if ($topic_id) { $sql_where[] = 'p.topic_id = ' . $topic_id; From d5dd9c929d7d65d954bf1f85149c48d332463b42 Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 10 Mar 2015 22:55:17 +0000 Subject: [PATCH 036/239] [ticket/13689] Allow modifying the query for postgres native fulltext search PHPBB3-13689 --- phpBB/phpbb/search/fulltext_postgres.php | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 9425719c29..927a00164b 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -417,6 +417,55 @@ class fulltext_postgres extends \phpbb\search\base break; } + $tsearch_query = $this->tsearch_query; + + /** + * Allow changing the query used to search for posts using fulltext_postgres + * + * @event core.search_postgres_keywords_main_query_before + * @var string tsearch_query The parsed keywords used for this search + * @var int result_count The previous result count for the format of the query. + * Set to 0 to force a re-count + * @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED + * @var array author_ary Array of user_id containing the users to filter the results to + * @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant) + * @var array ex_fid_ary Which forums not to search on + * @var int topic_id Limit the search to this topic_id only + * @var string sql_sort_table Extra tables to include in the SQL query. + * Used in conjunction with sql_sort_join + * @var string sql_sort_join SQL conditions to join all the tables used together. + * Used in conjunction with sql_sort_table + * @var int sort_days Time, in days, of the oldest possible post to list + * @var string sql_match Which columns to do the search on. + * @var string sql_match_where Extra conditions to use to properly filter the matching process + * @var string sort_by_sql The possible predefined sort types + * @var string sort_key The sort type used from the possible sort types + * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used + * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir + * @var int start How many posts to skip in the search results (used for pagination) + * @since 3.1.4-RC1 + */ + $vars = array( + 'tsearch_query', + 'result_count', + 'join_topic', + 'author_ary', + 'author_name', + 'ex_fid_ary', + 'topic_id', + 'sql_sort_table', + 'sql_sort_join', + 'sort_days', + 'sql_match', + 'sql_match_where', + 'sort_by_sql', + 'sort_key', + 'sort_dir', + 'sql_sort', + 'start', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_keywords_main_query_before', compact($vars))); + $sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id'; $sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : ''; $field = ($type == 'posts') ? 'post_id' : 'topic_id'; From 1a001fc233f4d4e1bfae2c5e6161d96577c30ad9 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 11 Mar 2015 18:28:24 +0000 Subject: [PATCH 037/239] [ticket/13691] Allow changing query to search for posts by author in native PHPBB3-13691 --- phpBB/phpbb/search/fulltext_native.php | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index d4c1bbc4b9..0e1db9ee05 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -983,6 +983,49 @@ class fulltext_native extends \phpbb\search\base $select = ($type == 'posts') ? 'p.post_id' : 't.topic_id'; $is_mysql = false; + /** + * Allow changing the query used to search for posts by author in fulltext_native + * + * @event core.search_native_author_count_query_before + * @var int total_results The previous result count for the format of the query. + * Set to 0 to force a re-count + * @var string select SQL SELECT clause for what to get + * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen + * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table + * @var array sql_author SQL WHERE condition for the post author ids + * @var int topic_id Limit the search to this topic_id only + * @var string sort_by_sql The possible predefined sort types + * @var string sort_key The sort type used from the possible sort types + * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used + * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir + * @var string sort_days Time, in days, that the oldest post showing can have + * @var string sql_time The SQL to search on the time specifyed by sort_days + * @var bool firstpost_only Wether or not to search only on the first post of the topics + * @var array ex_fid_ary Forum ids that must not be searched on + * @var array sql_fora SQL query for ex_fid_ary + * @var int start How many posts to skip in the search results (used for pagination) + * @since 3.1.4-RC1 + */ + $vars = array( + 'total_results', + 'select', + 'sql_sort_table', + 'sql_sort_join', + 'sql_author', + 'topic_id', + 'sort_by_sql', + 'sort_key', + 'sort_dir', + 'sql_sort', + 'sort_days', + 'sql_time', + 'firstpost_only', + 'ex_fid_ary', + 'sql_fora', + 'start', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_native_author_count_query_before', compact($vars))); + // If the cache was completely empty count the results if (!$total_results) { From 29ccbd8098a9884c4389d902963dadcaf3a7448e Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 11 Mar 2015 22:12:47 +0000 Subject: [PATCH 038/239] [ticket/13693] Allow modifying the MySQL author search query PHPBB3-13693 --- phpBB/phpbb/search/fulltext_mysql.php | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 5ca39f1683..f0ac875d0e 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -628,6 +628,55 @@ class fulltext_mysql extends \phpbb\search\base $m_approve_fid_sql = ' AND ' . $post_visibility; + /** + * Allow changing the query used to search for posts by author in fulltext_mysql + * + * @event core.search_mysql_author_query_before + * @var int result_count The previous result count for the format of the query. + * Set to 0 to force a re-count + * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen + * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table + * @var array author_ary Array of user_id containing the users to filter the results to + * @var string author_name An extra username to search on + * @var string sql_author SQL WHERE condition for the post author ids + * @var int topic_id Limit the search to this topic_id only + * @var string sql_topic_id SQL of topic_id + * @var string sort_by_sql The possible predefined sort types + * @var string sort_key The sort type used from the possible sort types + * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used + * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir + * @var string sort_days Time, in days, that the oldest post showing can have + * @var string sql_time The SQL to search on the time specifyed by sort_days + * @var bool firstpost_only Wether or not to search only on the first post of the topics + * @var array ex_fid_ary Forum ids that must not be searched on + * @var array sql_fora SQL query for ex_fid_ary + * @var string m_approve_fid_sql WHERE clause condition on post_visibility restrictions + * @var int start How many posts to skip in the search results (used for pagination) + * @since 3.1.4-RC1 + */ + $vars = array( + 'result_count', + 'sql_sort_table', + 'sql_sort_join', + 'author_ary', + 'author_name', + 'sql_author', + 'topic_id', + 'sql_topic_id', + 'sort_by_sql', + 'sort_key', + 'sort_dir', + 'sql_sort', + 'sort_days', + 'sql_time', + 'firstpost_only', + 'ex_fid_ary', + 'sql_fora', + 'm_approve_fid_sql', + 'start', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_author_query_before', compact($vars))); + // If the cache was completely empty count the results $calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS '; From cfdaf2d63fd9ae4489dc9b63c5a04705d779bd86 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 11 Mar 2015 19:58:23 +0000 Subject: [PATCH 039/239] [ticket/13694] Allow modifying the Postgres native author search query PHPBB3-13694 --- phpBB/phpbb/search/fulltext_postgres.php | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 9425719c29..1ba1edfc2c 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -603,6 +603,55 @@ class fulltext_postgres extends \phpbb\search\base $m_approve_fid_sql = ' AND ' . $post_visibility; + /** + * Allow changing the query used to search for posts by author in fulltext_postgres + * + * @event core.search_postgres_author_count_query_before + * @var int result_count The previous result count for the format of the query. + * Set to 0 to force a re-count + * @var string sql_sort_table CROSS JOIN'ed table to allow doing the sort chosen + * @var string sql_sort_join Condition to define how to join the CROSS JOIN'ed table specifyed in sql_sort_table + * @var array author_ary Array of user_id containing the users to filter the results to + * @var string author_name An extra username to search on + * @var string sql_author SQL WHERE condition for the post author ids + * @var int topic_id Limit the search to this topic_id only + * @var string sql_topic_id SQL of topic_id + * @var string sort_by_sql The possible predefined sort types + * @var string sort_key The sort type used from the possible sort types + * @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used + * @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir + * @var string sort_days Time, in days, that the oldest post showing can have + * @var string sql_time The SQL to search on the time specifyed by sort_days + * @var bool firstpost_only Wether or not to search only on the first post of the topics + * @var array ex_fid_ary Forum ids that must not be searched on + * @var array sql_fora SQL query for ex_fid_ary + * @var string m_approve_fid_sql WHERE clause condition on post_visibility restrictions + * @var int start How many posts to skip in the search results (used for pagination) + * @since 3.1.4-RC1 + */ + $vars = array( + 'result_count', + 'sql_sort_table', + 'sql_sort_join', + 'author_ary', + 'author_name', + 'sql_author', + 'topic_id', + 'sql_topic_id', + 'sort_by_sql', + 'sort_key', + 'sort_dir', + 'sql_sort', + 'sort_days', + 'sql_time', + 'firstpost_only', + 'ex_fid_ary', + 'sql_fora', + 'm_approve_fid_sql', + 'start', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_author_count_query_before', compact($vars))); + // Build the query for really selecting the post_ids if ($type == 'posts') { From 0a52d732e4321d8b5375fd14461db9c463ad5af3 Mon Sep 17 00:00:00 2001 From: Crizzo Date: Fri, 13 Mar 2015 22:17:11 +0100 Subject: [PATCH 040/239] [ticket/13701] Adds two new events to posting_pm_layout.html These events wrap the includes of posting_pm_header.html to add some content before and after it. PHPBB3-13701 --- phpBB/docs/events.md | 14 ++++++++++++++ .../prosilver/template/posting_pm_layout.html | 2 ++ 2 files changed, 16 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 5c4b6a8d7d..fd6cfdfeaa 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -976,6 +976,20 @@ posting_pm_header_find_username_before * Since: 3.1.0-RC4 * Purpose: Add content before the find username link on composing pm +posting_pm_layout_include_pm_header_after +=== +* Locations: + + styles/prosilver/template/posting_pm_layout.html +* Since: 3.1.4-RC1 +* Purpose: Add content after the include of posting_pm_header.html + +posting_pm_layout_include_pm_header_before +=== +* Locations: + + styles/prosilver/template/posting_pm_layout.html +* Since: 3.1.4-RC1 +* Purpose: Add content before the include of posting_pm_header.html + quickreply_editor_panel_after === * Locations: diff --git a/phpBB/styles/prosilver/template/posting_pm_layout.html b/phpBB/styles/prosilver/template/posting_pm_layout.html index 3bdadd06ca..7f4a0ea8d7 100644 --- a/phpBB/styles/prosilver/template/posting_pm_layout.html +++ b/phpBB/styles/prosilver/template/posting_pm_layout.html @@ -19,7 +19,9 @@
+ +
From d4ca81f23f7a5bbb05b8e05834cf4775afa6e316 Mon Sep 17 00:00:00 2001 From: RMcGirr83 Date: Wed, 18 Mar 2015 10:45:58 -0400 Subject: [PATCH 041/239] [ticket/13710] Allow template events near smilies display PHPBB3-13710 --- phpBB/docs/events.md | 24 +++++++++++++++++++ .../prosilver/template/posting_editor.html | 4 +++- .../subsilver2/template/posting_body.html | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 5c4b6a8d7d..954128f20b 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -896,6 +896,14 @@ overall_header_stylesheets_after * Purpose: Add asset calls after stylesheets within the `` tag. Note that INCLUDECSS will not work with this event. +posting_editor_bbcode_status_after +=== +* Locations: + + styles/prosilver/template/posting_editor.html + + styles/subsilver2/template/posting_body.html +* Since: 3.1.4-RC1 +* Purpose: Add content after bbcode status + posting_editor_buttons_after === * Locations: @@ -944,6 +952,22 @@ posting_editor_options_prepend * Since: 3.1.0-a1 * Purpose: Add posting options on the posting screen +posting_editor_smilies_after +=== +* Locations: + + styles/prosilver/template/posting_editor.html + + styles/subsilver2/template/posting_body.html +* Since: 3.1.4-RC1 +* Purpose: Add content after smilies + +posting_editor_smilies_before +=== +* Locations: + + styles/prosilver/template/posting_editor.html + + styles/subsilver2/template/posting_body.html +* Since: 3.1.4-RC1 +* Purpose: Add content before the smilies + posting_editor_subject_after === * Locations: diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index e68e6a97e5..5804f95579 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -36,6 +36,7 @@
+ {L_SMILIES}
@@ -45,7 +46,7 @@
{L_MORE_SMILIES} - +

@@ -58,6 +59,7 @@ {SMILIES_STATUS}
+
{L_BACK_TO_DRAFTS} diff --git a/phpBB/styles/subsilver2/template/posting_body.html b/phpBB/styles/subsilver2/template/posting_body.html index 321e4227ee..815d8c4a99 100644 --- a/phpBB/styles/subsilver2/template/posting_body.html +++ b/phpBB/styles/subsilver2/template/posting_body.html @@ -171,6 +171,7 @@ {L_MESSAGE_BODY}{L_COLON}
{L_MESSAGE_BODY_EXPLAIN} 

+ @@ -192,6 +193,7 @@
+ + From 3ec3dfcf3ad63ac52383ad74b8b346f0d177bcab Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 May 2015 14:58:46 +0200 Subject: [PATCH 156/239] [ticket/13878] Display background images when printing topic in webkit PHPBB3-13878 --- phpBB/styles/prosilver/theme/common.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index c0cc2bb2dd..7b17c58698 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -59,6 +59,7 @@ body { margin: 0; padding: 12px 0; word-wrap: break-word; + -webkit-print-color-adjust: exact; } h1 { From 8b6c6e794a4233daf82b017d3d23fd7e0bf1ebaa Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 28 May 2015 15:57:31 +0200 Subject: [PATCH 157/239] [ticket/13879] Replaced px with em where appropriate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're using ems basically everywhere else so ¯\_(ツ)_/¯ PHPBB3-13879 --- phpBB/styles/prosilver/theme/buttons.css | 3 +-- phpBB/styles/prosilver/theme/common.css | 19 ++++++++----------- phpBB/styles/prosilver/theme/cp.css | 6 +++--- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index f9a520369e..a816c7f7f2 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -5,8 +5,7 @@ cursor: pointer; display: inline-block; height: 18px; - line-height: 18px; - font-size: 13px; + font-size: 1.2em; white-space: nowrap; border: 1px solid transparent; border-radius: 4px; diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index c0cc2bb2dd..73d1f2c7c0 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -326,10 +326,9 @@ ul.linklist li.responsive-menu { ul.linklist li.responsive-menu a.responsive-menu-link { display: inline-block; margin: 0 5px; - font-size: 16px; position: relative; width: 16px; - line-height: 20px; + line-height: 1.2em; text-decoration: none; } @@ -798,7 +797,7 @@ fieldset.fields1 dl.pmlist dd.recipients { /* Action-bars (container for post/reply buttons, pagination, etc.) ---------------------------------------- */ .action-bar { - font-size: 11px; + font-size: 1.1em; margin: 4px 0; } @@ -810,7 +809,6 @@ fieldset.fields1 dl.pmlist dd.recipients { ---------------------------------------- */ .pagination { float: right; - font-size: 11px; margin-top: 3px; text-align: right; width: auto; @@ -840,7 +838,7 @@ fieldset.fields1 dl.pmlist dd.recipients { display: block; font-size: 0.9em; font-weight: normal; - line-height: 13px; + line-height: 1.4em; min-width: 10px; padding: 3px; text-align: center; @@ -1155,12 +1153,11 @@ ul.linklist:after, .dropdown-extended .header { padding: 0 10px; font-family: Arial, "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 11px; font-weight: bold; text-align: left; text-shadow: 1px 1px 1px white; text-transform: uppercase; - line-height: 30px; + line-height: 3em; border-bottom: 1px solid; border-radius: 5px 5px 0 0; } @@ -1212,7 +1209,7 @@ ul.linklist:after, } .notification_list p.notification-time { - font-size: 10px; + font-size: 0.9em; margin: 0; text-align: right; } @@ -1228,7 +1225,7 @@ ul.linklist:after, .notification_list p.notifications_title { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; - font-size: 13px !important; + font-size: 1.2em !important; } .notification_list p.notifications_title strong { @@ -1236,7 +1233,7 @@ ul.linklist:after, } .notification_list p.notifications_time { - font-size: 10px !important; + font-size: 0.9em !important; } .notification_text { @@ -1259,7 +1256,7 @@ ul.linklist:after, } #quick-links a.responsive-menu-link:before { - font-size: 16px; + font-size: 1.6em; line-height: 16.5px; } diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css index 81b6d9bf64..8a223f653f 100644 --- a/phpBB/styles/prosilver/theme/cp.css +++ b/phpBB/styles/prosilver/theme/cp.css @@ -114,7 +114,7 @@ ul.cplist { float: left; font-size: 1em; font-weight: bold; - line-height: 14px; + line-height: 1.4em; } #tabs .tab > a, #minitabs .tab > a { @@ -172,10 +172,10 @@ ul.cplist { .responsive-tab > a.responsive-tab-link { display: block; - font-size: 16px; + font-size: 1.6em; position: relative; width: 16px; - line-height: 14px; + line-height: 0.9em; text-decoration: none; } From 44fcdd007fd82dbedf3188a035075416818161ab Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 28 May 2015 16:01:35 +0200 Subject: [PATCH 158/239] [ticket/13876] set webfont async to true PHPBB3-13876 --- phpBB/styles/prosilver/template/overall_header.html | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 0f3e983718..4e2013e276 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -38,6 +38,7 @@ (function(d) { var wf = d.createElement('script'), s = d.scripts[0]; wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.5.18/webfont.js'; + wf.async = true; s.parentNode.insertBefore(wf, s); })(document); From be1d1c7d05a0b0dec259da967e2ed277fb8f632f Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 28 May 2015 18:05:07 +0200 Subject: [PATCH 159/239] [ticket/13882] Lazy load the notification avatars. This moves them further down the waterfall, making the page load quicker. PHPBB3-13882 --- phpBB/assets/javascript/core.js | 12 ++++++++++ phpBB/includes/functions.php | 23 +++++++++++++++++-- phpBB/includes/functions_compatibility.php | 5 ++-- .../notification/type/admin_activate_user.php | 2 +- .../phpbb/notification/type/group_request.php | 2 +- phpBB/phpbb/notification/type/pm.php | 2 +- phpBB/phpbb/notification/type/post.php | 2 +- phpBB/phpbb/notification/type/report_pm.php | 2 +- .../notification/type/report_pm_closed.php | 2 +- phpBB/phpbb/notification/type/report_post.php | 2 +- .../notification/type/report_post_closed.php | 2 +- phpBB/phpbb/notification/type/topic.php | 2 +- phpBB/phpbb/user_loader.php | 5 ++-- 13 files changed, 48 insertions(+), 15 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 9eb931270a..819e9329a4 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1612,6 +1612,18 @@ phpbb.registerPageDropdowns = function() { }); }; +phpbb.lazyLoadAvatars = function loadAvatars() { + $('.avatar[data-src]').each(function () { + var $avatar = $(this); + + $avatar + .attr('src', $avatar.data('src')) + .removeAttr('data-src'); + }); +}; + +$(window).load(phpbb.lazyLoadAvatars); + /** * Apply code editor to all textarea elements with data-bbcode attribute */ diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d460497669..b3da9c4e5d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4809,10 +4809,11 @@ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config * @param array $row Row cleaned by \phpbb\avatar\manager::clean_row * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* @param bool $lazy If true, will be lazy loaded (requires JS) * * @return string Avatar html */ -function phpbb_get_avatar($row, $alt, $ignore_config = false) +function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; global $request; @@ -4850,7 +4851,25 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false) if (!empty($avatar_data['src'])) { - $html = 'get('path_helper'); + $corrected_path = $phpbb_path_helper->get_web_root_path(); + + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; + + $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme'; + + $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"'; + } else { + $src = 'src="' . $avatar_data['src'] . '"'; + } + + $html = ''; diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 43952ae57a..b59c7376e9 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -30,10 +30,11 @@ if (!defined('IN_PHPBB')) * @param string $avatar_height Height of users avatar * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* @param bool $lazy If true, will be lazy loaded (requires JS) * * @return string Avatar image */ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false) { // map arguments to new function phpbb_get_avatar() $row = array( @@ -43,7 +44,7 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ 'avatar_height' => $avatar_height, ); - return phpbb_get_avatar($row, $alt, $ignore_config); + return phpbb_get_avatar($row, $alt, $ignore_config, $lazy); } /** diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php index dfc0157558..7c5c18aa47 100644 --- a/phpBB/phpbb/notification/type/admin_activate_user.php +++ b/phpBB/phpbb/notification/type/admin_activate_user.php @@ -104,7 +104,7 @@ class admin_activate_user extends \phpbb\notification\type\base */ public function get_avatar() { - return $this->user_loader->get_avatar($this->item_id); + return $this->user_loader->get_avatar($this->item_id, false, true); } /** diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php index 4baf516fed..96bfc86322 100644 --- a/phpBB/phpbb/notification/type/group_request.php +++ b/phpBB/phpbb/notification/type/group_request.php @@ -96,7 +96,7 @@ class group_request extends \phpbb\notification\type\base */ public function get_avatar() { - return $this->user_loader->get_avatar($this->item_id); + return $this->user_loader->get_avatar($this->item_id, false, true); } /** diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php index 330a70c85a..d2f34f95d0 100644 --- a/phpBB/phpbb/notification/type/pm.php +++ b/phpBB/phpbb/notification/type/pm.php @@ -100,7 +100,7 @@ class pm extends \phpbb\notification\type\base */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('from_user_id')); + return $this->user_loader->get_avatar($this->get_data('from_user_id'), false, true); } /** diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 421eff6372..e25fdcd808 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -165,7 +165,7 @@ class post extends \phpbb\notification\type\base */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('poster_id')); + return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true); } /** diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php index d39143f4b7..749cfe0b8e 100644 --- a/phpBB/phpbb/notification/type/report_pm.php +++ b/phpBB/phpbb/notification/type/report_pm.php @@ -223,7 +223,7 @@ class report_pm extends \phpbb\notification\type\pm */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('reporter_id')); + return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true); } /** diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index 9f301ee2cc..1c99db60c3 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -130,7 +130,7 @@ class report_pm_closed extends \phpbb\notification\type\pm */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('closer_id')); + return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true); } /** diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index 027cca716b..aed31e8642 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -196,7 +196,7 @@ class report_post extends \phpbb\notification\type\post_in_queue */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('reporter_id')); + return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true); } /** diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index a0bb187a0d..3f4378628b 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -137,7 +137,7 @@ class report_post_closed extends \phpbb\notification\type\post */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('closer_id')); + return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true); } /** diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 5f57087b73..fb08a9eee1 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -119,7 +119,7 @@ class topic extends \phpbb\notification\type\base */ public function get_avatar() { - return $this->user_loader->get_avatar($this->get_data('poster_id')); + return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true); } /** diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php index 24e663b150..5ce8ca2d4d 100644 --- a/phpBB/phpbb/user_loader.php +++ b/phpBB/phpbb/user_loader.php @@ -179,9 +179,10 @@ class user_loader * @param bool $query Should we query the database if this user has not yet been loaded? * Typically this should be left as false and you should make sure * you load users ahead of time with load_users() + * @param bool @lazy If true, will be lazy loaded (requires JS) * @return string */ - public function get_avatar($user_id, $query = false) + public function get_avatar($user_id, $query = false, $lazy = false) { if (!($user = $this->get_user($user_id, $query))) { @@ -193,7 +194,7 @@ class user_loader include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); } - return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height']); + return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height'], 'USER_AVATAR', false, $lazy); } /** From 2a83290e7c3f143790e6703dbe26ba914852e3e7 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 29 May 2015 12:09:19 +0200 Subject: [PATCH 160/239] [ticket/13887] Use correct JSDoc syntax PHPBB3-13887 --- phpBB/assets/javascript/core.js | 200 +++++++++++------------- phpBB/assets/javascript/plupload.js | 114 +++++--------- phpBB/styles/prosilver/template/ajax.js | 4 +- 3 files changed, 128 insertions(+), 190 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 9eb931270a..93a21eb203 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -21,7 +21,7 @@ phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); /** * Display a loading screen * - * @returns object Returns loadingIndicator. + * @returns {object} Returns loadingIndicator. */ phpbb.loadingIndicator = function() { if (!$loadingIndicator.is(':visible')) { @@ -54,7 +54,7 @@ phpbb.clearLoadingTimeout = function() { /** * Close popup alert after a specified delay * -* @param int Delay in ms until darkenwrapper's click event is triggered +* @param {int} delay Delay in ms until darkenwrapper's click event is triggered */ phpbb.closeDarkenWrapper = function(delay) { phpbbAlertTimer = setTimeout(function() { @@ -67,14 +67,12 @@ phpbb.closeDarkenWrapper = function(delay) { * * You can only call one alert or confirm box at any one time. * - * @param string title Title of the message, eg "Information" (HTML). - * @param string msg Message to display (HTML). - * @param bool fadedark Remove the dark background when done? Defaults - * to yes. + * @param {string} title Title of the message, eg "Information" (HTML). + * @param {string} msg Message to display (HTML). * - * @returns object Returns the div created. + * @returns {object} Returns the div created. */ -phpbb.alert = function(title, msg, fadedark) { +phpbb.alert = function(title, msg) { var $alert = $('#phpbb_alert'); $alert.find('.alert_title').html(title); $alert.find('.alert_text').html(msg); @@ -94,7 +92,7 @@ phpbb.alert = function(title, msg, fadedark) { /** * Handler for opening an alert box. * -* @param jQuery $alert jQuery object. +* @param {jQuery} $alert jQuery object. */ phpbb.alert.open = function($alert) { if (!$dark.is(':visible')) { @@ -134,8 +132,8 @@ phpbb.alert.open = function($alert) { /** * Handler for closing an alert box. * -* @param jQuery $alert jQuery object. -* @param bool fadedark Whether to remove dark background. +* @param {jQuery} $alert jQuery object. +* @param {bool} fadedark Whether to remove dark background. */ phpbb.alert.close = function($alert, fadedark) { var $fade = (fadedark) ? $dark : $alert; @@ -153,13 +151,13 @@ phpbb.alert.close = function($alert, fadedark) { * * You can only call one alert or confirm box at any one time. * - * @param string msg Message to display (HTML). - * @param function callback Callback. Bool param, whether the user pressed + * @param {string} msg Message to display (HTML). + * @param {function} callback Callback. Bool param, whether the user pressed * yes or no (or whatever their language is). - * @param bool fadedark Remove the dark background when done? Defaults + * @param {bool} fadedark Remove the dark background when done? Defaults * to yes. * - * @returns object Returns the div created. + * @returns {object} Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { var $confirmDiv = $('#phpbb_confirm'); @@ -197,9 +195,9 @@ phpbb.confirm = function(msg, callback, fadedark) { /** * Turn a querystring into an array. * - * @argument string string The querystring to parse. - * @returns object The object created. - */ + * @argument {string} string The querystring to parse. + * @returns {object} The object created. + */{} phpbb.parseQuerystring = function(string) { var params = {}, i, split; @@ -223,12 +221,7 @@ phpbb.parseQuerystring = function(string) { * For more info, view the following page on the phpBB wiki: * http://wiki.phpbb.com/JavaScript_Function.phpbb.ajaxify * - * @param object options Options. - * @param bool/function refresh If we are sent back a refresh, should it be - * acted upon? This can either be true / false / a function. - * @param function callback Callback to call on completion of event. Has - * three parameters: the element that the event was evoked from, the JSON - * that was returned and (if it is a form) the form action. + * @param {object} options Options. */ phpbb.ajaxify = function(options) { var $elements = $(options.selector), @@ -283,7 +276,7 @@ phpbb.ajaxify = function(options) { * It cannot be called from outside this function, and is purely here to * avoid repetition of code. * - * @param object res The object sent back by the server. + * @param {object} res The object sent back by the server. */ function returnHandler(res) { var alert; @@ -429,8 +422,8 @@ phpbb.search = { /** * Get cached search data. * - * @param string id Search ID. - * @return bool|object. Cached data object. Returns false if no data exists. + * @param {string} id Search ID. + * @returns {bool|object} Cached data object. Returns false if no data exists. */ phpbb.search.cache.get = function(id) { if (this.data[id]) { @@ -442,11 +435,9 @@ phpbb.search.cache.get = function(id) { /** * Set search cache data value. * - * @param string id Search ID. - * @param string key Data key. - * @param string value Data value. - * - * @return undefined + * @param {string} id Search ID. + * @param {string} key Data key. + * @param {string} value Data value. */ phpbb.search.cache.set = function(id, key, value) { if (!this.data[id]) { @@ -458,21 +449,19 @@ phpbb.search.cache.set = function(id, key, value) { /** * Cache search result. * - * @param string id Search ID. - * @param string keyword Keyword. - * @param array results Search results. - * - * @return undefined + * @param {string} id Search ID. + * @param {string} keyword Keyword. + * @param {Array} results Search results. */ -phpbb.search.cache.setResults = function(id, keyword, value) { - this.data[id].results[keyword] = value; +phpbb.search.cache.setResults = function(id, keyword, results) { + this.data[id].results[keyword] = results; }; /** * Trim spaces from keyword and lower its case. * - * @param string keyword Search keyword to clean. - * @return string Cleaned string. + * @param {string} keyword Search keyword to clean. + * @returns {string} Cleaned string. */ phpbb.search.cleanKeyword = function(keyword) { return $.trim(keyword).toLowerCase(); @@ -482,11 +471,11 @@ phpbb.search.cleanKeyword = function(keyword) { * Get clean version of search keyword. If textarea supports several keywords * (one per line), it fetches the current keyword based on the caret position. * - * @param jQuery $input Search input|textarea. - * @param string keyword Input|textarea value. - * @param bool multiline Whether textarea supports multiple search keywords. + * @param {jQuery} $input Search input|textarea. + * @param {string} keyword Input|textarea value. + * @param {bool} multiline Whether textarea supports multiple search keywords. * - * @return string Clean string. + * @returns string Clean string. */ phpbb.search.getKeyword = function($input, keyword, multiline) { if (multiline) { @@ -500,8 +489,8 @@ phpbb.search.getKeyword = function($input, keyword, multiline) { * Get the textarea line number on which the keyword resides - for textareas * that support multiple keywords (one per line). * - * @param jQuery $textarea Search textarea. - * @return int + * @param {jQuery} $textarea Search textarea. + * @returns {int} The line number. */ phpbb.search.getKeywordLine = function ($textarea) { var selectionStart = $textarea.get(0).selectionStart; @@ -512,11 +501,9 @@ phpbb.search.getKeywordLine = function ($textarea) { * Set the value on the input|textarea. If textarea supports multiple * keywords, only the active keyword is replaced. * - * @param jQuery $input Search input|textarea. - * @param string value Value to set. - * @param bool multiline Whether textarea supports multiple search keywords. - * - * @return undefined + * @param {jQuery} $input Search input|textarea. + * @param {string} value Value to set. + * @param {bool} multiline Whether textarea supports multiple search keywords. */ phpbb.search.setValue = function($input, value, multiline) { if (multiline) { @@ -531,12 +518,10 @@ phpbb.search.setValue = function($input, value, multiline) { /** * Sets the onclick event to set the value on the input|textarea to the selected search result. * - * @param jQuery $input Search input|textarea. - * @param object value Result object. - * @param jQuery $row Result element. - * @param jQuery $container jQuery object for the search container. - * - * @return undefined + * @param {jQuery} $input Search input|textarea. + * @param {object} value Result object. + * @param {jQuery} $row Result element. + * @param {jQuery} $container jQuery object for the search container. */ phpbb.search.setValueOnClick = function($input, value, $row, $container) { $row.click(function() { @@ -551,11 +536,11 @@ phpbb.search.setValueOnClick = function($input, value, $row, $container) { * already, those are displayed instead. Executes the AJAX request function * itself due to the need to use a timeout to limit the number of requests. * - * @param array data Data to be sent to the server. - * @param object event Onkeyup event object. - * @param function sendRequest Function to execute AJAX request. + * @param {Array} data Data to be sent to the server. + * @param {object} event Onkeyup event object. + * @param {function} sendRequest Function to execute AJAX request. * - * @return bool Returns false. + * @returns {bool} Returns false. */ phpbb.search.filter = function(data, event, sendRequest) { var $this = $(this), @@ -609,12 +594,10 @@ phpbb.search.filter = function(data, event, sendRequest) { /** * Handle search result response. * - * @param object res Data received from server. - * @param jQuery $input Search input|textarea. - * @param bool fromCache Whether the results are from the cache. - * @param function callback Optional callback to run when assigning each search result. - * - * @return undefined + * @param {object} res Data received from server. + * @param {jQuery} $input Search input|textarea. + * @param {bool} fromCache Whether the results are from the cache. + * @param {function} callback Optional callback to run when assigning each search result. */ phpbb.search.handleResponse = function(res, $input, fromCache, callback) { if (typeof res !== 'object') { @@ -641,12 +624,10 @@ phpbb.search.handleResponse = function(res, $input, fromCache, callback) { /** * Show search results. * - * @param array results Search results. - * @param jQuery $input Search input|textarea. - * @param jQuery $container Search results container element. - * @param function callback Optional callback to run when assigning each search result. - * - * @return undefined + * @param {Array} results Search results. + * @param {jQuery} $input Search input|textarea. + * @param {jQuery} $container Search results container element. + * @param {function} callback Optional callback to run when assigning each search result. */ phpbb.search.showResults = function(results, $input, $container, callback) { var $resultContainer = $('.search-results', $container); @@ -683,8 +664,7 @@ phpbb.search.showResults = function(results, $input, $container, callback) { /** * Clear search results. * - * @param jQuery $container Search results container. - * @return undefined + * @param {jQuery} $container Search results container. */ phpbb.search.clearResults = function($container) { $container.children(':not(.search-result-tpl)').remove(); @@ -703,8 +683,8 @@ phpbb.history = {}; /** * Check whether a method in the native history object is supported. * -* @param string fn Method name. -* @return bool Returns true if the method is supported. +* @param {string} fn Method name. +* @returns {bool} Returns true if the method is supported. */ phpbb.history.isSupported = function(fn) { return !(typeof history === 'undefined' || typeof history[fn] === 'undefined'); @@ -714,12 +694,10 @@ phpbb.history.isSupported = function(fn) { * Wrapper for the pushState and replaceState methods of the * native history object. * -* @param string mode Mode. Either push or replace. -* @param string url New URL. -* @param string title Optional page title. -* @patam object obj Optional state object. -* -* @return undefined +* @param {string} mode Mode. Either push or replace. +* @param {string} url New URL. +* @param {string} [title] Optional page title. +* @param {object} [obj] Optional state object. */ phpbb.history.alterUrl = function(mode, url, title, obj) { var fn = mode + 'State'; @@ -740,11 +718,9 @@ phpbb.history.alterUrl = function(mode, url, title, obj) { /** * Wrapper for the native history.replaceState method. * -* @param string url New URL. -* @param string title Optional page title. -* @patam object obj Optional state object. -* -* @return undefined +* @param {string} url New URL. +* @param {string} [title] Optional page title. +* @param {object} [obj] Optional state object. */ phpbb.history.replaceUrl = function(url, title, obj) { phpbb.history.alterUrl('replace', url, title, obj); @@ -753,11 +729,9 @@ phpbb.history.replaceUrl = function(url, title, obj) { /** * Wrapper for the native history.pushState method. * -* @param string url New URL. -* @param string title Optional page title. -* @patam object obj Optional state object. -* -* @return undefined +* @param {string} url New URL. +* @param {string} [title] Optional page title. +* @param {object} [obj] Optional state object. */ phpbb.history.pushUrl = function(url, title, obj) { phpbb.history.alterUrl('push', url, title, obj); @@ -766,7 +740,8 @@ phpbb.history.pushUrl = function(url, title, obj) { /** * Hide the optgroups that are not the selected timezone * -* @param bool keepSelection Shall we keep the value selected, or shall the user be forced to repick one. +* @param {bool} keepSelection Shall we keep the value selected, or shall the +* user be forced to repick one. */ phpbb.timezoneSwitchDate = function(keepSelection) { var $timezoneCopy = $('#timezone_copy'); @@ -824,7 +799,7 @@ phpbb.timezoneEnableDateSelection = function() { /** * Preselect a date/time or suggest one, if it is not picked. * -* @param bool forceSelector Shall we select the suggestion? +* @param {bool} forceSelector Shall we select the suggestion? */ phpbb.timezonePreselectSelect = function(forceSelector) { @@ -893,8 +868,8 @@ phpbb.ajaxCallbacks = {}; * * See the phpbb.ajaxify comments for information on stuff like parameters. * - * @param string id The name of the callback. - * @param function callback The callback to be called. + * @param {string} id The name of the callback. + * @param {function} callback The callback to be called. */ phpbb.addAjaxCallback = function(id, callback) { if (typeof callback === 'function') { @@ -985,7 +960,7 @@ phpbb.addAjaxCallback('toggle_link', function() { * types text. * * @param {jQuery} $items jQuery object(s) to resize -* @param {object} options Optional parameter that adjusts default +* @param {object} [options] Optional parameter that adjusts default * configuration. See configuration variable * * Optional parameters: @@ -1085,7 +1060,7 @@ phpbb.resizeTextArea = function($items, options) { * @param {Array} endTags List of end tags to look for * For example, Array('[/code]') * -* @return {boolean} True if cursor is in bbcode tag +* @returns {boolean} True if cursor is in bbcode tag */ phpbb.inBBCodeTag = function(textarea, startTags, endTags) { var start = textarea.selectionStart, @@ -1157,7 +1132,7 @@ phpbb.applyCodeEditor = function(textarea) { * @param {boolean} stripCodeStart If true, only part of line * after [code] tag will be returned. * - * @return {string} Line of text + * @returns {string} Line of text */ function getLastLine(stripCodeStart) { var start = textarea.selectionStart, @@ -1190,7 +1165,7 @@ phpbb.applyCodeEditor = function(textarea) { /** * Append text at cursor position * - * @param {string} Text Text to append + * @param {string} text Text to append */ function appendText(text) { var start = textarea.selectionStart, @@ -1416,9 +1391,9 @@ phpbb.registerDropdown = function(toggle, dropdown, options) { /** * Get the HTML for a color palette table. * -* @param string dir Palette direction - either v or h -* @param int width Palette cell width. -* @param int height Palette cell height. +* @param {string} dir Palette direction - either v or h +* @param {int} width Palette cell width. +* @param {int} height Palette cell height. */ phpbb.colorPalette = function(dir, width, height) { var r = 0, @@ -1470,7 +1445,7 @@ phpbb.colorPalette = function(dir, width, height) { /** * Register a color palette. * -* @param object el jQuery object for the palette container. +* @param {jQuery} el jQuery object for the palette container. */ phpbb.registerPalette = function(el) { var orientation = el.attr('data-orientation'), @@ -1504,10 +1479,10 @@ phpbb.registerPalette = function(el) { /** * Set display of page element * -* @param string id The ID of the element to change -* @param int action Set to 0 if element display should be toggled, -1 for +* @param {string} id The ID of the element to change +* @param {int} action Set to 0 if element display should be toggled, -1 for * hiding the element, and 1 for showing it. -* @param string type Display type that should be used, e.g. inline, block or +* @param {string} type Display type that should be used, e.g. inline, block or * other CSS "display" types */ phpbb.toggleDisplay = function(id, action, type) { @@ -1528,8 +1503,7 @@ phpbb.toggleDisplay = function(id, action, type) { * Toggle additional settings based on the selected * option of select element. * -* @param jQuery el jQuery select element object. -* @return undefined +* @param {jQuery} el jQuery select element object. */ phpbb.toggleSelectSettings = function(el) { el.children().each(function() { @@ -1543,8 +1517,8 @@ phpbb.toggleSelectSettings = function(el) { * Get function from name. * Based on http://stackoverflow.com/a/359910 * -* @param string functionName Function to get. -* @return function +* @param {string} functionName Function to get. +* @returns function */ phpbb.getFunctionByName = function (functionName) { var namespaces = functionName.split('.'), diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index e0d2e05a84..a80e816569 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -7,8 +7,6 @@ phpbb.plupload.ids = []; /** * Set up the uploader. - * - * @return undefined */ phpbb.plupload.initialize = function() { // Initialize the Plupload uploader. @@ -48,8 +46,6 @@ phpbb.plupload.initialize = function() { /** * Unsets all elements in the object uploader.settings.multipart_params whose keys * begin with 'attachment_data[' - * - * @return undefined */ phpbb.plupload.clearParams = function() { var obj = phpbb.plupload.uploader.settings.multipart_params; @@ -65,8 +61,7 @@ phpbb.plupload.clearParams = function() { /** * Update uploader.settings.multipart_params object with new data. * - * @param object obj - * @return undefined + * @param {object} obj */ phpbb.plupload.updateMultipartParams = function(obj) { phpbb.plupload.uploader.settings.multipart_params = $.extend( @@ -78,7 +73,7 @@ phpbb.plupload.updateMultipartParams = function(obj) { /** * Convert the array of attachment objects into an object that PHP would expect as POST data. * - * @return object An object in the form 'attachment_data[i][key]': value as + * @returns {object} An object in the form 'attachment_data[i][key]': value as * expected by the server */ phpbb.plupload.getSerializedData = function() { @@ -100,9 +95,8 @@ phpbb.plupload.getSerializedData = function() { * Get the index from the phpbb.plupload.data array where the given * attachment id appears. * - * @param int attach_id The attachment id of the file. - * @return bool Returns false if the id cannot be found. - * @return int Returns the index of the file if it exists. + * @param {int} attach_id The attachment id of the file. + * @returns {bool|int} Index of the file if exists, otherwise false. */ phpbb.plupload.getIndex = function(attach_id) { var index = $.inArray(Number(attach_id), phpbb.plupload.ids); @@ -112,10 +106,8 @@ phpbb.plupload.getIndex = function(attach_id) { /** * Set the data in phpbb.plupload.data and phpbb.plupload.ids arrays. * - * @param array data Array containing the new data to use. In the form of + * @param {Array} data Array containing the new data to use. In the form of * array(index => object(property: value). Requires attach_id to be one of the object properties. - * - * @return undefined */ phpbb.plupload.setData = function(data) { // Make sure that the array keys are reset. @@ -130,11 +122,10 @@ phpbb.plupload.setData = function(data) { /** * Update the attachment data in the HTML and the phpbb & phpbb.plupload objects. * - * @param array data Array containing the new data to use. - * @param string action The action that required the update. Used to update the inline attachment bbcodes. - * @param int index The index from phpbb.plupload_ids that was affected by the action. - * @param array downloadUrl Optional array of download urls to update. - * @return undefined + * @param {Array} data Array containing the new data to use. + * @param {string} action The action that required the update. Used to update the inline attachment bbcodes. + * @param {int} index The index from phpbb.plupload_ids that was affected by the action. + * @param {Array} downloadUrl Optional array of download urls to update. */ phpbb.plupload.update = function(data, action, index, downloadUrl) { @@ -148,8 +139,7 @@ phpbb.plupload.update = function(data, action, index, downloadUrl) { /** * Update the relevant elements and hidden data for all attachments. * - * @param array downloadUrl Optional array of download urls to update. - * @return undefined + * @param {Array} downloadUrl Optional array of download urls to update. */ phpbb.plupload.updateRows = function(downloadUrl) { for (var i = 0; i < phpbb.plupload.ids.length; i++) { @@ -163,9 +153,8 @@ phpbb.plupload.updateRows = function(downloadUrl) { * data for the file inserted into it. The row is then appended or prepended to * #file-list based on the attach_order setting. * - * @param object file Plupload file object for the new attachment. - * @return undefined - */ + * @param {object} file Plupload file object for the new attachment. + */{} phpbb.plupload.insertRow = function(file) { var row = $(phpbb.plupload.rowTpl); @@ -183,9 +172,8 @@ phpbb.plupload.insertRow = function(file) { /** * Update the relevant elements and hidden data for an attachment. * - * @param int index The index from phpbb.plupload.ids of the attachment to edit. - * @param array downloadUrl Optional array of download urls to update. - * @return undefined + * @param {int} index The index from phpbb.plupload.ids of the attachment to edit. + * @param {Array} downloadUrl Optional array of download urls to update. */ phpbb.plupload.updateRow = function(index, downloadUrl) { var attach = phpbb.plupload.data[index], @@ -194,7 +182,7 @@ phpbb.plupload.updateRow = function(index, downloadUrl) { // Add the link to the file if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { var url = downloadUrl[index].replace('&', '&'), - link = $(''); + link = ${('}'); link.attr('href', url).html(attach.real_filename); row.find('.file-name').html(link) @@ -207,10 +195,9 @@ phpbb.plupload.updateRow = function(index, downloadUrl) { /** * Update hidden input data for an attachment. * - * @param object row jQuery object for the attachment row. - * @param object attach Attachment data object from phpbb.plupload.data - * @param int index Attachment index from phpbb.plupload.ids - * @return undefined + * @param {object} row jQuery object for the attachment row. + * @param {object} attach Attachment data object from phpbb.plupload.data + * @param {int} index Attachment index from phpbb.plupload.ids */ phpbb.plupload.updateHiddenData = function(row, attach, index) { row.find('input[type="hidden"]').remove(); @@ -230,10 +217,8 @@ phpbb.plupload.updateHiddenData = function(row, attach, index) { * responds with the updated attachment data list so that any future * uploads can maintain state with the server * - * @param object row jQuery object for the attachment row. - * @param int attachId Attachment id of the file to be removed. - * - * @return undefined + * @param {object} row jQuery object for the attachment row. + * @param {int} attachId Attachment id of the file to be removed. */ phpbb.plupload.deleteFile = function(row, attachId) { // If there's no attach id, then the file hasn't been uploaded. Simply delete the row. @@ -300,8 +285,6 @@ phpbb.plupload.deleteFile = function(row, attachId) { /** * Check the attachment list and hide its container if it's empty. - * - * @return undefined */ phpbb.plupload.hideEmptyList = function() { if (!$('#file-list').children().length) { @@ -315,10 +298,8 @@ phpbb.plupload.hideEmptyList = function() { * before the phpbb.plupload,data and phpbb.plupload.ids arrays are updated, otherwise it will * not work correctly. * - * @param string action The action that occurred -- either "addition" or "removal" - * @param int index The index of the attachment from phpbb.plupload.ids that was affected. - * - * @return undefined + * @param {string} action The action that occurred -- either "addition" or "removal" + * @param {int} index The index of the attachment from phpbb.plupload.ids that was affected. */ phpbb.plupload.updateBbcode = function(action, index) { var textarea = $('#message', phpbb.plupload.form), @@ -366,10 +347,10 @@ phpbb.plupload.updateBbcode = function(action, index) { /** * Get Plupload file objects based on their upload status. * - * @param int status Plupload status - plupload.DONE, plupload.FAILED, plupload.QUEUED, - * plupload.STARTED, plupload.STOPPED + * @param {int} status Plupload status - plupload.DONE, plupload.FAILED, + * plupload.QUEUED, plupload.STARTED, plupload.STOPPED * - * @return Returns an array of the Plupload file objects matching the status. + * @returns {Array} The Plupload file objects matching the status. */ phpbb.plupload.getFilesByStatus = function(status) { var files = []; @@ -387,7 +368,7 @@ phpbb.plupload.getFilesByStatus = function(status) { * to upload. If so, disables the uploader and marks the queued files as failed. Otherwise * makes sure that the uploader is enabled. * - * @return bool Returns true if the limit has been reached. False if otherwise. + * @returns {bool} True if the limit has been reached. False if otherwise. */ phpbb.plupload.handleMaxFilesReached = function() { // If there is no limit, the user is an admin or moderator. @@ -412,8 +393,6 @@ phpbb.plupload.handleMaxFilesReached = function() { /** * Disable the uploader - * - * @return undefined */ phpbb.plupload.disableUploader = function() { $('#add_files').addClass('disabled'); @@ -422,8 +401,6 @@ phpbb.plupload.disableUploader = function() { /** * Enable the uploader - * - * @return undefined */ phpbb.plupload.enableUploader = function() { $('#add_files').removeClass('disabled'); @@ -433,8 +410,7 @@ phpbb.plupload.enableUploader = function() { /** * Mark all queued files as failed. * - * @param string error Error message to present to the user. - * @return undefined + * @param {string} error Error message to present to the user. */ phpbb.plupload.markQueuedFailed = function(error) { var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); @@ -448,9 +424,8 @@ phpbb.plupload.markQueuedFailed = function(error) { /** * Marks a file as failed and sets the error message for it. * - * @param object file Plupload file object that failed. - * @param string error Error message to present to the user. - * @return undefined + * @param {object} file Plupload file object that failed. + * @param {string} error Error message to present to the user. */ phpbb.plupload.fileError = function(file, error) { file.status = plupload.FAILED; @@ -520,11 +495,8 @@ phpbb.plupload.uploader.bind('Error', function(up, error) { * send the real filename along with the chunk. This is necessary because * for some reason the filename is set to 'blob' whenever a file is chunked * - * @param object up The plupload.Uploader object - * @param object file The plupload.File object that is about to be - * uploaded - * - * @return undefined + * @param {object} up The plupload.Uploader object + * @param {object} file The plupload.File object that is about to be uploaded */ phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) { if (phpbb.plupload.handleMaxFilesReached()) { @@ -539,12 +511,10 @@ phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) { * response from the server and checks for an error. If an error occurs it * is reported to the user and the upload of this particular file is halted * - * @param object up The plupload.Uploader object - * @param object file The plupload.File object whose chunk has just + * @param {object} up The plupload.Uploader object + * @param {object} file The plupload.File object whose chunk has just * been uploaded - * @param object response The response object from the server - * - * @return undefined + * @param {object} response The response object from the server */ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) { if (response.chunk >= response.chunks - 1) { @@ -584,8 +554,6 @@ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) { /** * Fires when files are added to the queue. - * - * @return undefined */ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) { // Prevent unnecessary requests to the server if the user already uploaded @@ -627,12 +595,10 @@ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) { * appends it to the next file upload so that the server can maintain state * with regards to the attachments in a given post * - * @param object up The plupload.Uploader object - * @param object file The plupload.File object that has just been + * @param {object} up The plupload.Uploader object + * @param {object} file The plupload.File object that has just been * uploaded - * @param string response The response string from the server - * - * @return undefined + * @param {string} response The response string from the server */ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { var json = {}, @@ -674,11 +640,9 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { /** * Fires when the entire queue of files have been uploaded. * - * @param object up The plupload.Uploader object - * @param array files An array of plupload.File objects that have just + * @param {object} up The plupload.Uploader object + * @param {Array} files An array of plupload.File objects that have just * been uploaded as part of a queue - * - * @return undefined */ phpbb.plupload.uploader.bind('UploadComplete', function(up, files) { // Hide the progress bar diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 168efff4b4..85eb841c80 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -42,8 +42,8 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) { /** * This callback will mark all topic icons read * -* @param update_topic_links bool Whether "Mark topics read" links should be -* updated. Defaults to true. +* @param {bool} [update_topic_links=true] Whether "Mark topics read" links +* should be updated. Defaults to true. */ phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) { var readTitle = res.NO_UNREAD_POSTS; From 143578ad09e45e1d8a8abea0c718bf04043bed70 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 29 May 2015 12:51:28 +0200 Subject: [PATCH 161/239] [ticket/13887] Minor JS refactoring PHPBB3-13887 --- phpBB/assets/javascript/core.js | 16 ++-- phpBB/assets/javascript/editor.js | 2 +- phpBB/assets/javascript/plupload.js | 91 ++++++++++--------- phpBB/styles/prosilver/template/ajax.js | 10 +- .../subsilver2/template/posting_body.html | 2 +- 5 files changed, 63 insertions(+), 58 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 93a21eb203..e55ec5a6f8 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1,3 +1,5 @@ +/* global bbfontstyle */ + var phpbb = {}; phpbb.alertTime = 100; @@ -197,7 +199,7 @@ phpbb.confirm = function(msg, callback, fadedark) { * * @argument {string} string The querystring to parse. * @returns {object} The object created. - */{} + */ phpbb.parseQuerystring = function(string) { var params = {}, i, split; @@ -764,7 +766,7 @@ phpbb.timezoneSwitchDate = function(keepSelection) { } if ($tzDate.val() !== '') { - $timezone.children('optgroup').remove(':not([data-tz-value="' + $('#tz_date').val() + '"])'); + $timezone.children('optgroup').remove(':not([data-tz-value="' + $tzDate.val() + '"])'); } if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) { @@ -1004,7 +1006,7 @@ phpbb.resizeTextArea = function($items, options) { function autoResize(item) { function setHeight(height) { - height += parseInt($item.css('height')) - $item.height(); + height += parseInt($item.css('height'), 10) - $item.height(); $item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized'); configuration.resizeCallback.call(item, $item); } @@ -1021,7 +1023,7 @@ phpbb.resizeTextArea = function($items, options) { configuration.maxHeight ), $item = $(item), - height = parseInt($item.height()), + height = parseInt($item.height(), 10), scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; if (height < 0) { @@ -1213,10 +1215,10 @@ phpbb.applyCodeEditor = function(textarea) { * This function will enable the drag and drop animation for a specified * textarea. * - * @param {object} textarea Textarea DOM object to apply editor to + * @param {HTMLElement} textarea Textarea DOM object to apply editor to */ phpbb.showDragNDrop = function(textarea) { - if (textarea == null) { + if (!textarea) { return; } @@ -1474,7 +1476,7 @@ phpbb.registerPalette = function(el) { } e.preventDefault(); }); -} +}; /** * Set display of page element diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js index c58e4d19dd..298526ab1f 100644 --- a/phpBB/assets/javascript/editor.js +++ b/phpBB/assets/javascript/editor.js @@ -159,7 +159,7 @@ function insert_text(text, spaces, popup) { /** * Add inline attachment at position */ -function attach_inline(index, filename) { +function attachInline(index, filename) { insert_text('[attachment=' + index + ']' + filename + '[/attachment]'); document.forms[form_name].elements[text_name].focus(); } diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index a80e816569..ba40976544 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -1,9 +1,11 @@ +/* global phpbb, plupload, attachInline */ + plupload.addI18n(phpbb.plupload.i18n); phpbb.plupload.ids = []; (function($) { // Avoid conflicts with other libraries -"use strict"; +'use strict'; /** * Set up the uploader. @@ -18,7 +20,7 @@ phpbb.plupload.initialize = function() { // Only execute if Plupload initialized successfully. phpbb.plupload.uploader.bind('Init', function() { - phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0], + phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0]; phpbb.plupload.rowTpl = $('#attach-row-tpl')[0].outerHTML; // Hide the basic upload panel and remove the attach row template. @@ -64,10 +66,8 @@ phpbb.plupload.clearParams = function() { * @param {object} obj */ phpbb.plupload.updateMultipartParams = function(obj) { - phpbb.plupload.uploader.settings.multipart_params = $.extend( - phpbb.plupload.uploader.settings.multipart_params, - obj - ); + var settings = phpbb.plupload.uploader.settings; + settings.multipart_params = $.extend(settings.multipart_params, obj); }; /** @@ -95,11 +95,11 @@ phpbb.plupload.getSerializedData = function() { * Get the index from the phpbb.plupload.data array where the given * attachment id appears. * - * @param {int} attach_id The attachment id of the file. + * @param {int} attachId The attachment id of the file. * @returns {bool|int} Index of the file if exists, otherwise false. */ -phpbb.plupload.getIndex = function(attach_id) { - var index = $.inArray(Number(attach_id), phpbb.plupload.ids); +phpbb.plupload.getIndex = function(attachId) { + var index = $.inArray(Number(attachId), phpbb.plupload.ids); return (index !== -1) ? index : false; }; @@ -154,7 +154,7 @@ phpbb.plupload.updateRows = function(downloadUrl) { * #file-list based on the attach_order setting. * * @param {object} file Plupload file object for the new attachment. - */{} + */ phpbb.plupload.insertRow = function(file) { var row = $(phpbb.plupload.rowTpl); @@ -182,10 +182,10 @@ phpbb.plupload.updateRow = function(index, downloadUrl) { // Add the link to the file if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { var url = downloadUrl[index].replace('&', '&'), - link = ${('}'); + link = $(''); link.attr('href', url).html(attach.real_filename); - row.find('.file-name').html(link) + row.find('.file-name').html(link); } row.find('textarea').attr('name', 'comment_list[' + index + ']'); @@ -203,6 +203,10 @@ phpbb.plupload.updateHiddenData = function(row, attach, index) { row.find('input[type="hidden"]').remove(); for (var key in attach) { + if (!attach.hasOwnProperty(key)) { + return; + } + var input = $('') .attr('type', 'hidden') .attr('name', 'attachment_data[' + index + '][' + key +']') @@ -290,7 +294,7 @@ phpbb.plupload.hideEmptyList = function() { if (!$('#file-list').children().length) { $('#file-list-container').slideUp(100); } -} +}; /** * Update the indices used in inline attachment bbcodes. This ensures that the bbcodes @@ -324,7 +328,7 @@ phpbb.plupload.updateBbcode = function(action, index) { // Private function used to generate search regexp var searchRegexp = function(index) { return new RegExp('\\[attachment=' + index + '\\](.*?)\\[\\/attachment\\]', 'g'); - } + }; // The update order of the indices is based on the action taken to ensure that we don't corrupt // the bbcode index by updating it several times as we move through the loop. // Removal loop starts at the removed index and moves to the end of the array. @@ -334,12 +338,12 @@ phpbb.plupload.updateBbcode = function(action, index) { i = (removal) ? index : phpbb.plupload.ids.length - 1; } return (removal) ? (i < phpbb.plupload.ids.length): (i >= index); - } + }; var i; while (searchLoop()) { text = text.replace(searchRegexp(i), updateBbcode); - (removal) ? i++ : i--; + i += (removal) ? 1 : -1; } textarea.val(text); }; @@ -361,7 +365,7 @@ phpbb.plupload.getFilesByStatus = function(status) { } }); return files; -} +}; /** * Check whether the user has reached the maximun number of files that he's allowed @@ -389,7 +393,7 @@ phpbb.plupload.handleMaxFilesReached = function() { phpbb.plupload.enableUploader(); } return false; -} +}; /** * Disable the uploader @@ -397,7 +401,7 @@ phpbb.plupload.handleMaxFilesReached = function() { phpbb.plupload.disableUploader = function() { $('#add_files').addClass('disabled'); phpbb.plupload.uploader.disableBrowse(); -} +}; /** * Enable the uploader @@ -405,7 +409,7 @@ phpbb.plupload.disableUploader = function() { phpbb.plupload.enableUploader = function() { $('#add_files').removeClass('disabled'); phpbb.plupload.uploader.disableBrowse(false); -} +}; /** * Mark all queued files as failed. @@ -419,7 +423,7 @@ phpbb.plupload.markQueuedFailed = function(error) { $('#' + file.id).find('.file-progress').hide(); phpbb.plupload.fileError(file, error); }); -} +}; /** * Marks a file as failed and sets the error message for it. @@ -430,10 +434,13 @@ phpbb.plupload.markQueuedFailed = function(error) { phpbb.plupload.fileError = function(file, error) { file.status = plupload.FAILED; file.error = error; - $('#' + file.id).find('.file-status').addClass('file-error').attr({'data-error-title': phpbb.plupload.lang.ERROR, 'data-error-message': error}); -} - - + $('#' + file.id).find('.file-status') + .addClass('file-error') + .attr({ + 'data-error-title': phpbb.plupload.lang.ERROR, + 'data-error-message': error + }); +}; /** @@ -442,24 +449,23 @@ phpbb.plupload.fileError = function(file, error) { phpbb.plupload.uploader = new plupload.Uploader(phpbb.plupload.config); phpbb.plupload.initialize(); - - +var $fileList = $('#file-list'); /** * Insert inline attachment bbcode. */ - $('#file-list').on('click', '.file-inline-bbcode', function(e) { +$fileList.on('click', '.file-inline-bbcode', function(e) { var attachId = $(this).parents('.attach-row').attr('data-attach-id'), index = phpbb.plupload.getIndex(attachId); - attach_inline(index, phpbb.plupload.data[index].real_filename); + attachInline(index, phpbb.plupload.data[index].real_filename); e.preventDefault(); }); /** * Delete a file. */ -$('#file-list').on('click', '.file-delete', function(e) { +$fileList.on('click', '.file-delete', function(e) { var row = $(this).parents('.attach-row'), attachId = row.attr('data-attach-id'); @@ -470,7 +476,7 @@ $('#file-list').on('click', '.file-delete', function(e) { /** * Display the error message for a particular file when the error icon is clicked. */ -$('#file-list').on('click', '.file-error', function(e) { +$fileList.on('click', '.file-error', function(e) { phpbb.alert($(this).attr('data-error-title'), $(this).attr('data-error-message')); e.preventDefault(); }); @@ -563,13 +569,14 @@ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) { } // Switch the active tab if the style supports it - if (typeof activateSubPanel == 'function') { - activateSubPanel('attach-panel'); + if (typeof activateSubPanel === 'function') { + activateSubPanel('attach-panel'); // jshint ignore: line } // Show the file list if there aren't any files currently. - if (!$('#file-list-container').is(':visible')) { - $('#file-list-container').show(100); + var $fileListContainer = $('#file-list-container'); + if (!$fileListContainer.is(':visible')) { + $fileListContainer.show(100); } $.each(files, function(i, file) { @@ -577,7 +584,7 @@ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) { }); up.bind('UploadProgress', function(up, file) { - $('#' + file.id + " .file-progress-bar").css('width', file.percent + '%'); + $('.file-progress-bar', '#' + file.id).css('width', file.percent + '%'); $('#file-total-progress-bar').css('width', up.total.percent + '%'); }); @@ -609,7 +616,7 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { row.find('.file-progress').hide(); try { - json = $.parseJSON(response.response); + json = JSON.parse(response.response); } catch (e) { error = 'Error parsing server response.'; } @@ -628,23 +635,19 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { if (typeof error !== 'undefined') { phpbb.plupload.fileError(file, error); } else if (file.status === plupload.DONE) { - file.attachment_data = json['data'][0]; + file.attachment_data = json.data[0]; row.attr('data-attach-id', file.attachment_data.attach_id); row.find('.file-inline-bbcode').show(); row.find('.file-status').addClass('file-uploaded'); - phpbb.plupload.update(json['data'], 'addition', 0, [json['download_url']]); + phpbb.plupload.update(json.data, 'addition', 0, [json.download_url]); } }); /** * Fires when the entire queue of files have been uploaded. - * - * @param {object} up The plupload.Uploader object - * @param {Array} files An array of plupload.File objects that have just - * been uploaded as part of a queue */ -phpbb.plupload.uploader.bind('UploadComplete', function(up, files) { +phpbb.plupload.uploader.bind('UploadComplete', function() { // Hide the progress bar setTimeout(function() { $('#file-total-progress-bar').fadeOut(500, function() { diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 85eb841c80..1d95fa42fa 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -138,9 +138,9 @@ phpbb.markNotifications = function($popup, unreadCount) { } // Update page title - $('title').text( - (unreadCount ? '(' + unreadCount + ')' : '') + $('title').text().replace(/(\(([0-9])\))/, '') - ); + var $title = $('title'); + var originalTitle = $title.text().replace(/(\((\d+)\))/, ''); + $title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle); }; // This callback finds the post from the delete link, and removes it. @@ -205,7 +205,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) { // Set min-height to prevent the page from jumping when the content changes var updatePanelHeight = function (height) { - var height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height; + height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height; panel.css('min-height', height); }; updatePanelHeight(); @@ -378,7 +378,7 @@ $('#member_search').click(function () { */ $(function() { phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250}); - phpbb.resizeTextArea($('#message-box textarea')); + phpbb.resizeTextArea($('textarea', '#message-box')); }); diff --git a/phpBB/styles/subsilver2/template/posting_body.html b/phpBB/styles/subsilver2/template/posting_body.html index 815d8c4a99..cde6873a90 100644 --- a/phpBB/styles/subsilver2/template/posting_body.html +++ b/phpBB/styles/subsilver2/template/posting_body.html @@ -221,7 +221,7 @@ {L_ATTACHMENTS}{L_COLON} -   +   From 0fc6816be6e1615fd6f3d7f3a52bb48049212e96 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 29 May 2015 13:01:33 +0200 Subject: [PATCH 162/239] [ticket/13887] Made unreadable code readable PHPBB3-13887 --- phpBB/assets/javascript/plupload.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index ba40976544..625907a2f6 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -329,22 +329,20 @@ phpbb.plupload.updateBbcode = function(action, index) { var searchRegexp = function(index) { return new RegExp('\\[attachment=' + index + '\\](.*?)\\[\\/attachment\\]', 'g'); }; - // The update order of the indices is based on the action taken to ensure that we don't corrupt - // the bbcode index by updating it several times as we move through the loop. - // Removal loop starts at the removed index and moves to the end of the array. - // Addition loop starts at the end of the array and moves to the added index at 0. - var searchLoop = function() { - if (typeof i === 'undefined') { - i = (removal) ? index : phpbb.plupload.ids.length - 1; - } - return (removal) ? (i < phpbb.plupload.ids.length): (i >= index); - }; - var i; - while (searchLoop()) { - text = text.replace(searchRegexp(i), updateBbcode); - i += (removal) ? 1 : -1; + // Loop forwards when removing and backwards when adding ensures we don't + // corrupt the bbcode index. + var i; + if (removal) { + for (i = index; i < phpbb.plupload.ids.length; i++) { + text = text.replace(searchRegexp(i), updateBbcode); + } + } else { + for (i = phpbb.plupload.ids.length - 1; i >= index; i--) { + text = text.replace(searchRegexp(i), updateBbcode); + } } + textarea.val(text); }; From da6f751cefedd0573611cf3e9123b4345759d779 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 29 May 2015 13:08:31 +0200 Subject: [PATCH 163/239] [ticket/13887] Made readable code DRY PHPBB3-13887 --- phpBB/assets/javascript/plupload.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 625907a2f6..3845de6c56 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -315,31 +315,28 @@ phpbb.plupload.updateBbcode = function(action, index) { return; } - // Private function used to replace the bbcode. - var updateBbcode = function(match, fileName) { - // Remove the bbcode if the file was removed. - if (removal && index === i) { - return ''; - } - var newIndex = i + ((removal) ? -1 : 1); - return '[attachment=' + newIndex +']' + fileName + '[/attachment]'; - }; - - // Private function used to generate search regexp - var searchRegexp = function(index) { - return new RegExp('\\[attachment=' + index + '\\](.*?)\\[\\/attachment\\]', 'g'); - }; + function runUpdate(i) { + var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); + text = text.replace(regex, function updateBbcode(_, fileName) { + // Remove the bbcode if the file was removed. + if (removal && index === i) { + return ''; + } + var newIndex = i + ((removal) ? -1 : 1); + return '[attachment=' + newIndex +']' + fileName + '[/attachment]'; + }); + } // Loop forwards when removing and backwards when adding ensures we don't // corrupt the bbcode index. var i; if (removal) { for (i = index; i < phpbb.plupload.ids.length; i++) { - text = text.replace(searchRegexp(i), updateBbcode); + runUpdate(i); } } else { for (i = phpbb.plupload.ids.length - 1; i >= index; i--) { - text = text.replace(searchRegexp(i), updateBbcode); + runUpdate(i); } } From 9366f29fd7d0bf439b0a57bcea9f2753881b6509 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 28 May 2015 18:12:16 +0200 Subject: [PATCH 164/239] [ticket/13882] no more egyptian brackets /o/ PHPBB3-13882 --- phpBB/includes/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b3da9c4e5d..2c3560fa6d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4851,7 +4851,8 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) if (!empty($avatar_data['src'])) { - if ($lazy) { + if ($lazy) + { // Determine board url - we may need it later $board_url = generate_board_url() . '/'; // This path is sent with the base template paths in the assign_vars() @@ -4865,7 +4866,9 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme'; $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"'; - } else { + } + else + { $src = 'src="' . $avatar_data['src'] . '"'; } From d1c4f5bc352b89da7b0fba4925c68f596f623494 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 30 May 2015 12:18:44 +0200 Subject: [PATCH 165/239] [ticket/13882] Added tiny docblock to lazyLoadAvatars PHPBB3-13882 --- phpBB/assets/javascript/core.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 819e9329a4..ffd2f04c88 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1612,6 +1612,9 @@ phpbb.registerPageDropdowns = function() { }); }; +/** + * Handle avatars to be lazy loaded. + */ phpbb.lazyLoadAvatars = function loadAvatars() { $('.avatar[data-src]').each(function () { var $avatar = $(this); From e3090e04c3fc2505155118abfd7e354bd858056b Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 30 May 2015 14:44:48 +0200 Subject: [PATCH 166/239] [ticket/13898] js coding standaaards PHPBB3-13898 --- phpBB/.jscsrc | 79 +++++++++++++++++++++++++ phpBB/.jshintrc | 24 ++++++++ phpBB/assets/javascript/core.js | 77 +++++++++++++----------- phpBB/assets/javascript/plupload.js | 40 ++++++------- phpBB/styles/prosilver/template/ajax.js | 31 +++++----- 5 files changed, 181 insertions(+), 70 deletions(-) create mode 100644 phpBB/.jscsrc create mode 100644 phpBB/.jshintrc diff --git a/phpBB/.jscsrc b/phpBB/.jscsrc new file mode 100644 index 0000000000..cf0697c519 --- /dev/null +++ b/phpBB/.jscsrc @@ -0,0 +1,79 @@ + +{ + "excludeFiles": ["node_modules/**", "**/build/**"], + "requireCurlyBraces": [ + "if", "else", "for", "while", "do", "try", "catch" + ], + "requireSpaceBeforeKeywords": [ + "else", "while", "catch" + ], + "requireSpaceAfterKeywords": [ + "do", "for", "if", "else", "switch", "case", "try", "catch", "while", "return", "typeof" + ], + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": { + "afterTest": true, + "beforeConsequent": true, + "afterConsequent": true, + "beforeAlternate": true + }, + "requireSpacesInAnonymousFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "requireSpacesInFunction": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInCallExpression": true, + "requireBlocksOnNewline": true, + "requirePaddingNewlinesBeforeKeywords": ["case"], + "disallowEmptyBlocks": true, + "disallowSpacesInsideArrayBrackets": "nested", + "disallowSpacesInsideParentheses": true, + "requireSpacesInsideObjectBrackets": "all", + "disallowQuotedKeysInObjects": "allButReserved", + "disallowSpaceAfterObjectKeys": true, + "requireSpaceBeforeObjectValues": true, + "requireCommaBeforeLineBreak": true, + "requireOperatorBeforeLineBreak": [ + "?", "=", "+", "-", "/", "*", "===", "!==", ">", ">=", "<", "<=" + ], + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforeBinaryOperators": [ + "=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">=" + ], + "requireSpaceAfterBinaryOperators": [ + "=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">=" + ], + "requireCamelCaseOrUpperCaseIdentifiers": true, + "disallowKeywords": ["with"], + "disallowMultipleLineStrings": true, + "disallowMixedSpacesAndTabs": "smart", + "disallowTrailingWhitespace": true, + "disallowTrailingComma": true, + "disallowKeywordsOnNewLine": ["else"], + "requireLineFeedAtFileEnd": true, + "maximumLineLength": { + "value": 120, + "tabSize": 2, + "allowUrlComments": true, + "allowRegex": true + }, + "requireCapitalizedConstructors": true, + "requireDotNotation": true, + "disallowYodaConditions": true, + "requireSpaceAfterLineComment": { + "allExcept": ["#", "="] + }, + "disallowNewlineBeforeBlockStatements": true, + "validateQuoteMarks": { + "mark": "'", + "escape": true + }, + "validateParameterSeparator": ", ", + "safeContextKeyword": ["that"] +} diff --git a/phpBB/.jshintrc b/phpBB/.jshintrc new file mode 100644 index 0000000000..90d3bb613e --- /dev/null +++ b/phpBB/.jshintrc @@ -0,0 +1,24 @@ + +{ + "bitwise": true, + "curly": true, + "eqeqeq": true, + "es3": true, + "forin": false, + "freeze": true, + "newcap": true, + "noarg": true, + "noempty": true, + "nonbsp": true, + "undef": true, + "unused": true, + "strict": true, + + "browser": true, + "devel": true, + "jquery": true, + + "globals": { + "JSON": true + } +} diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 88ef5733fe..efa6ecbc74 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -264,11 +264,9 @@ phpbb.ajaxify = function(options) { } catch (e) {} if (typeof responseText === 'string' && responseText.length > 0) { errorText = responseText; - } - else if (typeof errorThrown === 'string' && errorThrown.length > 0) { + } else if (typeof errorThrown === 'string' && errorThrown.length > 0) { errorText = errorThrown; - } - else { + } else { errorText = $dark.attr('data-ajax-error-text-' + textStatus); if (typeof errorText !== 'string' || !errorText.length) { errorText = $dark.attr('data-ajax-error-text'); @@ -429,7 +427,7 @@ phpbb.search = { }; /** - * Get cached search data. + * Get cached search data. * * @param {string} id Search ID. * @returns {bool|object} Cached data object. Returns false if no data exists. @@ -442,7 +440,7 @@ phpbb.search.cache.get = function(id) { }; /** - * Set search cache data value. + * Set search cache data value. * * @param {string} id Search ID. * @param {string} key Data key. @@ -450,13 +448,13 @@ phpbb.search.cache.get = function(id) { */ phpbb.search.cache.set = function(id, key, value) { if (!this.data[id]) { - this.data[id] = {results: []}; + this.data[id] = { results: [] }; } this.data[id][key] = value; }; /** - * Cache search result. + * Cache search result. * * @param {string} id Search ID. * @param {string} keyword Keyword. @@ -496,7 +494,7 @@ phpbb.search.getKeyword = function($input, keyword, multiline) { /** * Get the textarea line number on which the keyword resides - for textareas - * that support multiple keywords (one per line). + * that support multiple keywords (one per line). * * @param {jQuery} $textarea Search textarea. * @returns {int} The line number. @@ -525,7 +523,8 @@ phpbb.search.setValue = function($input, value, multiline) { }; /** - * Sets the onclick event to set the value on the input|textarea to the selected search result. + * Sets the onclick event to set the value on the input|textarea to the + * selected search result. * * @param {jQuery} $input Search input|textarea. * @param {object} value Result object. @@ -554,7 +553,7 @@ phpbb.search.setValueOnClick = function($input, value, $row, $container) { phpbb.search.filter = function(data, event, sendRequest) { var $this = $(this), dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'), - minLength = parseInt($this.attr('data-min-length')), + minLength = parseInt($this.attr('data-min-length'), 10), searchID = $this.attr('data-results'), keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')), cache = phpbb.search.cache.get(searchID), @@ -576,7 +575,10 @@ phpbb.search.filter = function(data, event, sendRequest) { } else { // Do we already have results for this? if (cache.results[keyword]) { - var response = {keyword: keyword, results: cache.results[keyword]}; + var response = { + keyword: keyword, + results: cache.results[keyword] + }; phpbb.search.handleResponse(response, $this, true); proceed = false; } @@ -587,8 +589,8 @@ phpbb.search.filter = function(data, event, sendRequest) { phpbb.search.cache.set(searchID, 'lastSearch', keyword); phpbb.search.cache.setResults(searchID, keyword, []); proceed = false; - } - } + } + } } if (proceed) { @@ -601,7 +603,7 @@ phpbb.search.filter = function(data, event, sendRequest) { }; /** - * Handle search result response. + * Handle search result response. * * @param {object} res Data received from server. * @param {jQuery} $input Search input|textarea. @@ -781,7 +783,7 @@ phpbb.timezoneSwitchDate = function(keepSelection) { } else { $tzSelectDateSuggest.css('display', 'inline'); } - + var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); if ($tzOptions.length === 1) { @@ -1006,7 +1008,9 @@ phpbb.resizeTextArea = function($items, options) { function resetAutoResize(item) { var $item = $(item); if ($item.hasClass('auto-resized')) { - $(item).css({height: '', resize: ''}).removeClass('auto-resized'); + $(item) + .css({ height: '', resize: '' }) + .removeClass('auto-resized'); configuration.resetCallback.call(item, $item); } } @@ -1014,7 +1018,9 @@ phpbb.resizeTextArea = function($items, options) { function autoResize(item) { function setHeight(height) { height += parseInt($item.css('height'), 10) - $item.height(); - $item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized'); + $item + .css({ height: height + 'px', resize: 'none' }) + .addClass('auto-resized'); configuration.resizeCallback.call(item, $item); } @@ -1039,8 +1045,7 @@ phpbb.resizeTextArea = function($items, options) { if (height > maxHeight) { setHeight(maxHeight); - } - else if (scrollHeight > (height + 5)) { + } else if (scrollHeight > (height + 5)) { setHeight(Math.min(maxHeight, scrollHeight)); } } @@ -1157,7 +1162,7 @@ phpbb.applyCodeEditor = function(textarea) { var tagLength = startTags[i].length; value = value.substring(index + tagLength); - if (startTags[i].lastIndexOf(startTagsEnd) != tagLength) { + if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) { index = value.indexOf(startTagsEnd); if (index >= 0) { @@ -1333,12 +1338,15 @@ phpbb.toggleDropdown = function() { fullFreeSpace = freeSpace + parent.outerWidth(); options.dropdown.find('.dropdown-contents').each(function() { - contentWidth = parseInt($(this).outerWidth()); - $(this).css({marginLeft: 0, left: 0}); + contentWidth = parseInt($(this).outerWidth(), 10); + $(this).css({ marginLeft: 0, left: 0 }); }); var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; - options.dropdown.css({'width': maxOffset, 'margin-left': '-' + maxOffset}); + options.dropdown.css({ + width: maxOffset, + marginLeft: -maxOffset + }); } } else { options.dropdown.css('margin-right', '-' + (windowWidth + freeSpace) + 'px'); @@ -1405,9 +1413,7 @@ phpbb.registerDropdown = function(toggle, dropdown, options) { * @param {int} height Palette cell height. */ phpbb.colorPalette = function(dir, width, height) { - var r = 0, - g = 0, - b = 0, + var r, g, b, numberList = new Array(6), color = '', html = ''; @@ -1418,32 +1424,33 @@ phpbb.colorPalette = function(dir, width, height) { numberList[3] = 'BF'; numberList[4] = 'FF'; - var tableClass = (dir == 'h') ? 'horizontal-palette' : 'vertical-palette'; + var tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; html += ''; for (r = 0; r < 5; r++) { - if (dir == 'h') { + if (dir === 'h') { html += ''; } for (g = 0; g < 5; g++) { - if (dir == 'v') { + if (dir === 'v') { html += ''; } for (b = 0; b < 5; b++) { - color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); + color = '' + numberList[r] + numberList[g] + numberList[b]; html += ''; } - if (dir == 'v') { + if (dir === 'v') { html += ''; } } - if (dir == 'h') { + if (dir === 'h') { html += ''; } } @@ -1530,7 +1537,7 @@ phpbb.toggleSelectSettings = function(el) { * @returns function */ phpbb.getFunctionByName = function (functionName) { - var namespaces = functionName.split('.'), + var namespaces = functionName.split('.'), func = namespaces.pop(), context = window; diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 3845de6c56..96e5ca96e6 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -105,7 +105,7 @@ phpbb.plupload.getIndex = function(attachId) { /** * Set the data in phpbb.plupload.data and phpbb.plupload.ids arrays. - * + * * @param {Array} data Array containing the new data to use. In the form of * array(index => object(property: value). Requires attach_id to be one of the object properties. */ @@ -121,7 +121,7 @@ phpbb.plupload.setData = function(data) { /** * Update the attachment data in the HTML and the phpbb & phpbb.plupload objects. - * + * * @param {Array} data Array containing the new data to use. * @param {string} action The action that required the update. Used to update the inline attachment bbcodes. * @param {int} index The index from phpbb.plupload_ids that was affected by the action. @@ -138,7 +138,7 @@ phpbb.plupload.update = function(data, action, index, downloadUrl) { /** * Update the relevant elements and hidden data for all attachments. - * + * * @param {Array} downloadUrl Optional array of download urls to update. */ phpbb.plupload.updateRows = function(downloadUrl) { @@ -152,7 +152,7 @@ phpbb.plupload.updateRows = function(downloadUrl) { * using the id "attach-row-tpl" to be present. This snippet is cloned and the * data for the file inserted into it. The row is then appended or prepended to * #file-list based on the attach_order setting. - * + * * @param {object} file Plupload file object for the new attachment. */ phpbb.plupload.insertRow = function(file) { @@ -162,7 +162,7 @@ phpbb.plupload.insertRow = function(file) { row.find('.file-name').html(plupload.xmlEncode(file.name)); row.find('.file-size').html(plupload.formatSize(file.size)); - if (phpbb.plupload.order == 'desc') { + if (phpbb.plupload.order === 'desc') { $('#file-list').prepend(row); } else { $('#file-list').append(row); @@ -171,7 +171,7 @@ phpbb.plupload.insertRow = function(file) { /** * Update the relevant elements and hidden data for an attachment. - * + * * @param {int} index The index from phpbb.plupload.ids of the attachment to edit. * @param {Array} downloadUrl Optional array of download urls to update. */ @@ -209,7 +209,7 @@ phpbb.plupload.updateHiddenData = function(row, attach, index) { var input = $('') .attr('type', 'hidden') - .attr('name', 'attachment_data[' + index + '][' + key +']') + .attr('name', 'attachment_data[' + index + '][' + key + ']') .attr('value', attach[key]); $('textarea', row).after(input); } @@ -256,7 +256,7 @@ phpbb.plupload.deleteFile = function(row, attachId) { // trigger_error() was called which likely means a permission error was encountered. if (typeof response.title !== 'undefined') { - phpbb.plupload.uploader.trigger('Error', {message: response.message}); + phpbb.plupload.uploader.trigger('Error', { message: response.message }); // We will have to assume that the deletion failed. So leave the file status as uploaded. row.find('.file-status').toggleClass('file-uploaded'); @@ -281,7 +281,7 @@ phpbb.plupload.deleteFile = function(row, attachId) { $.ajax(phpbb.plupload.config.url, { type: 'POST', data: $.extend(fields, phpbb.plupload.getSerializedData()), - headers: {'X-PHPBB-USING-PLUPLOAD': '1', 'X-Requested-With': 'XMLHttpRequest'} + headers: { 'X-PHPBB-USING-PLUPLOAD': '1', 'X-Requested-With': 'XMLHttpRequest' } }) .always(always) .done(done); @@ -297,10 +297,10 @@ phpbb.plupload.hideEmptyList = function() { }; /** - * Update the indices used in inline attachment bbcodes. This ensures that the bbcodes - * correspond to the correct file after a file is added or removed. This should be called - * before the phpbb.plupload,data and phpbb.plupload.ids arrays are updated, otherwise it will - * not work correctly. + * Update the indices used in inline attachment bbcodes. This ensures that the + * bbcodes correspond to the correct file after a file is added or removed. + * This should be called before the phpbb.plupload,data and phpbb.plupload.ids + * arrays are updated, otherwise it will not work correctly. * * @param {string} action The action that occurred -- either "addition" or "removal" * @param {int} index The index of the attachment from phpbb.plupload.ids that was affected. @@ -323,7 +323,7 @@ phpbb.plupload.updateBbcode = function(action, index) { return ''; } var newIndex = i + ((removal) ? -1 : 1); - return '[attachment=' + newIndex +']' + fileName + '[/attachment]'; + return '[attachment=' + newIndex + ']' + fileName + '[/attachment]'; }); } @@ -380,10 +380,10 @@ phpbb.plupload.handleMaxFilesReached = function() { phpbb.plupload.markQueuedFailed(phpbb.plupload.lang.TOO_MANY_ATTACHMENTS); // Disable the uploader. phpbb.plupload.disableUploader(); - phpbb.plupload.uploader.trigger('Error', {message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS}); + phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS }); return true; - } else if(phpbb.plupload.maxFiles > phpbb.plupload.ids.length) { + } else if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) { // Enable the uploader if the user is under the limit phpbb.plupload.enableUploader(); } @@ -504,7 +504,7 @@ phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) { return; } - phpbb.plupload.updateMultipartParams({'real_filename': file.name}); + phpbb.plupload.updateMultipartParams({ real_filename: file.name }); }); /** @@ -538,7 +538,7 @@ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) { // If trigger_error() was called, then a permission error likely occurred. if (typeof json.title !== 'undefined') { - json.error = {message: json.message}; + json.error = { message: json.message }; } if (json.error) { @@ -619,7 +619,7 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { // If trigger_error() was called, then a permission error likely occurred. if (typeof json.title !== 'undefined') { error = json.message; - up.trigger('Error', {message: error}); + up.trigger('Error', { message: error }); // The rest of the queue will fail. phpbb.plupload.markQueuedFailed(error); @@ -640,7 +640,7 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) { }); /** - * Fires when the entire queue of files have been uploaded. + * Fires when the entire queue of files have been uploaded. */ phpbb.plupload.uploader.bind('UploadComplete', function() { // Hide the progress bar diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 1d95fa42fa..76c605dd19 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -9,9 +9,9 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) { var readTitle = res.NO_UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS; var iconsArray = { - 'forum_unread': 'forum_read', - 'forum_unread_subforum': 'forum_read_subforum', - 'forum_unread_locked': 'forum_read_locked' + forum_unread: 'forum_read', + forum_unread_subforum: 'forum_read_subforum', + forum_unread_locked: 'forum_read_locked' }; $('li.row').find('dl[class*="forum_unread"]').each(function() { @@ -39,7 +39,7 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) { phpbb.closeDarkenWrapper(3000); }); -/** +/** * This callback will mark all topic icons read * * @param {bool} [update_topic_links=true] Whether "Mark topics read" links @@ -49,10 +49,10 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) { var readTitle = res.NO_UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS; var iconsArray = { - 'global_unread': 'global_read', - 'announce_unread': 'announce_read', - 'sticky_unread': 'sticky_read', - 'topic_unread': 'topic_read' + global_unread: 'global_read', + announce_unread: 'announce_read', + sticky_unread: 'sticky_read', + topic_unread: 'topic_read' }; var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; var unreadClassSelectors; @@ -223,7 +223,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) { // If the user can still vote, simply slide down the results poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); } - + // Get the votes count of the highest poll option poll.find('[data-poll-option-id]').each(function() { var option = $(this); @@ -252,7 +252,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) { var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); setTimeout(function () { - bar.animate({width: percentRel + '%'}, 500) + bar.animate({ width: percentRel + '%' }, 500) .removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5') .addClass(newBarClass) .html(res.vote_counts[optionId]); @@ -287,10 +287,10 @@ phpbb.addAjaxCallback('vote_poll', function(res) { var panelHeight = panel.height(); var innerHeight = panel.find('.inner').outerHeight(); - if (panelHeight != innerHeight) { - panel.css({'min-height': '', 'height': panelHeight}) - .animate({height: innerHeight}, time, function () { - panel.css({'min-height': innerHeight, 'height': ''}); + if (panelHeight !== innerHeight) { + panel.css({ minHeight: '', height: panelHeight }) + .animate({ height: innerHeight }, time, function () { + panel.css({ minHeight: innerHeight, height: '' }); }); } }; @@ -377,7 +377,8 @@ $('#member_search').click(function () { * Automatically resize textarea */ $(function() { - phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250}); + var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)'); + phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 }); phpbb.resizeTextArea($('textarea', '#message-box')); }); From bafd649eea74daa85799858e2406d5b6bdcb080b Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 30 May 2015 14:50:35 +0200 Subject: [PATCH 167/239] [ticket/13898] 4 spaces, not 2 PHPBB3-13898 --- phpBB/.jscsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/.jscsrc b/phpBB/.jscsrc index cf0697c519..4b516fcbe9 100644 --- a/phpBB/.jscsrc +++ b/phpBB/.jscsrc @@ -59,7 +59,7 @@ "requireLineFeedAtFileEnd": true, "maximumLineLength": { "value": 120, - "tabSize": 2, + "tabSize": 4, "allowUrlComments": true, "allowRegex": true }, From a39a421acb3d0e2c6b8d8f20974e90ea3625b065 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 30 May 2015 14:55:42 +0200 Subject: [PATCH 168/239] [ticket/13898] Allow underscores :( PHPBB3-13898 --- phpBB/.jscsrc | 1 - phpBB/assets/javascript/core.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/phpBB/.jscsrc b/phpBB/.jscsrc index 4b516fcbe9..9dd5ab82e6 100644 --- a/phpBB/.jscsrc +++ b/phpBB/.jscsrc @@ -49,7 +49,6 @@ "requireSpaceAfterBinaryOperators": [ "=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">=" ], - "requireCamelCaseOrUpperCaseIdentifiers": true, "disallowKeywords": ["with"], "disallowMultipleLineStrings": true, "disallowMixedSpacesAndTabs": "smart", diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index efa6ecbc74..5709941286 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1439,9 +1439,9 @@ phpbb.colorPalette = function(dir, width, height) { for (b = 0; b < 5; b++) { color = '' + numberList[r] + numberList[g] + numberList[b]; - html += ''; } From 27a70f573f4e3a99e9ca25ed0a2c456c17d93577 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 30 May 2015 15:03:56 +0200 Subject: [PATCH 169/239] [ticket/13898] Fixed all the forum_fn.js violations I understood PHPBB3-13898 --- phpBB/styles/prosilver/template/forum_fn.js | 62 ++++++++++++--------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 7a377a4973..ccedf19604 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -1,3 +1,5 @@ +/* global phpbb */ + /** * phpBB3 forum functions */ @@ -37,7 +39,7 @@ function pageJump(item) { baseUrl = item.attr('data-base-url'), startName = item.attr('data-start-name'); - if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) { + if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) { if (baseUrl.indexOf('?') === -1) { document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage); } else { @@ -124,7 +126,7 @@ function activateSubPanel(p, panels) { var i, showPanel; - if (typeof(p) === 'string') { + if (typeof p === 'string') { showPanel = p; } $('input[name="show_panel"]').val(showPanel); @@ -277,8 +279,7 @@ jQuery(function($) { /** * Functions for user search popup */ -function insertUser(formId, value) -{ +function insertUser(formId, value) { 'use strict'; var $form = jQuery(formId), @@ -286,7 +287,7 @@ function insertUser(formId, value) fieldName = $form.attr('data-field-name'), item = opener.document.forms[formName][fieldName]; - if (item.value.length && item.type == 'textarea') { + if (item.value.length && item.type === 'textarea') { value = item.value + '\n' + value; } @@ -319,7 +320,7 @@ function parseDocument($container) { 'use strict'; var test = document.createElement('div'), - oldBrowser = (typeof test.style.borderRadius == 'undefined'), + oldBrowser = (typeof test.style.borderRadius === 'undefined'), $body = $('body'); /** @@ -359,7 +360,10 @@ function parseDocument($container) { */ if (oldBrowser) { // Fix .linklist.bulletin lists - $container.find('ul.linklist.bulletin > li:first-child, ul.linklist.bulletin > li.rightside:last-child').addClass('no-bulletin'); + $container + .find('ul.linklist.bulletin > li') + .filter(':first-child, .rightside:last-child') + .addClass('no-bulletin'); } /** @@ -420,12 +424,12 @@ function parseDocument($container) { width; // Test max-width set in code for .navlinks above - width = parseInt($this.css('max-width')); + width = parseInt($this.css('max-width'), 10); if (!width) { - width = $body.width(); + width = $body.width(); } - maxHeight = parseInt($this.css('line-height')); + maxHeight = parseInt($this.css('line-height'), 10); $links.each(function() { if ($(this).height() > 0) { maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); @@ -452,8 +456,8 @@ function parseDocument($container) { return; } - for (var i = 0; i < classesLength; i ++) { - for (var j = length - 1; j >= 0; j --) { + for (var i = 0; i < classesLength; i++) { + for (var j = length - 1; j >= 0; j--) { $links.eq(j).addClass('wrapped ' + classes[i]); if ($this.height() <= maxHeight) { return; @@ -470,7 +474,9 @@ function parseDocument($container) { /** * Responsive link lists */ - $container.find('.linklist:not(.navlinks, [data-skip-responsive]), .postbody .post-buttons:not([data-skip-responsive])').each(function() { + var selector = '.linklist:not(.navlinks, [data-skip-responsive]),' + + '.postbody .post-buttons:not([data-skip-responsive])'; + $container.find(selector).each(function() { var $this = $(this), filterSkip = '.breadcrumbs, [data-skip-responsive]', filterLast = '.edit-icon, .quote-icon, [data-last-responsive]', @@ -478,7 +484,7 @@ function parseDocument($container) { $linksNotSkip = $linksAll.not(filterSkip), // All items that can potentially be hidden $linksFirst = $linksNotSkip.not(filterLast), // The items that will be hidden first $linksLast = $linksNotSkip.filter(filterLast), // The items that will be hidden last - persistent = $this.attr('id') == 'nav-main', // Does this list already have a menu (such as quick-links)? + persistent = $this.attr('id') === 'nav-main', // Does this list already have a menu (such as quick-links)? html = '', slack = 3; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured. @@ -675,7 +681,7 @@ function parseDocument($container) { $children = column.children(), html = column.html(); - if ($children.length == 1 && $children.text() == column.text()) { + if ($children.length === 1 && $children.text() === column.text()) { html = $children.html(); } @@ -717,8 +723,7 @@ function parseDocument($container) { if (!$block.length) { $this.find('dt > .list-inner').append(' - +
'; - html += ''; + html += ''; html += '
'; - html += ''; + html += ''; html += '

{L_LOGIN_LOGOUT}

{L_USERNAME}{L_COLON}   {L_PASSWORD}{L_COLON}   {L_FORGOT_PASS}  {L_LOG_ME_IN}   {L_USERNAME}{L_COLON}   {L_PASSWORD}{L_COLON}   {L_FORGOT_PASS}  {L_LOG_ME_IN}  
{S_LOGIN_REDIRECT} diff --git a/phpBB/styles/subsilver2/template/login_body.html b/phpBB/styles/subsilver2/template/login_body.html index ed63e748cf..1067f3738d 100644 --- a/phpBB/styles/subsilver2/template/login_body.html +++ b/phpBB/styles/subsilver2/template/login_body.html @@ -44,7 +44,7 @@ style="width: 50%; text-align: {S_CONTENT_FLOW_END};">{L_PASSWORD}{L_COLON} - +
{L_FORGOT_PASS}
{L_RESEND_ACTIVATION} diff --git a/phpBB/styles/subsilver2/template/login_forum.html b/phpBB/styles/subsilver2/template/login_forum.html index 9a141fc295..2cda9f3452 100644 --- a/phpBB/styles/subsilver2/template/login_forum.html +++ b/phpBB/styles/subsilver2/template/login_forum.html @@ -30,7 +30,7 @@ {L_PASSWORD}{L_COLON} - + diff --git a/phpBB/styles/subsilver2/template/ucp_login_link.html b/phpBB/styles/subsilver2/template/ucp_login_link.html index 5d8e3ee27b..6db9890d8c 100644 --- a/phpBB/styles/subsilver2/template/ucp_login_link.html +++ b/phpBB/styles/subsilver2/template/ucp_login_link.html @@ -52,7 +52,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html b/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html index 090d729326..862956a1d0 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html @@ -21,16 +21,16 @@ {L_EMAIL_ADDRESS}{L_COLON} - {EMAIL} + {EMAIL} {L_NEW_PASSWORD}{L_COLON}
{L_CHANGE_PASSWORD_EXPLAIN} - + {L_CONFIRM_PASSWORD}{L_COLON}
{L_CONFIRM_PASSWORD_EXPLAIN} - + @@ -39,7 +39,7 @@ {L_CURRENT_PASSWORD}{L_COLON}
{L_CURRENT_CHANGE_PASSWORD_EXPLAIN}{L_CURRENT_PASSWORD_EXPLAIN} - + {S_HIDDEN_FIELDS}   diff --git a/phpBB/styles/subsilver2/template/ucp_register.html b/phpBB/styles/subsilver2/template/ucp_register.html index 162fa2a020..9b9e164df4 100644 --- a/phpBB/styles/subsilver2/template/ucp_register.html +++ b/phpBB/styles/subsilver2/template/ucp_register.html @@ -41,15 +41,15 @@ {L_EMAIL_ADDRESS}{L_COLON} - + {L_PASSWORD}{L_COLON}
{L_PASSWORD_EXPLAIN} - + {L_CONFIRM_PASSWORD}{L_COLON} - + diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index 906fdd7c63..83b01b9f6d 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -137,7 +137,7 @@

{L_LOGIN_LOGOUT}

- {L_USERNAME}{L_COLON}   {L_PASSWORD}{L_COLON}   {L_LOG_ME_IN}   + {L_USERNAME}{L_COLON}   {L_PASSWORD}{L_COLON}   {L_LOG_ME_IN}   {S_LOGIN_REDIRECT} From 2b0acdcea4a04a0f7ac3ceab8f80b1dd61f2f84b Mon Sep 17 00:00:00 2001 From: CHItA Date: Fri, 5 Jun 2015 07:33:40 +0200 Subject: [PATCH 181/239] [ticket/13841] Fix tests on 3.1 and master branch PHPBB3-13841 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 96e0895ff8..6155fdbd48 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -540,7 +540,7 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true) * * @event core.move_topics_before_query * @var array table_ary Array of tables from which forum_id will be updated for all rows that hold the moved topics - * @var array topic_ids Array of the moved topic ids + * @var array topic_ids Array of the moved topic ids * @var string forum_id The forum id from where the topics are moved * @var array forum_ids Array of the forums where the topics are moving (includes also forum_id) * @var bool auto_sync Whether or not to perform auto sync From c221571963b5252c3343b6db3ace552e52104056 Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 6 Jun 2015 14:54:56 +0700 Subject: [PATCH 182/239] [ticket/13779] Add permission set tests PHPBB3-13779 --- tests/dbal/fixtures/migrator_permission.xml | 134 +++++++++++++++++++ tests/dbal/migrator_tool_permission_test.php | 62 +++++++++ 2 files changed, 196 insertions(+) diff --git a/tests/dbal/fixtures/migrator_permission.xml b/tests/dbal/fixtures/migrator_permission.xml index 08cec42a42..c07956fa85 100644 --- a/tests/dbal/fixtures/migrator_permission.xml +++ b/tests/dbal/fixtures/migrator_permission.xml @@ -27,5 +27,139 @@ 1 0 + + 4 + a_test + 1 + 0 + 0 + + + 5 + m_test + 1 + 0 + 0 + + + 6 + u_test + 1 + 0 + 0 + + + + + group_id + group_name + group_desc + + 2 + REGISTERED + + + + 4 + GLOBAL_MODERATORS + + + + 5 + ADMINISTRATORS + + +
+ + + group_id + auth_role_id + forum_id + + 2 + 5 + 0 + + + 4 + 5 + 0 + + + 4 + 10 + 0 + + + 5 + 1 + 0 + + + 5 + 5 + 0 + +
+ + + role_id + role_name + role_type + role_description + + 1 + ROLE_ADMIN_STANDARD + a_ + + + + 5 + ROLE_USER_FULL + u_ + + + + 10 + ROLE_MOD_FULL + m_ + + +
+ + + role_id + auth_option_id + auth_setting + + 1 + 4 + 0 + + + 1 + 5 + 0 + + + 1 + 6 + 0 + + + 6 + 6 + 0 + + + 10 + 5 + 0 + + + 10 + 6 + 0 +
diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index 4453fbf123..2d673864f7 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -15,6 +15,12 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case { + public $group_ids = array( + 'REGISTERED' => 2, + 'GLOBAL_MODERATORS' => 4, + 'ADMINISTRATORS' => 5, + ); + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_permission.xml'); @@ -158,4 +164,60 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case } $this->assertFalse($this->tool->exists('global_test', true)); } + + public function test_permission_set_data() + { + return array( + array( + 'ADMINISTRATORS', + 'a_test', + 'group', + true, + ), + array( + 'GLOBAL_MODERATORS', + 'm_test', + 'group', + true, + ), + array( + 'REGISTERED', + 'u_test', + 'group', + true, + ), + ); + } + + /** + * @dataProvider test_permission_set_data + */ + public function test_permission_set($group_name, $auth_option, $type, $has_permission) + { + $this->tool->permission_set($group_name, $auth_option, $type, $has_permission); + $administrators_perm = $this->auth->acl_group_raw_data($this->group_ids['ADMINISTRATORS'], $auth_option); + $global_moderators_perm = $this->auth->acl_group_raw_data($this->group_ids['GLOBAL_MODERATORS'], $auth_option); + $registered_users_perm = $this->auth->acl_group_raw_data($this->group_ids['REGISTERED'], $auth_option); + + switch($group_name) + { + case 'GLOBAL_MODERATORS': + $this->assertEquals(false, empty($administrators_perm), 'm_test is not empty for Administrators'); + $this->assertEquals(false, empty($global_moderators_perm), 'm_test is not empty for Global moderators'); + $this->assertEquals(true, empty($registered_users_perm), 'm_test empty for Registered users'); + break; + + case 'ADMINISTRATORS': + $this->assertEquals(false, empty($administrators_perm), 'a_test is not empty for Administrators'); + $this->assertEquals(true, empty($global_moderators_perm), 'a_test is empty for Global moderators'); + $this->assertEquals(true, empty($registered_users_perm), 'a_test is empty for Registered users'); + break; + + case 'REGISTERED': + $this->assertEquals(false, empty($administrators_perm), 'u_test is not empty for Administrators'); + $this->assertEquals(false, empty($global_moderators_perm), 'u_test is not empty for Global moderators'); + $this->assertEquals(false, empty($registered_users_perm), 'u_test is not empty for Registered users'); + break; + } + } } From c78ee4e2011b50232066e86ca651c93bea2606e1 Mon Sep 17 00:00:00 2001 From: AJ Quick Date: Sun, 15 Mar 2015 17:47:01 -0600 Subject: [PATCH 183/239] [ticket/13923] Update startup.php While suppressing the output from the 'set_magic_quotes_runtime(0)' is sufficient with normal phpBB installs, using this file in association with the oauth plugin will cause an error on some versions of PHP. This fixes a potential bug where set_magic_quotes_runtime is depreciated in newer versions of PHP. PHPBB3-13923 --- phpBB/includes/startup.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 2885c80541..2a25e6975b 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -94,7 +94,11 @@ if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) } else { - @set_magic_quotes_runtime(0); + if(get_magic_quotes_runtime()) + { + // Deactivate + @set_magic_quotes_runtime(0); + } // Be paranoid with passed vars if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on' || !function_exists('ini_get')) From a620651ca1fbd9eb42bfbe9e5d093a2a92590548 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 6 Jun 2015 10:30:09 -0700 Subject: [PATCH 184/239] [ticket/13818] Add browse CDB links to ext style lang management PHPBB3-13818 --- phpBB/adm/style/acp_ext_list.html | 8 +++++++- phpBB/adm/style/acp_language.html | 4 ++++ phpBB/adm/style/acp_styles.html | 6 +++++- phpBB/language/en/acp/extensions.php | 8 ++++++++ phpBB/language/en/acp/language.php | 2 ++ phpBB/language/en/acp/styles.php | 2 ++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index f96da7e26a..f61be27c9b 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -7,7 +7,7 @@

{L_EXTENSIONS_EXPLAIN}

- {L_VERSIONCHECK_FORCE_UPDATE_ALL}{L_SETTINGS} + {L_BROWSE_EXTENSIONS_DATABASE}{L_VERSIONCHECK_FORCE_UPDATE_ALL}{L_SETTINGS}