From 49de9e3d444ab71a2ad1e5ac1db6d92e3cb80466 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 2 Mar 2013 15:03:13 -0600 Subject: [PATCH 001/172] [ticket/11387] Log module added only after it has been added PHPBB3-11387 --- phpBB/includes/db/migration/tool/module.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index 6ffb073543..3ba82d8a0f 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -209,9 +209,6 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac } // The "manual" way - $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); - add_log('admin', 'LOG_MODULE_ADD', $module_log_name); - if (!is_numeric($parent)) { $sql = 'SELECT module_id @@ -267,6 +264,8 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac else { // Success + $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); + add_log('admin', 'LOG_MODULE_ADD', $module_log_name); // Move the module if requested above/below an existing one if (isset($data['before']) && $data['before']) From 58d7acbf5a4483f7e2ebac6d9ed38189c48facfb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 17 Mar 2013 19:54:32 +0100 Subject: [PATCH 002/172] [ticket/11452] Now notification_method_email checks whether user has address. Make sure the user has an email address set before offering email notifications. The address could be missing for whatever reason, e.g. external authentication. This is also consistent with XMPP/Jabber now. PHPBB3-11452 --- phpBB/includes/notification/method/email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index 4a7fea6df3..2cd1ba3ef6 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -53,7 +53,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base */ public function is_available() { - return (bool) $this->config['email_enable']; + return $this->config['email_enable'] && $this->user->data['user_email']; } /** From aefca4b40f67bc4d0cc52c8f89705148237a5f05 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 21 Mar 2013 14:59:53 +0100 Subject: [PATCH 003/172] [ticket/11465] Use extension finder when adding extensions' acp modules The method acp_modules::get_module_infos() needs to use the extension finder whenever it is looking for a module's info file. While transitioning to the new extension system, only the initial search for all module info files was changed to the new system. Due to this it is not possible to add an extension's acp/mcp/ucp module manually in the ACP. This patch will always use the extension finder for the acp module's info files and therefore properly find the needed file. Additionally, the code has been cleaned up a little bit. PHPBB3-11465 --- phpBB/includes/acp/acp_modules.php | 74 +++++++++++------------------- 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 7c2ea86122..9cf6bf0214 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -544,81 +544,59 @@ class acp_modules */ function get_module_infos($module = '', $module_class = false, $use_all_available = false) { - global $phpbb_root_path, $phpEx; + global $phpbb_extension_manager, $phpbb_root_path, $phpEx; $module_class = ($module_class === false) ? $this->module_class : $module_class; $directory = $phpbb_root_path . 'includes/' . $module_class . '/info/'; $fileinfo = array(); - if (!$module) + $finder = $phpbb_extension_manager->get_finder(); + + $modules = $finder + ->extension_suffix('_module') + ->extension_directory("/$module_class") + ->core_path("includes/$module_class/info/") + ->core_prefix($module_class . '_') + ->get_classes(true, $use_all_available); + + foreach ($modules as $cur_module) { - global $phpbb_extension_manager; - - $finder = $phpbb_extension_manager->get_finder(); - - $modules = $finder - ->extension_suffix('_module') - ->extension_directory("/$module_class") - ->core_path("includes/$module_class/info/") - ->core_prefix($module_class . '_') - ->get_classes(true, $use_all_available); - - foreach ($modules as $module) + // Skip entries we do not need if we know the module we are + // looking for + if ($module && strpos($cur_module, $module) === false) { - $info_class = preg_replace('/_module$/', '_info', $module); - - // If the class does not exist it might be following the old - // format. phpbb_acp_info_acp_foo needs to be turned into - // acp_foo_info and the respective file has to be included - // manually because it does not support auto loading - if (!class_exists($info_class)) - { - $info_class = str_replace("phpbb_{$module_class}_info_", '', $module) . '_info'; - if (file_exists($directory . $info_class . '.' . $phpEx)) - { - include($directory . $info_class . '.' . $phpEx); - } - } - - if (class_exists($info_class)) - { - $info = new $info_class(); - $module_info = $info->module(); - - $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module; - - $fileinfo[$main_class] = $module_info; - } + continue; } - ksort($fileinfo); - } - else - { - $info_class = preg_replace('/_module$/', '_info', $module); + $info_class = preg_replace('/_module$/', '_info', $cur_module); + // If the class does not exist it might be following the old + // format. phpbb_acp_info_acp_foo needs to be turned into + // acp_foo_info and the respective file has to be included + // manually because it does not support auto loading if (!class_exists($info_class)) { - $info_class = $module . '_info'; - if (!class_exists($info_class) && file_exists($directory . $module . '.' . $phpEx)) + $info_class = str_replace("phpbb_{$module_class}_info_", '', $cur_module) . '_info'; + if (file_exists($directory . $info_class . '.' . $phpEx)) { - include($directory . $module . '.' . $phpEx); + include($directory . $info_class . '.' . $phpEx); } } - // Get module title tag if (class_exists($info_class)) { $info = new $info_class(); $module_info = $info->module(); - $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module; + $main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $cur_module; $fileinfo[$main_class] = $module_info; } } + ksort($fileinfo); + return $fileinfo; } From fadcee77b9ac652655f1dffb07979ac59b78b140 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 22 Mar 2013 10:12:39 +0100 Subject: [PATCH 004/172] [ticket/11465] Add unit tests for acp_modules::get_module_infos() The tests add 3 different modules. One acp module that should be found (acp/a_module), one acp module that should not be found (acp/fail_module), and one mcp module that should work again (mcp/a_module). The modules' info files had to be included as they were not auto-loaded for some reason. There are several test stages. First of, it is tested if the correct mcp and acp module is returned. Afterwards, the proper loading of specified modules is tested. One with an existing module and one with a not existing module. Finally, the test concludes with trying to get the module info of not existing ucp modules. Other classes like foobar would have also worked for that check but I decided to use the ucp type of class as that is the one type missing from the added test modules. PHPBB3-11465 --- tests/extension/ext/foo/acp/a_info.php | 16 ++++ tests/extension/ext/foo/acp/a_module.php | 5 ++ tests/extension/ext/foo/acp/fail_info.php | 16 ++++ tests/extension/ext/foo/acp/fail_module.php | 5 ++ tests/extension/ext/foo/mcp/a_info.php | 16 ++++ tests/extension/ext/foo/mcp/a_module.php | 5 ++ tests/extension/modules_test.php | 95 +++++++++++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 tests/extension/ext/foo/acp/a_info.php create mode 100644 tests/extension/ext/foo/acp/a_module.php create mode 100644 tests/extension/ext/foo/acp/fail_info.php create mode 100644 tests/extension/ext/foo/acp/fail_module.php create mode 100644 tests/extension/ext/foo/mcp/a_info.php create mode 100644 tests/extension/ext/foo/mcp/a_module.php create mode 100644 tests/extension/modules_test.php diff --git a/tests/extension/ext/foo/acp/a_info.php b/tests/extension/ext/foo/acp/a_info.php new file mode 100644 index 0000000000..3e9bbffaca --- /dev/null +++ b/tests/extension/ext/foo/acp/a_info.php @@ -0,0 +1,16 @@ + 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ); + } +} diff --git a/tests/extension/ext/foo/acp/a_module.php b/tests/extension/ext/foo/acp/a_module.php new file mode 100644 index 0000000000..093b4b1ad7 --- /dev/null +++ b/tests/extension/ext/foo/acp/a_module.php @@ -0,0 +1,5 @@ + 'phpbb_ext_foo_acp_fail_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ); + } +} diff --git a/tests/extension/ext/foo/acp/fail_module.php b/tests/extension/ext/foo/acp/fail_module.php new file mode 100644 index 0000000000..dd16955418 --- /dev/null +++ b/tests/extension/ext/foo/acp/fail_module.php @@ -0,0 +1,5 @@ + 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ); + } +} diff --git a/tests/extension/ext/foo/mcp/a_module.php b/tests/extension/ext/foo/mcp/a_module.php new file mode 100644 index 0000000000..59d9f8cc6f --- /dev/null +++ b/tests/extension/ext/foo/mcp/a_module.php @@ -0,0 +1,5 @@ +extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'foo' => array( + 'ext_name' => 'foo', + 'ext_active' => '1', + 'ext_path' => 'ext/foo/', + ), + 'bar' => array( + 'ext_name' => 'bar', + 'ext_active' => '1', + 'ext_path' => 'ext/bar/', + ), + )); + $phpbb_extension_manager = $this->extension_manager; + + $this->acp_modules = new acp_modules(); + } + + public function test_get_module_infos() + { + // the modules' info files needs to be included before the test for + // some reason ... + require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; + require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; + require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; + + $this->acp_modules->module_class = 'acp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array( + 'phpbb_ext_foo_acp_a_module' => array( + 'filename' => 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ), + ), $acp_modules); + + $this->acp_modules->module_class = 'mcp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array( + 'phpbb_ext_foo_mcp_a_module' => array( + 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ), + ), $acp_modules); + + $this->acp_modules->module_class = 'mcp'; + $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); + $this->assertEquals(array( + 'phpbb_ext_foo_mcp_a_module' => array( + 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ), + ), $acp_modules); + + $this->acp_modules->module_class = 'mcp'; + $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); + $this->assertEquals(array(), $acp_modules); + + $this->acp_modules->module_class = 'ucp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array(), $acp_modules); + } +} From 11477a3f18078625d79205e4ab488a25ead7d15d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 22 Mar 2013 13:29:30 +0100 Subject: [PATCH 005/172] [ticket/11465] Move require_once() in unit test to the top of the file PHPBB3-11465 --- tests/extension/modules_test.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 52ec3503e7..36f54fde32 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -7,7 +7,10 @@ * */ -require_once dirname(__FILE__) . './../../phpBB/includes/acp/acp_modules.php'; +require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; +require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; +require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; class phpbb_extension_modules_test extends phpbb_test_case { @@ -39,12 +42,6 @@ class phpbb_extension_modules_test extends phpbb_test_case public function test_get_module_infos() { - // the modules' info files needs to be included before the test for - // some reason ... - require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; - require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; - require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; - $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( From 323a494cd16bd202d89260f756519c2d76f2f9fe Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Mon, 25 Mar 2013 18:21:48 -0400 Subject: [PATCH 006/172] [ticket/11458] Search for permission language files in extensions Extensions that add new permission masks only need to add a permission file in the language folder of the extension. The file must start with 'permissions_' eg 'permissions_blog.php'. The permission language file will be automatically included when viewing/setting permissions. PHPBB3-11458 --- phpBB/includes/functions_admin.php | 37 ++++++++++-------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index d273b9fb3a..5d71f55d1a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3040,38 +3040,25 @@ function tidy_database() */ function add_permission_language() { - global $user, $phpEx; + global $user, $phpEx, $phpbb_extension_manager; // First of all, our own file. We need to include it as the first file because it presets all relevant variables. $user->add_lang('acp/permissions_phpbb'); - $files_to_add = array(); + // add permission language files from extensions + $finder = $phpbb_extension_manager->get_finder(); - // Now search in acp and mods folder for permissions_ files. - foreach (array('acp/', 'mods/') as $path) + $lang_files = $finder + ->prefix('permissions_') + ->suffix(".$phpEx") + ->extension_directory('/language/' . $user->lang_name) + ->core_path('language/' . $user->lang_name . '/mods') + ->find(); + + foreach ($lang_files as $lang_file => $ext_name) { - $dh = @opendir($user->lang_path . $user->lang_name . '/' . $path); - - if ($dh) - { - while (($file = readdir($dh)) !== false) - { - if ($file !== 'permissions_phpbb.' . $phpEx && strpos($file, 'permissions_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) - { - $files_to_add[] = $path . substr($file, 0, -(strlen($phpEx) + 1)); - } - } - closedir($dh); - } + $user->add_lang_ext($ext_name, $lang_file); } - - if (!sizeof($files_to_add)) - { - return false; - } - - $user->add_lang($files_to_add); - return true; } /** From 29a5db25ec21a8b349195d01bdd0cfea09814653 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 7 Apr 2013 19:12:04 +0300 Subject: [PATCH 007/172] [ticket/11482] Implementation of advanced DEFINE tag Implementation of advanced DEFINE tag and ENDDEFINE PHPBB3-11482 --- phpBB/includes/template/filter.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 9e8ad2fef0..a3894905e5 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -329,6 +329,10 @@ class phpbb_template_filter extends php_user_filter return 'compile_tag_define($matches[2], false) . ' ?>'; break; + case 'ENDDEFINE': + return 'compile_tag_enddefine() . ' ?>'; + break; + case 'INCLUDE': return 'compile_tag_include($matches[2]) . ' ?>'; break; @@ -833,6 +837,16 @@ class phpbb_template_filter extends php_user_filter $match = array(); preg_match('#^((?:' . self::REGEX_NS . '\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (.*?))?$#', $tag_args, $match); + if (!empty($match[2]) && !isset($match[3]) && $op) + { + // DEFINE tag with ENDDEFINE + $array = '$_tpldata[\'DEFINE\'][\'.vars\']'; + $code = 'ob_start(); '; + $code .= 'if (!isset(' . $array . ')) { ' . $array . ' = array(); } '; + $code .= $array . '[] = \'' . $match[2] . '\''; + return $code; + } + if (empty($match[2]) || (!isset($match[3]) && $op)) { return ''; @@ -859,6 +873,20 @@ class phpbb_template_filter extends php_user_filter return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $parsed_statement . ';'; } + /** + * Compile ENDDEFINE tag + * + * @return string compiled template code + */ + private function compile_tag_enddefine() + { + $array = '$_tpldata[\'DEFINE\'][\'.vars\']'; + $code = 'if (!isset(' . $array . ') || !sizeof(' . $array . ')) { trigger_error(\'ENDDEFINE tag without DEFINE in \' . basename(__FILE__), E_USER_ERROR); }'; + $code .= '$define_var = array_pop(' . $array . '); '; + $code .= '$_tpldata[\'DEFINE\'][\'.\'][$define_var] = ob_get_clean();'; + return $code; + } + /** * Compile INCLUDE tag * From 5e8d92b0a84cf6ffbaefe1af5f2efd947e25aa1a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 10 Apr 2013 09:00:34 +0300 Subject: [PATCH 008/172] [ticket/11482] Unit tests for advanced DEFINE Unit tests for advanced DEFINE and ENDDEFINE PHPBB3-11482 --- tests/template/template_test.php | 14 ++++++++++++++ tests/template/templates/define.html | 2 -- tests/template/templates/define_advanced.html | 12 ++++++++++++ tests/template/templates/define_include2.html | 11 +++++++++++ tests/template/templates/define_unclosed.html | 2 ++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/template/templates/define_advanced.html create mode 100644 tests/template/templates/define_include2.html create mode 100644 tests/template/templates/define_unclosed.html diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 56cc7a9de5..a3c0b69123 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -132,6 +132,20 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "xyz\nabc\nabc\nbar\nbar\nabc", ), + array( + 'define_advanced.html', + array(), + array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), + array(), + "abc\nzxc\ncde\nbcd", + ), + array( + 'define_unclosed.html', + array(), + array(), + array(), + "test", + ), array( 'expressions.html', array(), diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index 4459fffbe0..4e6d0ee793 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -7,5 +7,3 @@ {$VALUE} {$VALUE} - - diff --git a/tests/template/templates/define_advanced.html b/tests/template/templates/define_advanced.html new file mode 100644 index 0000000000..83467a5b4b --- /dev/null +++ b/tests/template/templates/define_advanced.html @@ -0,0 +1,12 @@ + +abc + +{$VALUE} + +bcd + + +cde + + +{$INCLUDED_VALUE3} diff --git a/tests/template/templates/define_include2.html b/tests/template/templates/define_include2.html new file mode 100644 index 0000000000..874f3e1852 --- /dev/null +++ b/tests/template/templates/define_include2.html @@ -0,0 +1,11 @@ + +zxc + + +qwe + +{$INCLUDED_VALUE1} + +{$VALUE2} +{$VALUE1} + diff --git a/tests/template/templates/define_unclosed.html b/tests/template/templates/define_unclosed.html new file mode 100644 index 0000000000..1c975eab2b --- /dev/null +++ b/tests/template/templates/define_unclosed.html @@ -0,0 +1,2 @@ + +test From 6110380a35ec2bca1dc953e8dfd67b1131bb1e59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Apr 2013 13:07:25 +0200 Subject: [PATCH 009/172] [ticket/11465] Add phpBB module to test PHPBB3-11465 --- tests/extension/includes/acp/acp_foobar.php | 28 +++++++++++++++++++ .../includes/acp/info/acp_foobar.php | 26 +++++++++++++++++ tests/extension/modules_test.php | 8 ++++++ 3 files changed, 62 insertions(+) create mode 100644 tests/extension/includes/acp/acp_foobar.php create mode 100644 tests/extension/includes/acp/info/acp_foobar.php diff --git a/tests/extension/includes/acp/acp_foobar.php b/tests/extension/includes/acp/acp_foobar.php new file mode 100644 index 0000000000..c256a432e2 --- /dev/null +++ b/tests/extension/includes/acp/acp_foobar.php @@ -0,0 +1,28 @@ + 'acp_foobar', + 'title' => 'ACP Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), + ), + ); + } +} diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 36f54fde32..9849ad2ca4 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -53,6 +53,14 @@ class phpbb_extension_modules_test extends phpbb_test_case 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), ), ), + 'acp_foobar' => array( + 'filename' => 'acp_foobar', + 'title' => 'ACP Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), + ), + ), ), $acp_modules); $this->acp_modules->module_class = 'mcp'; From 78bcc31a5d0cb01a4748f184fddd00a9b50f09f1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Apr 2013 13:08:31 +0200 Subject: [PATCH 010/172] [ticket/11465] The info file does not have _info suffix PHPBB3-11465 --- phpBB/includes/acp/acp_modules.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 9cf6bf0214..62af12ad32 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -577,10 +577,11 @@ class acp_modules // manually because it does not support auto loading if (!class_exists($info_class)) { - $info_class = str_replace("phpbb_{$module_class}_info_", '', $cur_module) . '_info'; - if (file_exists($directory . $info_class . '.' . $phpEx)) + $info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); + $info_class = $info_class_file . '_info'; + if (file_exists($directory . $info_class_file . '.' . $phpEx)) { - include($directory . $info_class . '.' . $phpEx); + include($directory . $info_class_file . '.' . $phpEx); } } From bc423f0d97e1cc531aa78505317e85604e57b88d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Apr 2013 13:11:13 +0200 Subject: [PATCH 011/172] [ticket/11465] Correctly set the root path for the test PHPBB3-11465 --- tests/extension/modules_test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index 9849ad2ca4..675fb1f4a0 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -42,6 +42,11 @@ class phpbb_extension_modules_test extends phpbb_test_case public function test_get_module_infos() { + global $phpbb_root_path; + + // Correctly set the root path for this test to this directory, so the classes can be found + $phpbb_root_path = dirname(__FILE__) . '/'; + $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( From 8567aaed324eb87856ee6274f8330c52beecd0a3 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 10 Apr 2013 20:12:03 +0300 Subject: [PATCH 012/172] [ticket/11482] Use double quotes for code Use double quotes for code to avoid excessive escaping PHPBB3-11482 --- phpBB/includes/template/filter.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index a3894905e5..5b0957280d 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -840,10 +840,10 @@ class phpbb_template_filter extends php_user_filter if (!empty($match[2]) && !isset($match[3]) && $op) { // DEFINE tag with ENDDEFINE - $array = '$_tpldata[\'DEFINE\'][\'.vars\']'; + $array = "\$_tpldata['DEFINE']['.vars']"; $code = 'ob_start(); '; - $code .= 'if (!isset(' . $array . ')) { ' . $array . ' = array(); } '; - $code .= $array . '[] = \'' . $match[2] . '\''; + $code .= "if (!isset($array)) { $array = array(); } "; + $code .= "{$array}[] = '{$match[2]}'"; return $code; } @@ -880,10 +880,10 @@ class phpbb_template_filter extends php_user_filter */ private function compile_tag_enddefine() { - $array = '$_tpldata[\'DEFINE\'][\'.vars\']'; - $code = 'if (!isset(' . $array . ') || !sizeof(' . $array . ')) { trigger_error(\'ENDDEFINE tag without DEFINE in \' . basename(__FILE__), E_USER_ERROR); }'; - $code .= '$define_var = array_pop(' . $array . '); '; - $code .= '$_tpldata[\'DEFINE\'][\'.\'][$define_var] = ob_get_clean();'; + $array = "\$_tpldata['DEFINE']['.vars']"; + $code = "if (!isset($array) || !sizeof($array)) { trigger_error('ENDDEFINE tag without DEFINE in ' . basename(__FILE__), E_USER_ERROR); }"; + $code .= "\$define_var = array_pop($array); "; + $code .= "\$_tpldata['DEFINE']['.'][\$define_var] = ob_get_clean();"; return $code; } From 88072fd6c2c3ec6cc6d2a880bd76a9c601fd0767 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 9 Apr 2013 18:38:59 +0300 Subject: [PATCH 013/172] [ticket/10741] Function to resize textarea elements New function to automatically resize textarea elements as user types text PHPBB3-10741 --- phpBB/assets/javascript/core.js | 85 +++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 8bbea8b8c9..6fe71d141a 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -568,4 +568,89 @@ phpbb.addAjaxCallback('toggle_link', function() { el.parent().attr('class', toggleClass); }); +/** +* Automatically resize textarea +* +* This function automatically resizes textarea elements when user +* types text. +* +* @param jQuery item jQuery object to resize +* @param object options Optional parameter that adjusts default +* configuration. See configuration variable +*/ +phpbb.resizeTextArea = function(items) { + // Configuration + var configuration = { + minWindowHeight: 500, // Minimum browser window height when textareas are resized + minHeight: 200, // Minimum height of textarea + maxHeight: 500, // Maximum height of textarea + heightDiff: 200, // Minimum difference between window and textarea height + // In following callbacks parameter "item" is jQuery object. "this" points to DOM object + resizeCallback: function(item) { }, // Function to call after resizing textarea. + resetCallback: function(item) { } // Function to call when resize has been canceled + } + + if (arguments.length > 1) + { + configuration = $.extend(configuration, arguments[1]); + } + + function resetAutoResize(item) + { + var $item = $(item); + if ($item.hasClass('auto-resized')) + { + $(item).css('height', '').removeClass('auto-resized'); + configuration.resetCallback.call(item, $item); + } + }; + + function autoResize(item) + { + function setHeight(height) + { + $item.css('height', height + 'px').addClass('auto-resized'); + configuration.resizeCallback.call(item, $item); + } + + var windowHeight = $(window).height(); + + if (windowHeight < configuration.minWindowHeight) + { + resetAutoResize(item); + return; + } + + var maxHeight = Math.min(Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), configuration.maxHeight), + $item = $(item), + height = parseInt($item.height()), + scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; + + if (height > maxHeight) + { + setHeight(maxHeight); + } + else if (scrollHeight > (height + 5)) + { + setHeight(Math.min(maxHeight, scrollHeight)); + } + }; + + items.bind('focus change keyup', function() { + $(this).each(function() { + autoResize(this); + }); + }).css('resize', 'none').change(); + + $(window).resize(function() { + items.each(function() { + if ($(this).hasClass('auto-resized')) + { + autoResize(this); + } + }); + }); +}; + + })(jQuery); // Avoid conflicts with other libraries From 316efcbbbb72058bb9986be08af3d11173817386 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 9 Apr 2013 18:39:47 +0300 Subject: [PATCH 014/172] [ticket/10741] Automatically resize textareas in prosilver and ACP Automatically resize textareas in prosilver and ACP. PHPBB3-10741 --- phpBB/adm/style/ajax.js | 6 ++++++ phpBB/styles/prosilver/template/ajax.js | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 8f7c210e00..8211bdd014 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -148,6 +148,12 @@ $('[data-ajax]').each(function() { } }); +/** +* Automatically resize textarea +*/ +$(document).ready(function() { + phpbb.resizeTextArea($('textarea'), {minHeight: 75}); +}); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 8dd1f58c97..e7dfe95009 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -225,4 +225,13 @@ $('#member_search').click(function () { return false; }); +/** +* Automatically resize textarea +*/ +$(document).ready(function() { + phpbb.resizeTextArea($('textarea:not(#message-box textarea)'), {minHeight: 75, maxHeight: 250}); + phpbb.resizeTextArea($('#message-box textarea')); +}); + + })(jQuery); // Avoid conflicts with other libraries From 67f0e19128415210f0ece4a8cd3df12e4b35eaf6 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 9 Apr 2013 18:47:08 +0300 Subject: [PATCH 015/172] [ticket/10741] Do not resize textarea.no-auto-resize Do not auto-resize textareas with class .no-auto-resize PHPBB3-10741 --- phpBB/adm/style/ajax.js | 2 +- phpBB/styles/prosilver/template/ajax.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 8211bdd014..6f21dfa6ac 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -152,7 +152,7 @@ $('[data-ajax]').each(function() { * Automatically resize textarea */ $(document).ready(function() { - phpbb.resizeTextArea($('textarea'), {minHeight: 75}); + phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75}); }); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index e7dfe95009..2528b96ece 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -229,7 +229,7 @@ $('#member_search').click(function () { * Automatically resize textarea */ $(document).ready(function() { - phpbb.resizeTextArea($('textarea:not(#message-box textarea)'), {minHeight: 75, maxHeight: 250}); + phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250}); phpbb.resizeTextArea($('#message-box textarea')); }); From cbb9f084fce0fd42ed1481233f417c79e8a0abfa Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 10 Apr 2013 09:08:25 +0300 Subject: [PATCH 016/172] [ticket/10741] Fix for browser-specific resizing of textarea Disable browser-specific resizing only after textarea has been resized Enable browser-specific resizing after script resizing has been reset PHPBB3-10741 --- phpBB/assets/javascript/core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 6fe71d141a..827ed2e34a 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -600,7 +600,7 @@ phpbb.resizeTextArea = function(items) { var $item = $(item); if ($item.hasClass('auto-resized')) { - $(item).css('height', '').removeClass('auto-resized'); + $(item).css({height: '', resize: ''}).removeClass('auto-resized'); configuration.resetCallback.call(item, $item); } }; @@ -609,7 +609,7 @@ phpbb.resizeTextArea = function(items) { { function setHeight(height) { - $item.css('height', height + 'px').addClass('auto-resized'); + $item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized'); configuration.resizeCallback.call(item, $item); } @@ -640,7 +640,7 @@ phpbb.resizeTextArea = function(items) { $(this).each(function() { autoResize(this); }); - }).css('resize', 'none').change(); + }).change(); $(window).resize(function() { items.each(function() { From 474b4a60a527a4c0cd853872ce80ae50fdd2f374 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 13 Apr 2013 10:49:59 -0400 Subject: [PATCH 017/172] [ticket/11458] We still auto add language files from the mods and acp folders in the language directory, so we revert some changes here PHPBB3-11458 --- phpBB/includes/functions_admin.php | 35 ++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5d71f55d1a..b5efa49159 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3045,20 +3045,47 @@ function add_permission_language() // First of all, our own file. We need to include it as the first file because it presets all relevant variables. $user->add_lang('acp/permissions_phpbb'); - // add permission language files from extensions + $files_to_add = array(); + + // Now search in acp and mods folder for permissions_ files. + foreach (array('acp/', 'mods/') as $path) + { + $dh = @opendir($user->lang_path . $user->lang_name . '/' . $path); + + if ($dh) + { + while (($file = readdir($dh)) !== false) + { + if ($file !== 'permissions_phpbb.' . $phpEx && strpos($file, 'permissions_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) + { + $files_to_add[] = $path . substr($file, 0, -(strlen($phpEx) + 1)); + } + } + closedir($dh); + } + } + + // find permission language files from extensions $finder = $phpbb_extension_manager->get_finder(); - $lang_files = $finder + $ext_lang_files = $finder ->prefix('permissions_') ->suffix(".$phpEx") ->extension_directory('/language/' . $user->lang_name) - ->core_path('language/' . $user->lang_name . '/mods') ->find(); - foreach ($lang_files as $lang_file => $ext_name) + foreach ($ext_lang_files as $lang_file => $ext_name) { $user->add_lang_ext($ext_name, $lang_file); } + + if (!sizeof($files_to_add)) + { + return false; + } + + $user->add_lang($files_to_add); + return true; } /** From 84c815a12e7c2c816035e3b05e8ea7c88f0f4534 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 13 Apr 2013 11:24:47 -0400 Subject: [PATCH 018/172] [ticket/11458] Add functional test Since there is no test method to include extension language files, a functional test seems more appropriate. We add a permission mask 'acl_u_foo' with translation found in extenion 'bar' and confirm that the permission language file 'permissions_foo.php' from 'bar' was added by asserting that 'Can view foo' exists when viewing user permissions in acp PHPBB3-11458 --- .../extension_permission_lang_test.php | 59 +++++++++++++++++++ .../foo/bar/language/en/permissions_foo.php | 6 ++ 2 files changed, 65 insertions(+) create mode 100644 tests/functional/extension_permission_lang_test.php create mode 100644 tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php new file mode 100644 index 0000000000..c3d136de49 --- /dev/null +++ b/tests/functional/extension_permission_lang_test.php @@ -0,0 +1,59 @@ +phpbb_extension_manager = $this->get_extension_manager(); + + $this->purge_cache(); + + $this->login(); + $this->admin_login(); + $this->add_lang('acp/permissions'); + } + + public function test_auto_include_permission_lang_from_extensions() + { + $this->phpbb_extension_manager->enable('foo/bar'); + + // User permissions + $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains('Can view foo', $this->client->getResponse()->getContent()); + } + + public function permissions_data() + { + return array( + // description + // permission type + // permission name + // mode + // object name + // object id + array( + 'user permission', + 'u_', + 'acl_u_foo', + 'setting_user_global', + 'user_id', + 2, + ), + ); + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php new file mode 100644 index 0000000000..cd4b9a32d1 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php @@ -0,0 +1,6 @@ + array('lang' => 'Can view foo', 'cat' => 'misc'), +)); From 2c910999b090502cf6a3ac2add68de763ea897ca Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 13 Apr 2013 13:56:02 -0400 Subject: [PATCH 019/172] [ticket/11458] Fix test PHPBB-11458 --- tests/functional/extension_permission_lang_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index c3d136de49..1368a628d8 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -34,7 +34,14 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t // User permissions $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains('Can view foo', $this->client->getResponse()->getContent()); + + // Select admin + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $data = array('username[0]' => 'admin'); + $form->setValues($data); + $crawler = $this->client->submit($form); + $this->assert_response_success(); + $this->assertContains('Can view foo', $crawler->filter('body')->text()); } public function permissions_data() From 7240759e34d4e67fbce632c03ae6818aad36a07c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 14 Apr 2013 17:25:45 +0200 Subject: [PATCH 020/172] [ticket/11465] Check if class exists before including info file PHPBB3-11465 --- phpBB/includes/acp/acp_modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 62af12ad32..ab416fb406 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -579,7 +579,7 @@ class acp_modules { $info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); $info_class = $info_class_file . '_info'; - if (file_exists($directory . $info_class_file . '.' . $phpEx)) + if (!class_exists($info_class) && file_exists($directory . $info_class_file . '.' . $phpEx)) { include($directory . $info_class_file . '.' . $phpEx); } From 9e2acdab9aea7762761e81b3306a950ab627434d Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sun, 14 Apr 2013 17:53:38 -0400 Subject: [PATCH 021/172] [ticket/11458] Fix functional test again Add 'u_foo' to phpbb_acl_options Make sure extension and fixtures are added before running test PHPBB3-11458 --- .../extension_permission_lang_test.php | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 1368a628d8..234cbbbaf2 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -14,9 +14,73 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t { protected $phpbb_extension_manager; + static protected $fixtures = array( + 'foo/bar/language/en/permissions_foo.php', + ); + + /** + * This should only be called once before the tests are run. + * This is used to copy the fixtures to the phpBB install + */ + static public function setUpBeforeClass() + { + global $phpbb_root_path; + parent::setUpBeforeClass(); + + $directories = array( + $phpbb_root_path . 'ext/foo/bar/', + $phpbb_root_path . 'ext/foo/bar/language/', + $phpbb_root_path . 'ext/foo/bar/language/en/', + ); + + foreach ($directories as $dir) + { + if (!is_dir($dir)) + { + mkdir($dir, 0777, true); + } + } + + foreach (self::$fixtures as $fixture) + { + copy( + "tests/functional/fixtures/ext/$fixture", + "{$phpbb_root_path}ext/$fixture"); + } + } + + /** + * This should only be called once after the tests are run. + * This is used to remove the fixtures from the phpBB install + */ + static public function tearDownAfterClass() + { + global $phpbb_root_path; + + foreach (self::$fixtures as $fixture) + { + unlink("{$phpbb_root_path}ext/$fixture"); + } + + rmdir("{$phpbb_root_path}ext/foo/bar/language/en"); + rmdir("{$phpbb_root_path}ext/foo/bar/language"); + rmdir("{$phpbb_root_path}ext/foo/bar"); + rmdir("{$phpbb_root_path}ext/foo"); + } + public function setUp() { parent::setUp(); + + $this->get_db(); + + $acl_ary = array( + 'auth_option' => 'u_foo', + 'is_global' => 1, + ); + + $sql = 'INSERT INTO phpbb_acl_options ' . $this->db->sql_build_array('INSERT', $acl_ary); + $this->db->sql_query($sql); $this->phpbb_extension_manager = $this->get_extension_manager(); @@ -43,24 +107,4 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $this->assert_response_success(); $this->assertContains('Can view foo', $crawler->filter('body')->text()); } - - public function permissions_data() - { - return array( - // description - // permission type - // permission name - // mode - // object name - // object id - array( - 'user permission', - 'u_', - 'acl_u_foo', - 'setting_user_global', - 'user_id', - 2, - ), - ); - } } From 198b992dcef0a0a7099eb3db6185d567b58b6e5a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 28 Apr 2013 22:53:05 -0500 Subject: [PATCH 022/172] [ticket/11413] Schema changes and migration file Notifications tables are dropped because phpBB currently does not have any way to make the necessary changes to the DB schema (and no release has yet been made with these changes). This will fix the following bugs: PHPBB3-11411 PHPBB3-11413 PHPBB3-11414 PHPBB3-11416 PHPBB3-11420 PHPBB3-11413 --- phpBB/develop/create_schema_files.php | 26 ++- .../db/migration/data/310/notifications.php | 64 ------ .../db/migration/data/310/notifications2.php | 206 ++++++++++++++++++ phpBB/install/schemas/firebird_schema.sql | 23 +- phpBB/install/schemas/mssql_schema.sql | 15 +- phpBB/install/schemas/mysql_40_schema.sql | 14 +- phpBB/install/schemas/mysql_41_schema.sql | 14 +- phpBB/install/schemas/oracle_schema.sql | 30 ++- phpBB/install/schemas/postgres_schema.sql | 14 +- phpBB/install/schemas/sqlite_schema.sql | 13 +- 10 files changed, 304 insertions(+), 115 deletions(-) create mode 100644 phpBB/includes/db/migration/data/310/notifications2.php diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index b454fb2c16..3121db391d 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1317,16 +1317,20 @@ function get_schema_struct() $schema_data['phpbb_notification_types'] = array( 'COLUMNS' => array( - 'notification_type' => array('VCHAR:255', ''), + 'notification_type_id' => array('USINT', NULL, 'auto_increment'), + 'notification_type_name' => array('VCHAR:255', ''), 'notification_type_enabled' => array('BOOL', 1), ), - 'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'), + 'PRIMARY_KEY' => array('notification_type_id'), + 'KEYS' => array( + 'type' => array('UNIQUE', array('notification_type_name')), + ), ); $schema_data['phpbb_notifications'] = array( 'COLUMNS' => array( - 'notification_id' => array('UINT', NULL, 'auto_increment'), - 'item_type' => array('VCHAR:255', ''), + 'notification_id' => array('UINT:10', NULL, 'auto_increment'), + 'notification_type_id' => array('USINT', 0), 'item_id' => array('UINT', 0), 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), @@ -1336,7 +1340,7 @@ function get_schema_struct() ), 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( - 'item_ident' => array('INDEX', array('item_type', 'item_id')), + 'item_ident' => array('INDEX', array('notification_type_id', 'item_id')), 'user' => array('INDEX', array('user_id', 'notification_read')), ), ); @@ -1814,12 +1818,12 @@ function get_schema_struct() ); $schema_data['phpbb_user_notifications'] = array( - 'COLUMNS' => array( - 'item_type' => array('VCHAR:255', ''), - 'item_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:255', ''), - 'notify' => array('BOOL', 1), + 'COLUMNS' => array( + 'notification_type_id' => array('USINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), ), ); diff --git a/phpBB/includes/db/migration/data/310/notifications.php b/phpBB/includes/db/migration/data/310/notifications.php index 82bfd4cb2d..17c939d95a 100644 --- a/phpBB/includes/db/migration/data/310/notifications.php +++ b/phpBB/includes/db/migration/data/310/notifications.php @@ -91,70 +91,6 @@ class phpbb_db_migration_data_310_notifications extends phpbb_db_migration ), )), array('config.add', array('load_notifications', 1)), - array('custom', array(array($this, 'convert_notifications'))), ); } - - public function convert_notifications() - { - $convert_notifications = array( - array( - 'check' => ($this->config['allow_topic_notify']), - 'item_type' => 'post', - ), - array( - 'check' => ($this->config['allow_forum_notify']), - 'item_type' => 'topic', - ), - array( - 'check' => ($this->config['allow_bookmarks']), - 'item_type' => 'bookmark', - ), - array( - 'check' => ($this->config['allow_privmsg']), - 'item_type' => 'pm', - ), - ); - - foreach ($convert_notifications as $convert_data) - { - if ($convert_data['check']) - { - $sql = 'SELECT user_id, user_notify_type - FROM ' . USERS_TABLE . ' - WHERE user_notify = 1'; - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array( - 'item_type' => $convert_data['item_type'], - 'item_id' => 0, - 'user_id' => $row['user_id'], - 'method' => '', - ))); - - if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) - { - $this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array( - 'item_type' => $convert_data['item_type'], - 'item_id' => 0, - 'user_id' => $row['user_id'], - 'method' => 'email', - ))); - } - - if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) - { - $this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array( - 'item_type' => $convert_data['item_type'], - 'item_id' => 0, - 'user_id' => $row['user_id'], - 'method' => 'jabber', - ))); - } - } - $this->db->sql_freeresult($result); - } - } - } } diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications2.php new file mode 100644 index 0000000000..a3f29b073a --- /dev/null +++ b/phpBB/includes/db/migration/data/310/notifications2.php @@ -0,0 +1,206 @@ + array( + $this->table_prefix . 'notification_types', + $this->table_prefix . 'notifications', + $this->table_prefix . 'user_notifications', + ), + 'add_tables' => array( + $this->table_prefix . 'notification_types' => array( + 'COLUMNS' => array( + 'notification_type_id' => array('USINT', NULL, 'auto_increment'), + 'notification_type_name' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type_id'), + 'KEYS' => array( + 'type' => array('UNIQUE', array('notification_type_name')), + ), + ), + $this->table_prefix . 'notifications' => array( + 'COLUMNS' => array( + 'notification_id' => array('UINT:10', NULL, 'auto_increment'), + 'notification_type_id' => array('USINT', 0), + 'item_id' => array('UINT', 0), + 'item_parent_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notification_read' => array('BOOL', 0), + 'notification_time' => array('TIMESTAMP', 1), + 'notification_data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'notification_id', + 'KEYS' => array( + 'item_ident' => array('INDEX', array('notification_type_id', 'item_id')), + 'user' => array('INDEX', array('user_id', 'notification_read')), + ), + ), + $this->table_prefix . 'user_notifications' => array( + 'COLUMNS' => array( + 'notification_type_id' => array('USINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array( + 'notification_type_id', + 'item_id', + 'user_id', + ), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'notification_types', + $this->table_prefix . 'notifications', + $this->table_prefix . 'user_notifications', + ), + 'add_tables' => array( + $this->table_prefix . 'notification_types' => array( + 'COLUMNS' => array( + 'notification_type' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'), + ), + $this->table_prefix . 'notifications' => array( + 'COLUMNS' => array( + 'notification_id' => array('UINT', NULL, 'auto_increment'), + 'item_type' => array('VCHAR:255', ''), + 'item_id' => array('UINT', 0), + 'item_parent_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'notification_read' => array('BOOL', 0), + 'notification_time' => array('TIMESTAMP', 1), + 'notification_data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => 'notification_id', + 'KEYS' => array( + 'item_ident' => array('INDEX', array('item_type', 'item_id')), + 'user' => array('INDEX', array('user_id', 'notification_read')), + ), + ), + $this->table_prefix . 'user_notifications' => array( + 'COLUMNS' => array( + 'item_type' => array('VCHAR:255', ''), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), + ), + ), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'convert_notifications'))), + ); + } + + public function convert_notifications() + { + $insert_table = $this->table_prefix . 'user_notifications'; + + $sql = 'SELECT user_id, user_notify_type, user_notify_pm + FROM ' . USERS_TABLE; + $result = $this->db->sql_query($sql); + + $sql_insert_data = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $notification_methods = array(); + + // In-board notification + $notification_methods[] = ''; + + if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) + { + $notification_methods[] = 'email'; + } + + if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) + { + $notification_methods[] = 'jabber'; + } + + // Notifications for posts + foreach (array('post', 'topic') as $item_type) + { + $sql_insert_data = $this->add_method_rows( + $sql_insert_data, + $item_type, + 0, + $row['user_id'], + $notification_methods + ); + } + + if ($row['user_notify_pm']) + { + // Notifications for private messages + // User either gets all methods or no method + $sql_insert_data = $this->add_method_rows( + $sql_insert_data, + 'pm', + 0, + $row['user_id'], + $notification_methods + ); + } + + if (sizeof($sql_insert_data) > 500) + { + $this->db->sql_multi_insert($insert_table, $sql_insert_data); + $sql_insert_data = array(); + } + } + $this->db->sql_freeresult($result); + + if (!empty($sql_insert_data)) + { + $this->db->sql_multi_insert($insert_table, $sql_insert_data); + } + } + + protected function add_method_rows(array $sql_insert_data, $item_type, $item_id, $user_id, array $methods) + { + $row_base = array( + 'item_type' => $item_type, + 'item_id' => (int) $item_id, + 'user_id' => (int) $user_id, + ); + + foreach ($methods as $method) + { + $row_base['method'] = $method; + $sql_insert_data[] = $row_base; + } + + return $sql_insert_data; + } +} diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 18ca184c65..92227eb38c 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -642,17 +642,30 @@ END;; # Table: 'phpbb_notification_types' CREATE TABLE phpbb_notification_types ( - notification_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + notification_type_id INTEGER NOT NULL, + notification_type_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, notification_type_enabled INTEGER DEFAULT 1 NOT NULL );; -ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type, notification_type_enabled);; +ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type_id);; + +CREATE UNIQUE INDEX phpbb_notification_types_type ON phpbb_notification_types(notification_type_name);; + +CREATE GENERATOR phpbb_notification_types_gen;; +SET GENERATOR phpbb_notification_types_gen TO 0;; + +CREATE TRIGGER t_phpbb_notification_types FOR phpbb_notification_types +BEFORE INSERT +AS +BEGIN + NEW.notification_type_id = GEN_ID(phpbb_notification_types_gen, 1); +END;; # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER NOT NULL, - item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + notification_type_id INTEGER DEFAULT 0 NOT NULL, item_id INTEGER DEFAULT 0 NOT NULL, item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, @@ -663,7 +676,7 @@ CREATE TABLE phpbb_notifications ( ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);; -CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(item_type, item_id);; +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(notification_type_id, item_id);; CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, notification_read);; CREATE GENERATOR phpbb_notifications_gen;; @@ -1290,7 +1303,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status) # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + notification_type_id INTEGER DEFAULT 0 NOT NULL, item_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 3530f9cd25..e869cbd1b5 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -793,7 +793,8 @@ GO Table: 'phpbb_notification_types' */ CREATE TABLE [phpbb_notification_types] ( - [notification_type] [varchar] (255) DEFAULT ('') NOT NULL , + [notification_type_id] [int] IDENTITY (1, 1) NOT NULL , + [notification_type_name] [varchar] (255) DEFAULT ('') NOT NULL , [notification_type_enabled] [int] DEFAULT (1) NOT NULL ) ON [PRIMARY] GO @@ -801,18 +802,20 @@ GO ALTER TABLE [phpbb_notification_types] WITH NOCHECK ADD CONSTRAINT [PK_phpbb_notification_types] PRIMARY KEY CLUSTERED ( - [notification_type], - [notification_type_enabled] + [notification_type_id] ) ON [PRIMARY] GO +CREATE UNIQUE INDEX [type] ON [phpbb_notification_types]([notification_type_name]) ON [PRIMARY] +GO + /* Table: 'phpbb_notifications' */ CREATE TABLE [phpbb_notifications] ( [notification_id] [int] IDENTITY (1, 1) NOT NULL , - [item_type] [varchar] (255) DEFAULT ('') NOT NULL , + [notification_type_id] [int] DEFAULT (0) NOT NULL , [item_id] [int] DEFAULT (0) NOT NULL , [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , @@ -829,7 +832,7 @@ ALTER TABLE [phpbb_notifications] WITH NOCHECK ADD ) ON [PRIMARY] GO -CREATE INDEX [item_ident] ON [phpbb_notifications]([item_type], [item_id]) ON [PRIMARY] +CREATE INDEX [item_ident] ON [phpbb_notifications]([notification_type_id], [item_id]) ON [PRIMARY] GO CREATE INDEX [user] ON [phpbb_notifications]([user_id], [notification_read]) ON [PRIMARY] @@ -1588,7 +1591,7 @@ GO Table: 'phpbb_user_notifications' */ CREATE TABLE [phpbb_user_notifications] ( - [item_type] [varchar] (255) DEFAULT ('') NOT NULL , + [notification_type_id] [int] DEFAULT (0) NOT NULL , [item_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [method] [varchar] (255) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8c405677a8..70048ea6bd 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -452,16 +452,18 @@ CREATE TABLE phpbb_modules ( # Table: 'phpbb_notification_types' CREATE TABLE phpbb_notification_types ( - notification_type varbinary(255) DEFAULT '' NOT NULL, + notification_type_id smallint(4) UNSIGNED NOT NULL auto_increment, + notification_type_name varbinary(255) DEFAULT '' NOT NULL, notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (notification_type, notification_type_enabled) + PRIMARY KEY (notification_type_id), + UNIQUE type (notification_type_name) ); # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( - notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, - item_type varbinary(255) DEFAULT '' NOT NULL, + notification_id int(10) UNSIGNED NOT NULL auto_increment, + notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -469,7 +471,7 @@ CREATE TABLE phpbb_notifications ( notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, notification_data blob NOT NULL, PRIMARY KEY (notification_id), - KEY item_ident (item_type, item_id), + KEY item_ident (notification_type_id, item_id), KEY user (user_id, notification_read) ); @@ -911,7 +913,7 @@ CREATE TABLE phpbb_topics_watch ( # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type varbinary(255) DEFAULT '' NOT NULL, + notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varbinary(255) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index cb259aa57d..e5ab9ceafa 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -452,16 +452,18 @@ CREATE TABLE phpbb_modules ( # Table: 'phpbb_notification_types' CREATE TABLE phpbb_notification_types ( - notification_type varchar(255) DEFAULT '' NOT NULL, + notification_type_id smallint(4) UNSIGNED NOT NULL auto_increment, + notification_type_name varchar(255) DEFAULT '' NOT NULL, notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (notification_type, notification_type_enabled) + PRIMARY KEY (notification_type_id), + UNIQUE type (notification_type_name) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( - notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, - item_type varchar(255) DEFAULT '' NOT NULL, + notification_id int(10) UNSIGNED NOT NULL auto_increment, + notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -469,7 +471,7 @@ CREATE TABLE phpbb_notifications ( notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, notification_data text NOT NULL, PRIMARY KEY (notification_id), - KEY item_ident (item_type, item_id), + KEY item_ident (notification_type_id, item_id), KEY user (user_id, notification_read) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -911,7 +913,7 @@ CREATE TABLE phpbb_topics_watch ( # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type varchar(255) DEFAULT '' NOT NULL, + notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varchar(255) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 35f05e34cd..b2e7409c7a 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -870,19 +870,37 @@ END; Table: 'phpbb_notification_types' */ CREATE TABLE phpbb_notification_types ( - notification_type varchar2(255) DEFAULT '' , + notification_type_id number(4) NOT NULL, + notification_type_name varchar2(255) DEFAULT '' , notification_type_enabled number(1) DEFAULT '1' NOT NULL, - CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type, notification_type_enabled) + CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type_id), + CONSTRAINT u_phpbb_type UNIQUE (notification_type_name) ) / +CREATE SEQUENCE phpbb_notification_types_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_notification_types +BEFORE INSERT ON phpbb_notification_types +FOR EACH ROW WHEN ( + new.notification_type_id IS NULL OR new.notification_type_id = 0 +) +BEGIN + SELECT phpbb_notification_types_seq.nextval + INTO :new.notification_type_id + FROM dual; +END; +/ + + /* Table: 'phpbb_notifications' */ CREATE TABLE phpbb_notifications ( - notification_id number(8) NOT NULL, - item_type varchar2(255) DEFAULT '' , + notification_id number(10) NOT NULL, + notification_type_id number(4) DEFAULT '0' NOT NULL, item_id number(8) DEFAULT '0' NOT NULL, item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, @@ -893,7 +911,7 @@ CREATE TABLE phpbb_notifications ( ) / -CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id) +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (notification_type_id, item_id) / CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read) / @@ -1702,7 +1720,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status Table: 'phpbb_user_notifications' */ CREATE TABLE phpbb_user_notifications ( - item_type varchar2(255) DEFAULT '' , + notification_type_id number(4) DEFAULT '0' NOT NULL, item_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, method varchar2(255) DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 6dc507b46d..cd6de434b5 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -623,12 +623,16 @@ CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id /* Table: 'phpbb_notification_types' */ +CREATE SEQUENCE phpbb_notification_types_seq; + CREATE TABLE phpbb_notification_types ( - notification_type varchar(255) DEFAULT '' NOT NULL, + notification_type_id INT2 DEFAULT nextval('phpbb_notification_types_seq'), + notification_type_name varchar(255) DEFAULT '' NOT NULL, notification_type_enabled INT2 DEFAULT '1' NOT NULL CHECK (notification_type_enabled >= 0), - PRIMARY KEY (notification_type, notification_type_enabled) + PRIMARY KEY (notification_type_id) ); +CREATE UNIQUE INDEX phpbb_notification_types_type ON phpbb_notification_types (notification_type_name); /* Table: 'phpbb_notifications' @@ -637,7 +641,7 @@ CREATE SEQUENCE phpbb_notifications_seq; CREATE TABLE phpbb_notifications ( notification_id INT4 DEFAULT nextval('phpbb_notifications_seq'), - item_type varchar(255) DEFAULT '' NOT NULL, + notification_type_id INT2 DEFAULT '0' NOT NULL CHECK (notification_type_id >= 0), item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), @@ -647,7 +651,7 @@ CREATE TABLE phpbb_notifications ( PRIMARY KEY (notification_id) ); -CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (notification_type_id, item_id); CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read); /* @@ -1171,7 +1175,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status Table: 'phpbb_user_notifications' */ CREATE TABLE phpbb_user_notifications ( - item_type varchar(255) DEFAULT '' NOT NULL, + notification_type_id INT2 DEFAULT '0' NOT NULL CHECK (notification_type_id >= 0), item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), method varchar(255) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index ccb67ad46f..e12bb624b6 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -439,16 +439,17 @@ CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id # Table: 'phpbb_notification_types' CREATE TABLE phpbb_notification_types ( - notification_type varchar(255) NOT NULL DEFAULT '', - notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', - PRIMARY KEY (notification_type, notification_type_enabled) + notification_type_id INTEGER PRIMARY KEY NOT NULL , + notification_type_name varchar(255) NOT NULL DEFAULT '', + notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1' ); +CREATE UNIQUE INDEX phpbb_notification_types_type ON phpbb_notification_types (notification_type_name); # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER PRIMARY KEY NOT NULL , - item_type varchar(255) NOT NULL DEFAULT '', + notification_type_id INTEGER UNSIGNED NOT NULL DEFAULT '0', item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', @@ -457,7 +458,7 @@ CREATE TABLE phpbb_notifications ( notification_data text(65535) NOT NULL DEFAULT '' ); -CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (notification_type_id, item_id); CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read); # Table: 'phpbb_poll_options' @@ -883,7 +884,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type varchar(255) NOT NULL DEFAULT '', + notification_type_id INTEGER UNSIGNED NOT NULL DEFAULT '0', item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', method varchar(255) NOT NULL DEFAULT '', From 4c5e51e379f770d9bd3610e7235dafcb985494e1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 28 Apr 2013 23:40:48 -0500 Subject: [PATCH 023/172] [ticket/11413] Rename columns in notification/manager.php PHPBB3-11413 --- phpBB/config/services.yml | 1 + phpBB/includes/notification/manager.php | 276 ++++++++++++++---------- 2 files changed, 166 insertions(+), 111 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 7923c94a3f..3142b8faab 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -218,6 +218,7 @@ services: - @service_container - @user_loader - @dbal.conn + - @cache - @user - %core.root_path% - %core.php_ext% diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index 9eceeb753a..8ea4cdc121 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -36,6 +36,9 @@ class phpbb_notification_manager /** @var phpbb_db_driver */ protected $db; + /** @var phpbb_cache_service */ + protected $cache; + /** @var phpbb_user */ protected $user; @@ -70,7 +73,7 @@ class phpbb_notification_manager * @param string $user_notifications_table * @return phpbb_notification_manager */ - public function __construct($notification_types, $notification_methods, $phpbb_container, phpbb_user_loader $user_loader, phpbb_db_driver $db, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct($notification_types, $notification_methods, $phpbb_container, phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->notification_types = $notification_types; $this->notification_methods = $notification_methods; @@ -78,6 +81,7 @@ class phpbb_notification_manager $this->user_loader = $user_loader; $this->db = $db; + $this->cache = $cache; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; @@ -145,7 +149,7 @@ class phpbb_notification_manager FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt WHERE n.user_id = ' . (int) $options['user_id'] . ' AND n.notification_read = 0 - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); $unread_count = (int) $this->db->sql_fetchfield('unread_count', $result); @@ -158,7 +162,7 @@ class phpbb_notification_manager $sql = 'SELECT COUNT(n.notification_id) AS total_count FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt WHERE n.user_id = ' . (int) $options['user_id'] . ' - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); $total_count = (int) $this->db->sql_fetchfield('total_count', $result); @@ -170,11 +174,11 @@ class phpbb_notification_manager $rowset = array(); // Get the main notifications - $sql = 'SELECT n.* + $sql = 'SELECT n.*, nt.notification_type_name FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt WHERE n.user_id = ' . (int) $options['user_id'] . (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('n.notification_id', $options['notification_id']) : ' AND n.notification_id = ' . (int) $options['notification_id']) : '') . ' - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1 ORDER BY n.' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); @@ -188,12 +192,12 @@ class phpbb_notification_manager // Get all unread notifications if ($unread_count && $options['all_unread'] && !empty($rowset)) { - $sql = 'SELECT n.* + $sql = 'SELECT n.*, nt.notification_type_name FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt WHERE n.user_id = ' . (int) $options['user_id'] . ' AND n.notification_read = 0 AND ' . $this->db->sql_in_set('n.notification_id', array_keys($rowset), true) . ' - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1 ORDER BY n.' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); @@ -207,17 +211,17 @@ class phpbb_notification_manager foreach ($rowset as $row) { - $notification = $this->get_item_type_class($row['item_type'], $row); + $notification = $this->get_item_type_class($row['notification_type_name'], $row); // Array of user_ids to query all at once $user_ids = array_merge($user_ids, $notification->users_to_query()); // Some notification types also require querying additional tables themselves - if (!isset($load_special[$row['item_type']])) + if (!isset($load_special[$row['notification_type_name']])) { - $load_special[$row['item_type']] = array(); + $load_special[$row['notification_type_name']] = array(); } - $load_special[$row['item_type']] = array_merge($load_special[$row['item_type']], $notification->get_load_special()); + $load_special[$row['notification_type_name']] = array_merge($load_special[$row['notification_type_name']], $notification->get_load_special()); $notifications[$row['notification_id']] = $notification; } @@ -243,19 +247,21 @@ class phpbb_notification_manager /** * Mark notifications read * - * @param bool|string|array $item_type Type identifier or array of item types (only acceptable if the $data is identical for the specified types). False to mark read for all item types + * @param bool|string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types). False to mark read for all item types * @param bool|int|array $item_id Item id or array of item ids. False to mark read for all item ids * @param bool|int|array $user_id User id or array of user ids. False to mark read for all user ids * @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False) */ - public function mark_notifications_read($item_type, $item_id, $user_id, $time = false) + public function mark_notifications_read($notification_type_name, $item_id, $user_id, $time = false) { $time = ($time !== false) ? $time : time(); $sql = 'UPDATE ' . $this->notifications_table . " SET notification_read = 1 WHERE notification_time <= " . (int) $time . - (($item_type !== false) ? ' AND ' . (is_array($item_type) ? $this->db->sql_in_set('item_type', $item_type) : " item_type = '" . $this->db->sql_escape($item_type) . "'") : '') . + (($notification_type_name !== false) ? ' AND ' . + (is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name)) + : '') . (($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') . (($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : ''); $this->db->sql_query($sql); @@ -264,29 +270,21 @@ class phpbb_notification_manager /** * Mark notifications read from a parent identifier * - * @param string|array $item_type Type identifier or array of item types (only acceptable if the $data is identical for the specified types) + * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) * @param bool|int|array $item_parent_id Item parent id or array of item parent ids. False to mark read for all item parent ids * @param bool|int|array $user_id User id or array of user ids. False to mark read for all user ids * @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False) */ - public function mark_notifications_read_by_parent($item_type, $item_parent_id, $user_id, $time = false) + public function mark_notifications_read_by_parent($notification_type_name, $item_parent_id, $user_id, $time = false) { - if (is_array($item_type)) - { - foreach ($item_type as $type) - { - $this->mark_notifications_read_by_parent($type, $item_parent_id, $user_id, $time); - } - - return; - } - $time = ($time !== false) ? $time : time(); $sql = 'UPDATE ' . $this->notifications_table . " SET notification_read = 1 - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND notification_time <= " . (int) $time . + WHERE notification_time <= " . (int) $time . + (($notification_type_name !== false) ? ' AND ' . + (is_array($notification_type_name) ? $this->db->sql_in_set('notification_type_id', $this->get_notification_type_ids($notification_type_name)) : 'notification_type_id = ' . $this->get_notification_type_id($notification_type_name)) + : '') . (($item_parent_id !== false) ? ' AND ' . (is_array($item_parent_id) ? $this->db->sql_in_set('item_parent_id', $item_parent_id) : 'item_parent_id = ' . (int) $item_parent_id) : '') . (($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : ''); $this->db->sql_query($sql); @@ -312,7 +310,7 @@ class phpbb_notification_manager /** * Add a notification * - * @param string|array $item_type Type identifier or array of item types (only acceptable if the $data is identical for the specified types) + * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) * Note: If you send an array of types, any user who could receive multiple notifications from this single item will only receive * a single notification. If they MUST receive multiple notifications, call this function multiple times instead of sending an array * @param array $data Data specific for this type that will be inserted @@ -320,18 +318,18 @@ class phpbb_notification_manager * ignore_users array of data to specify which users should not receive certain types of notifications * @return array Information about what users were notified and how they were notified */ - public function add_notifications($item_type, $data, array $options = array()) + public function add_notifications($notification_type_name, $data, array $options = array()) { $options = array_merge(array( 'ignore_users' => array(), ), $options); - if (is_array($item_type)) + if (is_array($notification_type_name)) { $notified_users = array(); $temp_options = $options; - foreach ($item_type as $type) + foreach ($notification_type_name as $type) { $temp_options['ignore_users'] = $options['ignore_users'] + $notified_users; $notified_users += $this->add_notifications($type, $data, $temp_options); @@ -340,12 +338,12 @@ class phpbb_notification_manager return $notified_users; } - $item_id = $this->get_item_type_class($item_type)->get_item_id($data); + $item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data); // find out which users want to receive this type of notification - $notify_users = $this->get_item_type_class($item_type)->find_users_for_notification($data, $options); + $notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options); - $this->add_notifications_for_users($item_type, $data, $notify_users); + $this->add_notifications_for_users($notification_type_name, $data, $notify_users); return $notify_users; } @@ -353,15 +351,15 @@ class phpbb_notification_manager /** * Add a notification for specific users * - * @param string|array $item_type Type identifier or array of item types (only acceptable if the $data is identical for the specified types) + * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) * @param array $data Data specific for this type that will be inserted * @param array $notify_users User list to notify */ - public function add_notifications_for_users($item_type, $data, $notify_users) + public function add_notifications_for_users($notification_type_name, $data, $notify_users) { - if (is_array($item_type)) + if (is_array($notification_type_name)) { - foreach ($item_type as $type) + foreach ($notification_type_name as $type) { $this->add_notifications_for_users($type, $data, $notify_users); } @@ -369,24 +367,9 @@ class phpbb_notification_manager return; } - $sql = 'SELECT notification_type - FROM ' . $this->notification_types_table . " - WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; - $result = $this->db->sql_query($sql); + $notification_type_id = $this->get_notification_type_id($notification_type_name); - if ($this->db->sql_fetchrow($result) === false) - { - // Does not exist in the database, must add the item type - $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( - 'notification_type' => $item_type, - 'notification_type_enabled' => 1, - )); - $this->db->sql_query($sql); - } - - $this->db->sql_freeresult($result); - - $item_id = $this->get_item_type_class($item_type)->get_item_id($data); + $item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data); $user_ids = array(); $notification_objects = $notification_methods = array(); @@ -397,10 +380,10 @@ class phpbb_notification_manager // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item $sql = 'SELECT n.user_id - FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt - WHERE n.item_type = '" . $this->db->sql_escape($item_type) . "' - AND n.item_id = " . (int) $item_id . ' - AND nt.notification_type = n.item_type + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.notification_type_id = ' . (int) $notification_type_id . ' + AND n.item_id = ' . (int) $item_id . ' + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -415,7 +398,7 @@ class phpbb_notification_manager } // Allow notifications to perform actions before creating the insert array (such as run a query to cache some data needed for all notifications) - $notification = $this->get_item_type_class($item_type); + $notification = $this->get_item_type_class($notification_type_name); $pre_create_data = $notification->pre_create_insert_array($data, $notify_users); unset($notification); @@ -424,7 +407,7 @@ class phpbb_notification_manager // Go through each user so we can insert a row in the DB and then notify them by their desired means foreach ($notify_users as $user => $methods) { - $notification = $this->get_item_type_class($item_type); + $notification = $this->get_item_type_class($notification_type_name); $notification->user_id = (int) $user; @@ -464,14 +447,14 @@ class phpbb_notification_manager /** * Update a notification * - * @param string|array $item_type Type identifier or array of item types (only acceptable if the $data is identical for the specified types) + * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) * @param array $data Data specific for this type that will be updated */ - public function update_notifications($item_type, $data) + public function update_notifications($notification_type_name, $data) { - if (is_array($item_type)) + if (is_array($notification_type_name)) { - foreach ($item_type as $type) + foreach ($notification_type_name as $type) { $this->update_notifications($type, $data); } @@ -479,7 +462,7 @@ class phpbb_notification_manager return; } - $notification = $this->get_item_type_class($item_type); + $notification = $this->get_item_type_class($notification_type_name); // Allow the notifications class to over-ride the update_notifications functionality if (method_exists($notification, 'update_notifications')) @@ -491,28 +474,29 @@ class phpbb_notification_manager } } + $notification_type_id = $this->get_notification_type_id($notification_type_name); $item_id = $notification->get_item_id($data); $update_array = $notification->create_update_array($data); $sql = 'UPDATE ' . $this->notifications_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $update_array) . " - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id; + SET ' . $this->db->sql_build_array('UPDATE', $update_array) . ' + WHERE notification_type_id = ' . (int) $notification_type_id . ' + AND item_id = ' . (int) $item_id; $this->db->sql_query($sql); } /** * Delete a notification * - * @param string|array $item_type Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types) + * @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types) * @param int|array $item_id Identifier within the type (or array of ids) * @param array $data Data specific for this type that will be updated */ - public function delete_notifications($item_type, $item_id) + public function delete_notifications($notification_type_name, $item_id) { - if (is_array($item_type)) + if (is_array($notification_type_name)) { - foreach ($item_type as $type) + foreach ($notification_type_name as $type) { $this->delete_notifications($type, $item_id); } @@ -520,9 +504,11 @@ class phpbb_notification_manager return; } - $sql = 'DELETE FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND " . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id); + $notification_type_id = $this->get_notification_type_id($notification_type_name); + + $sql = 'DELETE FROM ' . $this->notifications_table . ' + WHERE notification_type_id = ' . (int) $notification_type_id . ' + AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id); $this->db->sql_query($sql); } @@ -646,24 +632,25 @@ class phpbb_notification_manager /** * Add a subscription * - * @param string $item_type Type identifier of the subscription + * @param string $notification_type_name Type identifier of the subscription * @param int $item_id The id of the item * @param string $method The method of the notification e.g. '', 'email', or 'jabber' * @param bool|int $user_id The user_id to add the subscription for (bool false for current user) */ - public function add_subscription($item_type, $item_id = 0, $method = '', $user_id = false) + public function add_subscription($notification_type_name, $item_id = 0, $method = '', $user_id = false) { if ($method !== '') { - $this->add_subscription($item_type, $item_type, '', $user_id); + $this->add_subscription($notification_type_name, $item_id, '', $user_id); } + $notification_type_id = $this->get_notification_type_id($notification_type_name); $user_id = ($user_id === false) ? $this->user->data['user_id'] : $user_id; $sql = 'SELECT notify - FROM ' . $this->user_notifications_table . " - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id . ' + FROM ' . $this->user_notifications_table . ' + WHERE notification_type_id = ' . (int) $notification_type_name . ' + AND item_id = ' . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method = '" . $this->db->sql_escape($method) . "'"; $this->db->sql_query($sql); @@ -674,7 +661,7 @@ class phpbb_notification_manager { $sql = 'INSERT INTO ' . $this->user_notifications_table . ' ' . $this->db->sql_build_array('INSERT', array( - 'item_type' => $item_type, + 'notification_type_id' => $notification_type_id, 'item_id' => (int) $item_id, 'user_id' => (int) $user_id, 'method' => $method, @@ -684,10 +671,10 @@ class phpbb_notification_manager } else if (!$current) { - $sql = 'UPDATE ' . $this->user_notifications_table . " + $sql = 'UPDATE ' . $this->user_notifications_table . ' SET notify = 1 - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id . ' + WHERE notification_type_id = ' . (int) $notification_type_id . ' + AND item_id = ' . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method = '" . $this->db->sql_escape($method) . "'"; $this->db->sql_query($sql); @@ -697,22 +684,23 @@ class phpbb_notification_manager /** * Delete a subscription * - * @param string $item_type Type identifier of the subscription + * @param string $notification_type_name Type identifier of the subscription * @param int $item_id The id of the item * @param string $method The method of the notification e.g. '', 'email', or 'jabber' * @param bool|int $user_id The user_id to add the subscription for (bool false for current user) */ - public function delete_subscription($item_type, $item_id = 0, $method = '', $user_id = false) + public function delete_subscription($notification_type_name, $item_id = 0, $method = '', $user_id = false) { + $notification_type_id = $this->get_notification_type_id($notification_type_name); $user_id = ($user_id === false) ? $this->user->data['user_id'] : $user_id; // If no method, make sure that no other notification methods for this item are selected before deleting if ($method === '') { $sql = 'SELECT COUNT(*) as num_notifications - FROM ' . $this->user_notifications_table . " - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id . ' + FROM ' . $this->user_notifications_table . ' + WHERE notification_type_id = ' . (int) $notification_type_id . ' + AND item_id = ' . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method <> '' AND notify = 1"; @@ -726,10 +714,10 @@ class phpbb_notification_manager } } - $sql = 'UPDATE ' . $this->user_notifications_table . " + $sql = 'UPDATE ' . $this->user_notifications_table . ' SET notify = 0 - WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id . ' + WHERE notification_type_id = ' . (int) $notification_type_id . ' + AND item_id = '. (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method = '" . $this->db->sql_escape($method) . "'"; $this->db->sql_query($sql); @@ -738,7 +726,7 @@ class phpbb_notification_manager { $sql = 'INSERT INTO ' . $this->user_notifications_table . ' ' . $this->db->sql_build_array('INSERT', array( - 'item_type' => $item_type, + 'notification_type_id' => (int) $notification_type_id, 'item_id' => (int) $item_id, 'user_id' => (int) $user_id, 'method' => $method, @@ -755,13 +743,13 @@ class phpbb_notification_manager * is disabled so that all those notifications are hidden and do not * cause errors * - * @param string $item_type Type identifier of the subscription + * @param string $notification_type_name Type identifier of the subscription */ - public function disable_notifications($item_type) + public function disable_notifications($notification_type_name) { $sql = 'UPDATE ' . $this->notification_types_table . " SET notification_type_enabled = 0 - WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; + WHERE notification_type_name = '" . $this->db->sql_escape($notification_type_name) . "'"; $this->db->sql_query($sql); } @@ -771,17 +759,21 @@ class phpbb_notification_manager * This should be called when an extension which has notification types * is purged so that all those notifications are removed * - * @param string $item_type Type identifier of the subscription + * @param string $notification_type_name Type identifier of the subscription */ - public function purge_notifications($item_type) + public function purge_notifications($notification_type_name) { - $sql = 'DELETE FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->db->sql_escape($item_type) . "'"; + $notification_type_id = $this->get_notification_type_id($notification_type_name); + + $sql = 'DELETE FROM ' . $this->notifications_table . ' + WHERE notification_type_id = ' . (int) $notification_type_id; $this->db->sql_query($sql); - $sql = 'DELETE FROM ' . $this->notification_types_table . " - WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; + $sql = 'DELETE FROM ' . $this->notification_types_table . ' + WHERE notification_type_id = ' . (int) $notification_type_id; $this->db->sql_query($sql); + + $this->cache->destroy('notification_type_ids'); } /** @@ -791,13 +783,13 @@ class phpbb_notification_manager * that was disabled is re-enabled so that all those notifications that * were hidden are shown again * - * @param string $item_type Type identifier of the subscription + * @param string $notification_type_name Type identifier of the subscription */ - public function enable_notifications($item_type) + public function enable_notifications($notification_type_name) { $sql = 'UPDATE ' . $this->notification_types_table . " SET notification_type_enabled = 1 - WHERE notification_type = '" . $this->db->sql_escape($item_type) . "'"; + WHERE notification_type_name = '" . $this->db->sql_escape($notification_type_name) . "'"; $this->db->sql_query($sql); } @@ -816,11 +808,11 @@ class phpbb_notification_manager /** * Helper to get the notifications item type class and set it up */ - public function get_item_type_class($item_type, $data = array()) + public function get_item_type_class($notification_type_name, $data = array()) { - $item_type = (strpos($item_type, 'notification.type.') === 0) ? $item_type : 'notification.type.' . $item_type; + $notification_type_name = (strpos($notification_type_name, 'notification.type.') === 0) ? $notification_type_name : 'notification.type.' . $notification_type_name; - $item = $this->load_object($item_type); + $item = $this->load_object($notification_type_name); $item->set_initial_data($data); @@ -851,4 +843,66 @@ class phpbb_notification_manager return $object; } + + /** + * Get the notification type id from the name + * + * @param string $notification_type_name The name + * @return int the notification_type_id + */ + public function get_notification_type_id($notification_type_name) + { + $notification_type_ids = $this->cache->get('notification_type_ids'); + + if ($notification_type_ids === false) + { + $notification_type_ids = array(); + + $sql = 'SELECT notification_type_id, notification_type_name + FROM ' . $this->notification_types_table; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id']; + } + $this->db->sql_freeresult($result); + + $this->cache->put('notification_type_ids', $notification_type_ids); + } + + if (!isset($notification_type_ids[$notification_type_name])) + { + $notification_type = $this->get_item_type_class($notification_type_name); + + $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( + 'notification_type_name' => $notification_type_name, + 'notification_type_enabled' => 1, + )); + $this->db->sql_query($sql); + + $notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid(); + + $this->cache->put('notification_type_ids', $notification_type_ids); + } + + return $notification_type_ids[$notification_type_name]; + } + + /** + * Get notification type ids (as an array) + * + * @param array $notification_type_names Array of strings + * @return array Array of integers + */ + public function get_notification_type_ids(array $notification_type_names) + { + $notification_type_ids = array(); + + foreach ($notification_type_names as $name) + { + $notification_type_ids[$name] = $this->get_notification_type_id($name); + } + + return $notification_type_ids; + } } From 33287a73609a99f33f3d0718fceaf72e39d5283e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 29 Apr 2013 21:22:07 -0500 Subject: [PATCH 024/172] [ticket/11413] Undo editing the user_notifications table item_type is not equivalent to notification_type_name, it can be a generic string (typically used to be able to subscribe to multiple notification types while only subscribing to one item PHPBB3-11413 --- phpBB/develop/create_schema_files.php | 10 ++--- .../db/migration/data/310/notifications2.php | 28 ++----------- phpBB/includes/notification/manager.php | 41 +++++++++---------- phpBB/includes/notification/type/base.php | 20 ++++++--- phpBB/includes/notification/type/bookmark.php | 8 ++-- phpBB/includes/notification/type/post.php | 8 ++-- phpBB/includes/notification/type/quote.php | 22 +++++----- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- 14 files changed, 69 insertions(+), 82 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3121db391d..0fd1a722ca 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1819,11 +1819,11 @@ function get_schema_struct() $schema_data['phpbb_user_notifications'] = array( 'COLUMNS' => array( - 'notification_type_id' => array('USINT', 0), - 'item_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:255', ''), - 'notify' => array('BOOL', 1), + 'item_type' => array('VCHAR:255', ''), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), ), ); diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications2.php index a3f29b073a..cd078f8f60 100644 --- a/phpBB/includes/db/migration/data/310/notifications2.php +++ b/phpBB/includes/db/migration/data/310/notifications2.php @@ -20,7 +20,6 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration 'drop_tables' => array( $this->table_prefix . 'notification_types', $this->table_prefix . 'notifications', - $this->table_prefix . 'user_notifications', ), 'add_tables' => array( $this->table_prefix . 'notification_types' => array( @@ -51,20 +50,6 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration 'user' => array('INDEX', array('user_id', 'notification_read')), ), ), - $this->table_prefix . 'user_notifications' => array( - 'COLUMNS' => array( - 'notification_type_id' => array('USINT', 0), - 'item_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:255', ''), - 'notify' => array('BOOL', 1), - ), - 'PRIMARY_KEY' => array( - 'notification_type_id', - 'item_id', - 'user_id', - ), - ), ), ); } @@ -75,7 +60,6 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration 'drop_tables' => array( $this->table_prefix . 'notification_types', $this->table_prefix . 'notifications', - $this->table_prefix . 'user_notifications', ), 'add_tables' => array( $this->table_prefix . 'notification_types' => array( @@ -102,15 +86,6 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration 'user' => array('INDEX', array('user_id', 'notification_read')), ), ), - $this->table_prefix . 'user_notifications' => array( - 'COLUMNS' => array( - 'item_type' => array('VCHAR:255', ''), - 'item_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:255', ''), - 'notify' => array('BOOL', 1), - ), - ), ), ); } @@ -126,6 +101,9 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration { $insert_table = $this->table_prefix . 'user_notifications'; + $sql = 'DELETE FROM ' . $insert_table; + $this->db->sql_query($sql); + $sql = 'SELECT user_id, user_notify_type, user_notify_pm FROM ' . USERS_TABLE; $result = $this->db->sql_query($sql); diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index 8ea4cdc121..e7d6af71b8 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -632,25 +632,25 @@ class phpbb_notification_manager /** * Add a subscription * - * @param string $notification_type_name Type identifier of the subscription + * @param string $item_type Type identifier of the subscription * @param int $item_id The id of the item * @param string $method The method of the notification e.g. '', 'email', or 'jabber' * @param bool|int $user_id The user_id to add the subscription for (bool false for current user) */ - public function add_subscription($notification_type_name, $item_id = 0, $method = '', $user_id = false) + public function add_subscription($item_type, $item_id = 0, $method = '', $user_id = false) { if ($method !== '') { - $this->add_subscription($notification_type_name, $item_id, '', $user_id); + // Make sure to subscribe them to the base subscription + $this->add_subscription($item_type, $item_id, '', $user_id); } - $notification_type_id = $this->get_notification_type_id($notification_type_name); $user_id = ($user_id === false) ? $this->user->data['user_id'] : $user_id; $sql = 'SELECT notify - FROM ' . $this->user_notifications_table . ' - WHERE notification_type_id = ' . (int) $notification_type_name . ' - AND item_id = ' . (int) $item_id . ' + FROM ' . $this->user_notifications_table . " + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method = '" . $this->db->sql_escape($method) . "'"; $this->db->sql_query($sql); @@ -661,7 +661,7 @@ class phpbb_notification_manager { $sql = 'INSERT INTO ' . $this->user_notifications_table . ' ' . $this->db->sql_build_array('INSERT', array( - 'notification_type_id' => $notification_type_id, + 'item_type' => $item_type, 'item_id' => (int) $item_id, 'user_id' => (int) $user_id, 'method' => $method, @@ -671,10 +671,10 @@ class phpbb_notification_manager } else if (!$current) { - $sql = 'UPDATE ' . $this->user_notifications_table . ' + $sql = 'UPDATE ' . $this->user_notifications_table . " SET notify = 1 - WHERE notification_type_id = ' . (int) $notification_type_id . ' - AND item_id = ' . (int) $item_id . ' + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method = '" . $this->db->sql_escape($method) . "'"; $this->db->sql_query($sql); @@ -684,23 +684,22 @@ class phpbb_notification_manager /** * Delete a subscription * - * @param string $notification_type_name Type identifier of the subscription + * @param string $item_type Type identifier of the subscription * @param int $item_id The id of the item * @param string $method The method of the notification e.g. '', 'email', or 'jabber' * @param bool|int $user_id The user_id to add the subscription for (bool false for current user) */ - public function delete_subscription($notification_type_name, $item_id = 0, $method = '', $user_id = false) + public function delete_subscription($item_type, $item_id = 0, $method = '', $user_id = false) { - $notification_type_id = $this->get_notification_type_id($notification_type_name); $user_id = ($user_id === false) ? $this->user->data['user_id'] : $user_id; // If no method, make sure that no other notification methods for this item are selected before deleting if ($method === '') { $sql = 'SELECT COUNT(*) as num_notifications - FROM ' . $this->user_notifications_table . ' - WHERE notification_type_id = ' . (int) $notification_type_id . ' - AND item_id = ' . (int) $item_id . ' + FROM ' . $this->user_notifications_table . " + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method <> '' AND notify = 1"; @@ -714,10 +713,10 @@ class phpbb_notification_manager } } - $sql = 'UPDATE ' . $this->user_notifications_table . ' + $sql = 'UPDATE ' . $this->user_notifications_table . " SET notify = 0 - WHERE notification_type_id = ' . (int) $notification_type_id . ' - AND item_id = '. (int) $item_id . ' + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id . ' AND user_id = ' .(int) $user_id . " AND method = '" . $this->db->sql_escape($method) . "'"; $this->db->sql_query($sql); @@ -726,7 +725,7 @@ class phpbb_notification_manager { $sql = 'INSERT INTO ' . $this->user_notifications_table . ' ' . $this->db->sql_build_array('INSERT', array( - 'notification_type_id' => (int) $notification_type_id, + 'item_type' => $item_type, 'item_id' => (int) $item_id, 'user_id' => (int) $user_id, 'method' => $method, diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index 600ef7c965..f56956d16a 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -68,11 +68,19 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i */ public static $notification_option = false; + /** + * The notification_type_id, set upon creation of the class + * This is the notification_type_id from the notification_types table + * + * @var int + */ + protected $notification_type_id; + /** * Indentification data - * item_type - Type of the item (translates to the notification type) - * item_id - ID of the item (e.g. post_id, msg_id) - * item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc) + * notification_type_id - ID of the item type (auto generated, from notification types table) + * item_id - ID of the item (e.g. post_id, msg_id) + * item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc) * user_id * notification_read * notification_time @@ -124,6 +132,8 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i public function set_notification_manager(phpbb_notification_manager $notification_manager) { $this->notification_manager = $notification_manager; + + $this->notification_type_id = $this->notification_manager->get_notification_type_id($this->get_type()); } /** @@ -211,7 +221,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i // Defaults $this->data = array_merge(array( 'item_id' => static::get_item_id($type_data), - 'item_type' => $this->get_type(), + 'notification_type_id' => $this->notification_type_id, 'item_parent_id' => static::get_item_parent_id($type_data), 'notification_time' => time(), @@ -460,7 +470,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i $this->notification_read = (bool) !$unread; $where = array( - "item_type = '" . $this->db->sql_escape($this->item_type) . "'", + 'notification_type_id = ' . (int) $this->notification_type_id, 'item_id = ' . (int) $this->item_id, 'user_id = ' . (int) $this->user_id, ); diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php index 946cb9b4ed..ae2e75d3eb 100644 --- a/phpBB/includes/notification/type/bookmark.php +++ b/phpBB/includes/notification/type/bookmark.php @@ -103,11 +103,11 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* - FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt - WHERE n.item_type = '" . $this->get_type() . "' - AND n.item_parent_id = " . (int) self::get_item_parent_id($post) . ' + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.notification_type_id = ' . (int) $this->notification_type_id . ' + AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . ' AND n.notification_read = 0 - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php index 626c13b7fd..9207fd866e 100644 --- a/phpBB/includes/notification/type/post.php +++ b/phpBB/includes/notification/type/post.php @@ -138,11 +138,11 @@ class phpbb_notification_type_post extends phpbb_notification_type_base // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* - FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt - WHERE n.item_type = '" . $this->get_type() . "' - AND n.item_parent_id = " . (int) self::get_item_parent_id($post) . ' + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.notification_type_id = ' . (int) $this->notification_type_id . ' + AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . ' AND n.notification_read = 0 - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php index e9eb7bea21..0ed13f36fb 100644 --- a/phpBB/includes/notification/type/quote.php +++ b/phpBB/includes/notification/type/quote.php @@ -122,11 +122,11 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT n.* - FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt - WHERE n.item_type = '" . $this->get_type() . "' - AND n.item_parent_id = " . (int) self::get_item_parent_id($post) . ' + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.notification_type_id = ' . (int) $this->notification_type_id . ' + AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . ' AND n.notification_read = 0 - AND nt.notification_type = n.item_type + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -154,10 +154,10 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post { $old_notifications = array(); $sql = 'SELECT n.user_id - FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . " nt - WHERE n.item_type = '" . $this->get_type() . "' - AND n.item_id = " . self::get_item_id($post) . ' - AND nt.notification_type = n.item_type + FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt + WHERE n.notification_type_id = ' . (int) $this->notification_type_id . ' + AND n.item_id = ' . self::get_item_id($post) . ' + AND nt.notification_type_id = n.notification_type_id AND nt.notification_type_enabled = 1'; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) @@ -185,9 +185,9 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post // Remove the necessary notifications if (!empty($remove_notifications)) { - $sql = 'DELETE FROM ' . $this->notifications_table . " - WHERE item_type = '" . $this->get_type() . "' - AND item_id = " . self::get_item_id($post) . ' + $sql = 'DELETE FROM ' . $this->notifications_table . ' + WHERE notification_type_id = ' . (int) $this->notification_type_id . ' + AND item_id = ' . self::get_item_id($post) . ' AND ' . $this->db->sql_in_set('user_id', $remove_notifications); $this->db->sql_query($sql); } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 92227eb38c..a64b8eeffc 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -1303,7 +1303,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status) # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - notification_type_id INTEGER DEFAULT 0 NOT NULL, + item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, item_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index e869cbd1b5..8465dc4d72 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1591,7 +1591,7 @@ GO Table: 'phpbb_user_notifications' */ CREATE TABLE [phpbb_user_notifications] ( - [notification_type_id] [int] DEFAULT (0) NOT NULL , + [item_type] [varchar] (255) DEFAULT ('') NOT NULL , [item_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [method] [varchar] (255) DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 70048ea6bd..37e4e66ad7 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -913,7 +913,7 @@ CREATE TABLE phpbb_topics_watch ( # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + item_type varbinary(255) DEFAULT '' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varbinary(255) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index e5ab9ceafa..ff0f315f93 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -913,7 +913,7 @@ CREATE TABLE phpbb_topics_watch ( # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - notification_type_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + item_type varchar(255) DEFAULT '' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varchar(255) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index b2e7409c7a..11f245869d 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1720,7 +1720,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status Table: 'phpbb_user_notifications' */ CREATE TABLE phpbb_user_notifications ( - notification_type_id number(4) DEFAULT '0' NOT NULL, + item_type varchar2(255) DEFAULT '' , item_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, method varchar2(255) DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index cd6de434b5..fea5700167 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -1175,7 +1175,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status Table: 'phpbb_user_notifications' */ CREATE TABLE phpbb_user_notifications ( - notification_type_id INT2 DEFAULT '0' NOT NULL CHECK (notification_type_id >= 0), + item_type varchar(255) DEFAULT '' NOT NULL, item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), method varchar(255) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index e12bb624b6..02ffb9a857 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -884,7 +884,7 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - notification_type_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + item_type varchar(255) NOT NULL DEFAULT '', item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', method varchar(255) NOT NULL DEFAULT '', From 7bda5a016a726711855fb7a749f9f3638e63d1e3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 29 Apr 2013 21:42:14 -0500 Subject: [PATCH 025/172] [ticket/11413] Prevent recursive function calls PHPBB3-11413 --- phpBB/includes/notification/manager.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index e7d6af71b8..a9eb503fb8 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -871,7 +871,10 @@ class phpbb_notification_manager if (!isset($notification_type_ids[$notification_type_name])) { - $notification_type = $this->get_item_type_class($notification_type_name); + if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name])) + { + throw new phpbb_notification_exception('Notification type ' . $notification_type_name . ' does not exist'); + } $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( 'notification_type_name' => $notification_type_name, From 4cd0914f8976913de0ec46cc78c8ac5731415838 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 29 Apr 2013 22:16:46 -0500 Subject: [PATCH 026/172] [ticket/11413] Fix notification tests Send types/methods the cache service, not the driver (not sure why the driver was sent before) PHPBB3-11413 --- phpBB/config/notifications.yml | 34 +++++++------- phpBB/includes/notification/exception.php | 29 ++++++++++++ phpBB/includes/notification/method/base.php | 4 +- phpBB/includes/notification/type/base.php | 4 +- .../manager_helper.php} | 2 +- tests/notification/notification_test.php | 47 ++++++++++++++----- 6 files changed, 86 insertions(+), 34 deletions(-) create mode 100644 phpBB/includes/notification/exception.php rename tests/{mock/notifications_notification_manager.php => notification/manager_helper.php} (95%) diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index 60aa63a854..c66527941e 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -19,7 +19,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -37,7 +37,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -55,7 +55,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -73,7 +73,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -91,7 +91,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -109,7 +109,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -127,7 +127,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -145,7 +145,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -163,7 +163,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -181,7 +181,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -199,7 +199,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -217,7 +217,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -235,7 +235,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -253,7 +253,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -271,7 +271,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -289,7 +289,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config @@ -304,7 +304,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache.driver + - @cache - @user - @auth - @config diff --git a/phpBB/includes/notification/exception.php b/phpBB/includes/notification/exception.php new file mode 100644 index 0000000000..a52d6fdc57 --- /dev/null +++ b/phpBB/includes/notification/exception.php @@ -0,0 +1,29 @@ +getMessage(); + } +} diff --git a/phpBB/includes/notification/method/base.php b/phpBB/includes/notification/method/base.php index 22418c9be8..bae85310b2 100644 --- a/phpBB/includes/notification/method/base.php +++ b/phpBB/includes/notification/method/base.php @@ -66,7 +66,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth * * @param phpbb_user_loader $user_loader * @param phpbb_db_driver $db - * @param phpbb_cache_driver_interface $cache + * @param phpbb_cache_service $cache * @param phpbb_user $user * @param phpbb_auth $auth * @param phpbb_config $config @@ -74,7 +74,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth * @param string $php_ext * @return phpbb_notification_method_base */ - public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) + public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) { $this->user_loader = $user_loader; $this->db = $db; diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index f56956d16a..983383ce2a 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -96,7 +96,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * * @param phpbb_user_loader $user_loader * @param phpbb_db_driver $db - * @param phpbb_cache_driver_interface $cache + * @param phpbb_cache_service $cache * @param phpbb_user $user * @param phpbb_auth $auth * @param phpbb_config $config @@ -107,7 +107,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * @param string $user_notifications_table * @return phpbb_notification_type_base */ - public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->user_loader = $user_loader; $this->db = $db; diff --git a/tests/mock/notifications_notification_manager.php b/tests/notification/manager_helper.php similarity index 95% rename from tests/mock/notifications_notification_manager.php rename to tests/notification/manager_helper.php index c995afb9ab..8d2ce5e002 100644 --- a/tests/mock/notifications_notification_manager.php +++ b/tests/notification/manager_helper.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Notifications service class * @package notifications */ -class phpbb_mock_notifications_notification_manager extends phpbb_notification_manager +class phpbb_notification_manager_helper extends phpbb_notification_manager { public function set_var($name, $value) { diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index beccf55371..5746d0090e 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -7,6 +7,8 @@ * */ +require_once dirname(__FILE__) . '/manager_helper.php'; + class phpbb_notification_test extends phpbb_database_test_case { protected $notifications, $db, $container, $user, $config, $auth, $cache; @@ -34,16 +36,23 @@ class phpbb_notification_test extends phpbb_database_test_case $this->user = new phpbb_mock_user(); $this->user_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $this->auth = new phpbb_mock_notifications_auth(); - $this->cache = new phpbb_mock_cache(); + $this->cache = new phpbb_cache_service( + new phpbb_cache_driver_null(), + $this->config, + $this->db, + $phpbb_root_path, + $phpEx + ); $this->container = new phpbb_mock_container_builder(); - $this->notifications = new phpbb_mock_notifications_notification_manager( + $this->notifications = new phpbb_notification_manager_helper( array(), array(), $this->container, $this->user_loader, $this->db, + $this->cache, $this->user, $phpbb_root_path, $phpEx, @@ -121,6 +130,20 @@ class phpbb_notification_test extends phpbb_database_test_case public function test_notifications() { + $this->db->sql_query('DELETE FROM phpbb_notification_types'); + + $types = array('quote', 'bookmark', 'post', 'test'); + foreach ($types as $id => $type) + { + $this->db->sql_query('INSERT INTO phpbb_notification_types ' . + $this->db->sql_build_array('INSERT', array( + 'notification_type_id' => ($id + 1), + 'notification_type_name' => $type, + 'notification_type_enabled' => 1, + )) + ); + } + // Used to test post notifications later $this->db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( 'topic_id' => 2, @@ -195,7 +218,7 @@ class phpbb_notification_test extends phpbb_database_test_case $expected = array( 1 => array( - 'item_type' => 'test', + 'notification_type_id' => 4, 'item_id' => 1, 'item_parent_id' => 1, 'user_id' => 0, @@ -204,7 +227,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'notification_data' => array(), ), 2 => array( - 'item_type' => 'test', + 'notification_type_id' => 4, 'item_id' => 2, 'item_parent_id' => 2, 'user_id' => 0, @@ -213,7 +236,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'notification_data' => array(), ), 3 => array( - 'item_type' => 'test', + 'notification_type_id' => 4, 'item_id' => 3, 'item_parent_id' => 2, 'user_id' => 0, @@ -222,7 +245,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'notification_data' => array(), ), 4 => array( - 'item_type' => 'post', + 'notification_type_id' => 3, 'item_id' => 4, 'item_parent_id' => 2, 'user_id' => 0, @@ -238,7 +261,7 @@ class phpbb_notification_test extends phpbb_database_test_case ), ), 5 => array( - 'item_type' => 'bookmark', + 'notification_type_id' => 2, 'item_id' => 5, 'item_parent_id' => 2, 'user_id' => 0, @@ -301,7 +324,7 @@ class phpbb_notification_test extends phpbb_database_test_case $expected = array( 1 => array( - 'item_type' => 'test', + 'notification_type_id' => 4, 'item_id' => 1, 'item_parent_id' => 2, 'user_id' => 0, @@ -310,7 +333,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'notification_data' => array(), ), 2 => array( - 'item_type' => 'test', + 'notification_type_id' => 4, 'item_id' => 2, 'item_parent_id' => 2, 'user_id' => 0, @@ -319,7 +342,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'notification_data' => array(), ), 3 => array( - 'item_type' => 'test', + 'notification_type_id' => 4, 'item_id' => 3, 'item_parent_id' => 2, 'user_id' => 0, @@ -328,7 +351,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'notification_data' => array(), ), 4 => array( - 'item_type' => 'post', + 'notification_type_id' => 3, 'item_id' => 4, 'item_parent_id' => 2, 'user_id' => 0, @@ -344,7 +367,7 @@ class phpbb_notification_test extends phpbb_database_test_case ), ), 5 => array( - 'item_type' => 'bookmark', + 'notification_type_id' => 2, 'item_id' => 5, 'item_parent_id' => 2, 'user_id' => 0, From 78c22248fa35dd01c0e30d1ea896379890cefe66 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 29 Apr 2013 22:41:08 -0500 Subject: [PATCH 027/172] [ticket/11413] Fix some more tests PHPBB3-11413 --- tests/notification/submit_post_base.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 953bedac80..5fbcfc8776 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -119,8 +119,9 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case public function test_submit_post($additional_post_data, $expected_before, $expected_after) { $sql = 'SELECT user_id, item_id, item_parent_id - FROM ' . NOTIFICATIONS_TABLE . " - WHERE item_type = '" . $this->item_type . "' + FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATIONS_TYPES_TABLE . " nt + WHERE nt.notification_type_name = '" . $this->item_type . "' + AND n.notification_type_id = nt.notification_type_id ORDER BY user_id, item_id ASC"; $result = $this->db->sql_query($sql); $this->assertEquals($expected_before, $this->db->sql_fetchrowset($result)); @@ -131,8 +132,9 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case submit_post('reply', '', 'poster-name', POST_NORMAL, $poll_data, $post_data, false, false); $sql = 'SELECT user_id, item_id, item_parent_id - FROM ' . NOTIFICATIONS_TABLE . " - WHERE item_type = '" . $this->item_type . "' + FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATIONS_TYPES_TABLE . " nt + WHERE nt.notification_type_name = '" . $this->item_type . "' + AND n.notification_type_id = nt.notification_type_id ORDER BY user_id ASC, item_id ASC"; $result = $this->db->sql_query($sql); $this->assertEquals($expected_after, $this->db->sql_fetchrowset($result)); From 878df5f280878b465e6e42c8257ddbdb66327a92 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 29 Apr 2013 22:52:52 -0500 Subject: [PATCH 028/172] [ticket/11413] Fix test fixtures and tests PHPBB3-11413 --- .../fixtures/submit_post_bookmark.xml | 8 ++-- .../fixtures/submit_post_post.xml | 10 +++-- .../fixtures/submit_post_post_in_queue.xml | 8 ++-- .../fixtures/submit_post_quote.xml | 8 ++-- tests/notification/submit_post_base.php | 40 ++++++++++++------- 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/tests/notification/fixtures/submit_post_bookmark.xml b/tests/notification/fixtures/submit_post_bookmark.xml index b669d4c1b6..d4bf8df73f 100644 --- a/tests/notification/fixtures/submit_post_bookmark.xml +++ b/tests/notification/fixtures/submit_post_bookmark.xml @@ -29,14 +29,14 @@ - item_type + notification_type_iduser_iditem_iditem_parent_idnotification_readnotification_data - bookmark + 1 5 1 1 @@ -45,9 +45,11 @@
- notification_type + notification_type_id + notification_type_namenotification_type_enabled + 1 bookmark 1 diff --git a/tests/notification/fixtures/submit_post_post.xml b/tests/notification/fixtures/submit_post_post.xml index cead4f7c26..b0ffa042c5 100644 --- a/tests/notification/fixtures/submit_post_post.xml +++ b/tests/notification/fixtures/submit_post_post.xml @@ -21,14 +21,14 @@
- item_type + notification_type_iduser_iditem_iditem_parent_idnotification_readnotification_data - post + 1 5 1 1 @@ -36,7 +36,7 @@ - post + 1 8 1 1 @@ -45,9 +45,11 @@
- notification_type + notification_type_id + notification_type_namenotification_type_enabled + 1 post 1 diff --git a/tests/notification/fixtures/submit_post_post_in_queue.xml b/tests/notification/fixtures/submit_post_post_in_queue.xml index eedcebf71d..090e90ea49 100644 --- a/tests/notification/fixtures/submit_post_post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_post_in_queue.xml @@ -1,14 +1,14 @@
- item_type + notification_type_iduser_iditem_iditem_parent_idnotification_readnotification_data - post_in_queue + 1 6 1 1 @@ -17,9 +17,11 @@
- notification_type + notification_type_id + notification_type_namenotification_type_enabled + 1 post_in_queue 1 diff --git a/tests/notification/fixtures/submit_post_quote.xml b/tests/notification/fixtures/submit_post_quote.xml index 884a84af4a..f22ed97d91 100644 --- a/tests/notification/fixtures/submit_post_quote.xml +++ b/tests/notification/fixtures/submit_post_quote.xml @@ -1,14 +1,14 @@
- item_type + notification_type_iduser_iditem_iditem_parent_idnotification_readnotification_data - quote + 1 5 1 1 @@ -17,9 +17,11 @@
- notification_type + notification_type_id + notification_type_namenotification_type_enabled + 1 quote 1 diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 5fbcfc8776..c3dbfc2535 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -52,9 +52,6 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case $this->db = $this->new_dbal(); $db = $this->db; - // Cache - $cache = new phpbb_mock_cache(); - // Auth $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) @@ -72,6 +69,14 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case set_config(null, null, null, $config); set_config_count(null, null, null, $config); + $cache = new phpbb_cache_service( + new phpbb_cache_driver_null(), + $config, + $db, + $phpbb_root_path, + $phpEx + ); + // Event dispatcher $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); @@ -94,23 +99,28 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case $user_loader = new phpbb_user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); - // Notification Manager - $phpbb_notifications = new phpbb_notification_manager(array(), array(), - $phpbb_container, $user_loader, $db, $user, - $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); - $phpbb_container->set('notification_manager', $phpbb_notifications); - // Notification Types - $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue'); + $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'approve_topic', 'approve_post'); + $notification_types_array = array(); foreach ($notification_types as $type) { $class_name = 'phpbb_notification_type_' . $type; - $phpbb_container->set('notification.type.' . $type, new $class_name( + $class = new $class_name( $user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $phpEx, - NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE)); + NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); + + $phpbb_container->set('notification.type.' . $type, $class); + + $notification_types_array['notification.type.' . $type] = $class; } + + // Notification Manager + $phpbb_notifications = new phpbb_notification_manager($notification_types_array, array(), + $phpbb_container, $user_loader, $db, $cache, $user, + $phpbb_root_path, $phpEx, + NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); + $phpbb_container->set('notification_manager', $phpbb_notifications); } /** @@ -119,7 +129,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case public function test_submit_post($additional_post_data, $expected_before, $expected_after) { $sql = 'SELECT user_id, item_id, item_parent_id - FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATIONS_TYPES_TABLE . " nt + FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . " nt WHERE nt.notification_type_name = '" . $this->item_type . "' AND n.notification_type_id = nt.notification_type_id ORDER BY user_id, item_id ASC"; @@ -132,7 +142,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case submit_post('reply', '', 'poster-name', POST_NORMAL, $poll_data, $post_data, false, false); $sql = 'SELECT user_id, item_id, item_parent_id - FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATIONS_TYPES_TABLE . " nt + FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . " nt WHERE nt.notification_type_name = '" . $this->item_type . "' AND n.notification_type_id = nt.notification_type_id ORDER BY user_id ASC, item_id ASC"; From 947550df8f5e2ba624adc26ddd22c7fe74e4f602 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 30 Apr 2013 11:27:43 +0300 Subject: [PATCH 029/172] [ticket/10741] Docblock for phpbb.resizeTextArea Better description of phpBB.resizeTextArea with detailed explanation of all optional parameters. Removed unnecessary semicolons PHPBB3-10741 --- phpBB/assets/javascript/core.js | 41 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 827ed2e34a..bb1fef253e 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -571,28 +571,39 @@ phpbb.addAjaxCallback('toggle_link', function() { /** * Automatically resize textarea * -* This function automatically resizes textarea elements when user +* This function automatically resizes textarea elements when user * types text. * -* @param jQuery item jQuery object to resize -* @param object options Optional parameter that adjusts default +* @param {jQuery} items jQuery object(s) to resize +* @param {object} options Optional parameter that adjusts default * configuration. See configuration variable +* +* Optional parameters: +* minWindowHeight {number} Minimum browser window height when textareas are resized. Default = 500 +* minHeight {number} Minimum height of textarea. Default = 200 +* maxHeight {number} Maximum height of textarea. Default = 500 +* heightDiff {number} Minimum difference between window and textarea height. Default = 200 +* resizeCallback {function} Function to call after resizing textarea +* resetCallback {function} Function to call when resize has been canceled + +* Callback function format: function(item) {} +* this points to DOM object +* item is a jQuery object, same as this */ -phpbb.resizeTextArea = function(items) { +phpbb.resizeTextArea = function(items, options) { // Configuration var configuration = { - minWindowHeight: 500, // Minimum browser window height when textareas are resized - minHeight: 200, // Minimum height of textarea - maxHeight: 500, // Maximum height of textarea - heightDiff: 200, // Minimum difference between window and textarea height - // In following callbacks parameter "item" is jQuery object. "this" points to DOM object - resizeCallback: function(item) { }, // Function to call after resizing textarea. - resetCallback: function(item) { } // Function to call when resize has been canceled - } + minWindowHeight: 500, + minHeight: 200, + maxHeight: 500, + heightDiff: 200, + resizeCallback: function(item) { }, + resetCallback: function(item) { } + }; if (arguments.length > 1) { - configuration = $.extend(configuration, arguments[1]); + configuration = $.extend(configuration, options); } function resetAutoResize(item) @@ -603,7 +614,7 @@ phpbb.resizeTextArea = function(items) { $(item).css({height: '', resize: ''}).removeClass('auto-resized'); configuration.resetCallback.call(item, $item); } - }; + } function autoResize(item) { @@ -634,7 +645,7 @@ phpbb.resizeTextArea = function(items) { { setHeight(Math.min(maxHeight, scrollHeight)); } - }; + } items.bind('focus change keyup', function() { $(this).each(function() { From 00ea297b614a10ad045075cad6f69f2c431c2757 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 30 Apr 2013 20:54:01 -0500 Subject: [PATCH 030/172] [ticket/11413] Create test for notification conversion PHPBB3-11413 --- tests/notification/convert_test.php | 114 ++++++++++++++++++++++++ tests/notification/fixtures/convert.xml | 52 +++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/notification/convert_test.php create mode 100644 tests/notification/fixtures/convert.xml diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php new file mode 100644 index 0000000000..9fa7fc6a42 --- /dev/null +++ b/tests/notification/convert_test.php @@ -0,0 +1,114 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/convert.xml'); + } + + protected function setUp() + { + parent::setUp(); + + global $phpbb_root_path, $phpEx; + + $this->db = $this->new_dbal(); + + $this->migration = new phpbb_db_migration_data_310_notifications2( + new phpbb_config(array()), + $this->db, + new phpbb_db_tools($this->db), + $phpbb_root_path, + $phpEx, + 'phpbb_' + ); + } + + public function test_convert() + { + $this->migration->convert_notifications(); + + $expected = array_merge( + $this->create_expected('post', 1, 'email'), + $this->create_expected('topic', 1, 'email'), + + $this->create_expected('pm', 2, 'email'), + $this->create_expected('post', 2, 'email'), + $this->create_expected('topic', 2, 'email'), + + $this->create_expected('post', 3, 'jabber'), + $this->create_expected('topic', 3, 'jabber'), + + $this->create_expected('pm', 4, 'jabber'), + $this->create_expected('post', 4, 'jabber'), + $this->create_expected('topic', 4, 'jabber'), + + $this->create_expected('post', 5, 'both'), + $this->create_expected('topic', 5, 'both'), + + $this->create_expected('pm', 6, 'both'), + $this->create_expected('post', 6, 'both'), + $this->create_expected('topic', 6, 'both') + ); + + $sql = 'SELECT * FROM phpbb_user_notifications + ORDER BY user_id ASC, item_type ASC'; + $result = $this->db->sql_query($sql); + $rowset = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + $this->assertEquals($expected, $rowset); + } + + protected function create_expected($type, $user_id, $method = '') + { + $return = array(); + + if ($method != '') + { + $return[] = array( + 'item_type' => $type, + 'item_id' => '0', + 'user_id' => (string) $user_id, + 'method' => '', + 'notify' => '1', + ); + } + + if ($method == 'email' || $method == 'both') + { + $return[] = array( + 'item_type' => $type, + 'item_id' => '0', + 'user_id' => (string) $user_id, + 'method' => 'email', + 'notify' => '1', + ); + } + + if ($method == 'jabber' || $method == 'both') + { + $return[] = array( + 'item_type' => $type, + 'item_id' => '0', + 'user_id' => (string) $user_id, + 'method' => 'jabber', + 'notify' => '1', + ); + } + + return $return; + } +} diff --git a/tests/notification/fixtures/convert.xml b/tests/notification/fixtures/convert.xml new file mode 100644 index 0000000000..a244070a95 --- /dev/null +++ b/tests/notification/fixtures/convert.xml @@ -0,0 +1,52 @@ + + +
+ user_id + username + username_clean + user_notify_type + user_notify_pm + + 1 + 1 + 1 + 0 + 0 + + + 2 + 2 + 2 + 0 + 1 + + + 3 + 3 + 3 + 1 + 0 + + + 4 + 4 + 4 + 1 + 1 + + + 5 + 5 + 5 + 2 + 0 + + + 6 + 6 + 6 + 2 + 1 + +
+ From 81b2ad158c272cd306ea35a9b44875a5c11e7135 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 30 Apr 2013 21:01:46 -0500 Subject: [PATCH 031/172] [ticket/11413] Use sql_insert_buffer PHPBB3-11413 --- .../db/migration/data/310/notifications2.php | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications2.php index cd078f8f60..44b3f8fd49 100644 --- a/phpBB/includes/db/migration/data/310/notifications2.php +++ b/phpBB/includes/db/migration/data/310/notifications2.php @@ -108,7 +108,7 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration FROM ' . USERS_TABLE; $result = $this->db->sql_query($sql); - $sql_insert_data = array(); + $insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table); while ($row = $this->db->sql_fetchrow($result)) { $notification_methods = array(); @@ -129,8 +129,8 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration // Notifications for posts foreach (array('post', 'topic') as $item_type) { - $sql_insert_data = $this->add_method_rows( - $sql_insert_data, + $this->add_method_rows( + $insert_buffer, $item_type, 0, $row['user_id'], @@ -142,30 +142,21 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration { // Notifications for private messages // User either gets all methods or no method - $sql_insert_data = $this->add_method_rows( - $sql_insert_data, + $this->add_method_rows( + $insert_buffer, 'pm', 0, $row['user_id'], $notification_methods ); } - - if (sizeof($sql_insert_data) > 500) - { - $this->db->sql_multi_insert($insert_table, $sql_insert_data); - $sql_insert_data = array(); - } } $this->db->sql_freeresult($result); - if (!empty($sql_insert_data)) - { - $this->db->sql_multi_insert($insert_table, $sql_insert_data); - } + $insert_buffer->flush(); } - protected function add_method_rows(array $sql_insert_data, $item_type, $item_id, $user_id, array $methods) + protected function add_method_rows(phpbb_db_sql_insert_buffer $insert_buffer, $item_type, $item_id, $user_id, array $methods) { $row_base = array( 'item_type' => $item_type, @@ -176,9 +167,7 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration foreach ($methods as $method) { $row_base['method'] = $method; - $sql_insert_data[] = $row_base; + $insert_buffer->insert($row_base); } - - return $sql_insert_data; } } From f2e618a05de5f406477363cb9236aca46569afe1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 30 Apr 2013 21:10:04 -0500 Subject: [PATCH 032/172] [ticket/11413] Test get_notification_type_id and _ids functions PHPBB3-11413 --- tests/notification/notification_test.php | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 5746d0090e..4ffd3587f1 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -99,6 +99,35 @@ class phpbb_notification_test extends phpbb_database_test_case return new $type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); } + public function test_get_notification_type_id() + { + // They should be inserted the first time + $this->assertEquals(1, $this->notifications->get_notification_type_id('post')); + $this->assertEquals(2, $this->notifications->get_notification_type_id('quote')); + $this->assertEquals(3, $this->notifications->get_notification_type_id('test')); + + $this->assertEquals(array( + 'test' => 3, + 'quote' => 2, + 'post' => 1, + ), + $this->notifications->get_notification_type_ids(array( + 'test', + 'quote', + 'post', + ) + )); + $this->assertEquals(2, $this->notifications->get_notification_type_id('quote')); + + try + { + $this->assertEquals(3, $this->notifications->get_notification_type_id('fail')); + + $this->fail('Non-existant type should throw exception'); + } + catch (Exception $e) {} + } + public function test_get_subscription_types() { $subscription_types = $this->notifications->get_subscription_types(); From 2f2feaa4e8ad9a18fd9ddcb7d65ae958c544dbcb Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 30 Apr 2013 21:38:40 -0500 Subject: [PATCH 033/172] [ticket/11413] Don't use the database for the convert test Different databases seem to work slightly differently here and are causing errors PHPBB3-11413 --- .../db/migration/data/310/notifications2.php | 11 +++++- tests/notification/convert_test.php | 37 ++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications2.php index 44b3f8fd49..c90944dcc9 100644 --- a/phpBB/includes/db/migration/data/310/notifications2.php +++ b/phpBB/includes/db/migration/data/310/notifications2.php @@ -100,7 +100,16 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration public function convert_notifications() { $insert_table = $this->table_prefix . 'user_notifications'; + $insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table); + $this->perform_conversion($insert_buffer, $insert_table); + } + + /** + * Perform the conversion (separate for testability) + */ + public function perform_conversion($insert_buffer, $insert_table) + { $sql = 'DELETE FROM ' . $insert_table; $this->db->sql_query($sql); @@ -108,7 +117,6 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration FROM ' . USERS_TABLE; $result = $this->db->sql_query($sql); - $insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table); while ($row = $this->db->sql_fetchrow($result)) { $notification_methods = array(); @@ -162,6 +170,7 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration 'item_type' => $item_type, 'item_id' => (int) $item_id, 'user_id' => (int) $user_id, + 'notify' => 1 ); foreach ($methods as $method) diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 9fa7fc6a42..529b2935e1 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -38,38 +38,33 @@ class phpbb_notification_convert_test extends phpbb_database_test_case public function test_convert() { - $this->migration->convert_notifications(); + $buffer = new phpbb_mock_sql_insert_buffer($this->db, 'phpbb_user_notifications'); + $this->migration->perform_conversion($buffer, 'phpbb_user_notifications'); $expected = array_merge( $this->create_expected('post', 1, 'email'), $this->create_expected('topic', 1, 'email'), - $this->create_expected('pm', 2, 'email'), $this->create_expected('post', 2, 'email'), $this->create_expected('topic', 2, 'email'), + $this->create_expected('pm', 2, 'email'), $this->create_expected('post', 3, 'jabber'), $this->create_expected('topic', 3, 'jabber'), - $this->create_expected('pm', 4, 'jabber'), $this->create_expected('post', 4, 'jabber'), $this->create_expected('topic', 4, 'jabber'), + $this->create_expected('pm', 4, 'jabber'), $this->create_expected('post', 5, 'both'), $this->create_expected('topic', 5, 'both'), - $this->create_expected('pm', 6, 'both'), $this->create_expected('post', 6, 'both'), - $this->create_expected('topic', 6, 'both') + $this->create_expected('topic', 6, 'both'), + $this->create_expected('pm', 6, 'both') ); - $sql = 'SELECT * FROM phpbb_user_notifications - ORDER BY user_id ASC, item_type ASC'; - $result = $this->db->sql_query($sql); - $rowset = $this->db->sql_fetchrowset($result); - $this->db->sql_freeresult($result); - - $this->assertEquals($expected, $rowset); + $this->assertEquals($expected, $buffer->get_buffer()); } protected function create_expected($type, $user_id, $method = '') @@ -80,10 +75,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case { $return[] = array( 'item_type' => $type, - 'item_id' => '0', - 'user_id' => (string) $user_id, + 'item_id' => 0, + 'user_id' => $user_id, 'method' => '', - 'notify' => '1', + 'notify' => 1, ); } @@ -91,10 +86,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case { $return[] = array( 'item_type' => $type, - 'item_id' => '0', - 'user_id' => (string) $user_id, + 'item_id' => 0, + 'user_id' => $user_id, 'method' => 'email', - 'notify' => '1', + 'notify' => 1, ); } @@ -102,10 +97,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case { $return[] = array( 'item_type' => $type, - 'item_id' => '0', - 'user_id' => (string) $user_id, + 'item_id' => 0, + 'user_id' => $user_id, 'method' => 'jabber', - 'notify' => '1', + 'notify' => 1, ); } From 900467681077b7c4cd48529b53f083c8ea0334f6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 30 Apr 2013 21:53:16 -0500 Subject: [PATCH 034/172] [ticket/11413] Include mock class PHPBB3-11413 --- tests/mock/sql_insert_buffer.php | 21 +++++++++++++++++++++ tests/notification/convert_test.php | 1 + 2 files changed, 22 insertions(+) create mode 100644 tests/mock/sql_insert_buffer.php diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php new file mode 100644 index 0000000000..ba09aa8d7f --- /dev/null +++ b/tests/mock/sql_insert_buffer.php @@ -0,0 +1,21 @@ +buffer)) ? true : false; + } + + public function get_buffer() + { + return $this->buffer; + } +} diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 529b2935e1..ba586b681d 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -8,6 +8,7 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; +require_once dirname(__FILE__) . '/../mock/sql_insert_buffer.php'; class phpbb_notification_convert_test extends phpbb_database_test_case { From 9db4e856db426c68d0e3055dbcad9754ce65779d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 1 May 2013 13:00:43 -0500 Subject: [PATCH 035/172] [ticket/11415] Move while loop from ext manager to acp_extensions.php Now enable_step works as it's supposed to (do one step at a time) and less refreshes are required for the user. PHPBB3-11415 --- phpBB/includes/acp/acp_extensions.php | 34 ++++++++++++++++++++------- phpBB/includes/extension/manager.php | 21 +++-------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index e4defa0400..7fdeb1ff8b 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -44,6 +44,10 @@ class acp_extensions $action = $request->variable('action', 'list'); $ext_name = $request->variable('ext_name', ''); + // What is a safe limit of execution time? Half the max execution time should be safe. + $safe_time_limit = (ini_get('max_execution_time') / 2); + $start_time = time(); + // Cancel action if ($request->is_set_post('cancel')) { @@ -105,11 +109,15 @@ class acp_extensions try { - if ($phpbb_extension_manager->enable_step($ext_name)) + while ($phpbb_extension_manager->enable_step($ext_name)) { - $template->assign_var('S_NEXT_STEP', true); + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + } } } catch (phpbb_db_migration_exception $e) @@ -139,11 +147,15 @@ class acp_extensions break; case 'disable': - if ($phpbb_extension_manager->disable_step($ext_name)) + while ($phpbb_extension_manager->disable_step($ext_name)) { - $template->assign_var('S_NEXT_STEP', true); + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name)); + } } $this->tpl_name = 'acp_ext_disable'; @@ -165,11 +177,15 @@ class acp_extensions case 'purge': try { - if ($phpbb_extension_manager->purge_step($ext_name)) + while ($phpbb_extension_manager->purge_step($ext_name)) { - $template->assign_var('S_NEXT_STEP', true); + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $start_time) >= $safe_time_limit) + { + $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + } } } catch (phpbb_db_migration_exception $e) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index a1022762b8..d3e9d56501 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -546,22 +546,11 @@ class phpbb_extension_manager $migrations = $finder->get_classes_from_files($migrations); $this->migrator->set_migrations($migrations); - // What is a safe limit of execution time? Half the max execution time should be safe. - $safe_time_limit = (ini_get('max_execution_time') / 2); - $start_time = time(); - if ($mode == 'enable') { - while (!$this->migrator->finished()) - { - $this->migrator->update(); + $this->migrator->update(); - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - return false; - } - } + return $this->migrator->finished(); } else if ($mode == 'purge') { @@ -571,11 +560,7 @@ class phpbb_extension_manager { $this->migrator->revert($migration); - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $start_time) >= $safe_time_limit) - { - return false; - } + return false; } } } From 7ed21cc6f2b7eee305d0c7c00821ef1ce680b77e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 1 May 2013 14:02:13 -0500 Subject: [PATCH 036/172] [ticket/11415] Move migrator to base extension class from ext.manager PHPBB3-11415 --- phpBB/includes/extension/base.php | 75 ++++++++++++++++++++++-- phpBB/includes/extension/manager.php | 86 +++++----------------------- 2 files changed, 86 insertions(+), 75 deletions(-) diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php index d51589d719..dc6d771672 100644 --- a/phpBB/includes/extension/base.php +++ b/phpBB/includes/extension/base.php @@ -27,25 +27,42 @@ class phpbb_extension_base implements phpbb_extension_interface /** @var ContainerInterface */ protected $container; + /** @var string */ + protected $extension_name; + + /** @var string */ + protected $extension_path; + /** * Constructor * * @param ContainerInterface $container Container object + * @param string $extension_name Name of this extension (from ext.manager) + * @param string $extension_path Relative path to this extension */ - public function __construct(ContainerInterface $container) + public function __construct(ContainerInterface $container, $extension_name, $extension_path) { $this->container = $container; + + $this->extension_name = $extension_name; + $this->extension_path = $extension_path; } /** - * Single enable step that does nothing + * Single enable step that installs any included migrations * * @param mixed $old_state State returned by previous call of this method * @return false Indicates no further steps are required */ public function enable_step($old_state) { - return false; + $migrations = $this->get_migration_file_list(); + $migrator = $this->container->get('migrator'); + $migrator->set_migrations($migrations); + + $migrator->update(); + + return !$migrator->finished(); } /** @@ -60,13 +77,63 @@ class phpbb_extension_base implements phpbb_extension_interface } /** - * Single purge step that does nothing + * Single purge step that reverts any included and installed migrations * * @param mixed $old_state State returned by previous call of this method * @return false Indicates no further steps are required */ public function purge_step($old_state) { + $migrations = $this->get_migration_file_list(); + $migrator = $this->container->get('migrator'); + $migrator->set_migrations($migrations); + + foreach ($migrations as $migration) + { + while ($migrator->migration_state($migration) !== false) + { + $migrator->revert($migration); + + return true; + } + } + return false; } + + /** + * Get the list of migration files from this extension + * + * @return array + */ + protected function get_migration_file_list() + { + static $migrations = false; + + if ($migrations !== false) + { + return $migrations; + } + + // Only have the finder search in this extension path directory + $extensions = array( + $this->extension_name => $this->extension_path, + ); + + $extension_manager = $this->container->get('ext.manager'); + $finder = $extension_manager->get_finder(); + $migrations = array(); + $file_list = $finder + ->extension_directory('/migrations') + ->find_from_paths($extensions); + + foreach ($file_list as $file) + { + $migrations[$file['named_path']] = $file['ext_name']; + } + + $migrations = $finder->get_classes_from_files($migrations); + + return $migrations; + } } diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index d3e9d56501..8b8a69f14c 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -138,11 +138,11 @@ class phpbb_extension_manager if (class_exists($extension_class_name)) { - return new $extension_class_name($this->container); + return new $extension_class_name($this->container, $name, $this->get_extension_path($name, true)); } else { - return new phpbb_extension_base($this->container); + return new phpbb_extension_base($this->container, $name, $this->get_extension_path($name, true)); } } @@ -178,12 +178,6 @@ class phpbb_extension_manager $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; - // Returns false if not completed - if (!$this->handle_migrations($name, 'enable')) - { - return true; - } - $extension = $this->get_extension($name); $state = $extension->enable_step($old_state); @@ -199,12 +193,21 @@ class phpbb_extension_manager $this->extensions[$name]['ext_path'] = $this->get_extension_path($extension_data['ext_name']); ksort($this->extensions); - $sql = 'UPDATE ' . $this->extension_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . " + $sql = 'SELECT COUNT(ext_name) as row_count + FROM ' . $this->extension_table . " WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; - $this->db->sql_query($sql); + $result = $this->db->sql_query($sql); + $count = $this->db->sql_fetchfield('row_count'); + $this->db->sql_freeresult($result); - if (!$this->db->sql_affectedrows()) + if ($count) + { + $sql = 'UPDATE ' . $this->extension_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . " + WHERE ext_name = '" . $this->db->sql_escape($name) . "'"; + $this->db->sql_query($sql); + } + else { $sql = 'INSERT INTO ' . $this->extension_table . ' ' . $this->db->sql_build_array('INSERT', $extension_data); @@ -335,12 +338,6 @@ class phpbb_extension_manager $old_state = unserialize($this->extensions[$name]['ext_state']); - // Returns false if not completed - if (!$this->handle_migrations($name, 'purge')) - { - return true; - } - $extension = $this->get_extension($name); $state = $extension->purge_step($old_state); @@ -514,57 +511,4 @@ class phpbb_extension_manager { return new phpbb_extension_finder($this, $this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); } - - /** - * Handle installing/reverting migrations - * - * @param string $extension_name Name of the extension - * @param string $mode enable or purge - * @return bool True if completed, False if not completed - */ - protected function handle_migrations($extension_name, $mode) - { - $extensions = array( - $extension_name => $this->phpbb_root_path . $this->get_extension_path($extension_name), - ); - - $finder = $this->get_finder(); - $migrations = array(); - $file_list = $finder - ->extension_directory('/migrations') - ->find_from_paths($extensions); - - if (empty($file_list)) - { - return true; - } - - foreach ($file_list as $file) - { - $migrations[$file['named_path']] = $file['ext_name']; - } - $migrations = $finder->get_classes_from_files($migrations); - $this->migrator->set_migrations($migrations); - - if ($mode == 'enable') - { - $this->migrator->update(); - - return $this->migrator->finished(); - } - else if ($mode == 'purge') - { - foreach ($migrations as $migration) - { - while ($this->migrator->migration_state($migration) !== false) - { - $this->migrator->revert($migration); - - return false; - } - } - } - - return true; - } } From 60e32728393d4258f92f7893f8275889278a995f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 1 May 2013 14:09:08 -0500 Subject: [PATCH 037/172] [ticket/11415] Remove migrator dependency from extension manager PHPBB3-11415 --- phpBB/config/services.yml | 1 - phpBB/includes/extension/manager.php | 5 +---- tests/dbal/migrator_test.php | 6 +++++- tests/extension/manager_test.php | 6 ++++-- tests/extension/metadata_manager_test.php | 5 ++++- tests/test_framework/phpbb_functional_test_case.php | 5 ++++- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 7923c94a3f..306dc2dc77 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -130,7 +130,6 @@ services: - @service_container - @dbal.conn - @config - - @migrator - @filesystem - %tables.ext% - %core.root_path% diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 8b8a69f14c..b42043748f 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -29,7 +29,6 @@ class phpbb_extension_manager protected $db; protected $config; - protected $migrator; protected $cache; protected $php_ext; protected $extensions; @@ -43,7 +42,6 @@ class phpbb_extension_manager * @param ContainerInterface $container A container * @param phpbb_db_driver $db A database connection * @param phpbb_config $config phpbb_config - * @param phpbb_db_migrator $migrator * @param phpbb_filesystem $filesystem * @param string $extension_table The name of the table holding extensions * @param string $phpbb_root_path Path to the phpbb includes directory. @@ -51,13 +49,12 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, phpbb_filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; - $this->migrator = $migrator; $this->cache = $cache; $this->filesystem = $filesystem; $this->php_ext = $php_ext; diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 6390d6a715..5fc05f2119 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -55,8 +55,12 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case 'phpbb_', $tools ); + + $container = new phpbb_mock_container_builder(); + $container->set('migrator', $migrator); + $this->extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), + $container, $this->db, $this->config, $this->migrator, diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 106f078691..43b7410654 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -107,11 +107,13 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $table_prefix, array() ); + $container = new phpbb_mock_container_builder(); + $container->set('migrator', $migrator); + return new phpbb_extension_manager( - new phpbb_mock_container_builder(), + $container, $db, $config, - $migrator, new phpbb_filesystem(), 'phpbb_ext', dirname(__FILE__) . '/', diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 05d1cbccc3..92a0ff126c 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -59,8 +59,11 @@ class metadata_manager_test extends phpbb_database_test_case $this->table_prefix, array() ); + $container = new phpbb_mock_container_builder(); + $container->set('migrator', $migrator); + $this->extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), + $container, $this->db, $this->config, $this->migrator, diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 5534de89c9..a11c0f72ca 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -148,8 +148,11 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'], array() ); + $container = new phpbb_mock_container_builder(); + $container->set('migrator', $migrator); + $extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), + $container, $db, $config, $migrator, From 87b01fc854b22e3839776505486d5a564e671f5f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 1 May 2013 15:18:53 -0500 Subject: [PATCH 038/172] [ticket/11415] Make migrator/ext.manager dependencies of the base ext class PHPBB3-11415 --- phpBB/includes/extension/base.php | 30 ++++++++++++++++++---------- phpBB/includes/extension/manager.php | 6 ++++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php index dc6d771672..2d22658ff1 100644 --- a/phpBB/includes/extension/base.php +++ b/phpBB/includes/extension/base.php @@ -27,6 +27,12 @@ class phpbb_extension_base implements phpbb_extension_interface /** @var ContainerInterface */ protected $container; + /** @var phpbb_extension_manager */ + protected $extension_manager; + + /** @var phpbb_db_migrator */ + protected $migrator; + /** @var string */ protected $extension_name; @@ -37,12 +43,15 @@ class phpbb_extension_base implements phpbb_extension_interface * Constructor * * @param ContainerInterface $container Container object + * @param phpbb_extension_manager $extension_manager * @param string $extension_name Name of this extension (from ext.manager) * @param string $extension_path Relative path to this extension */ - public function __construct(ContainerInterface $container, $extension_name, $extension_path) + public function __construct(ContainerInterface $container, phpbb_extension_manager $extension_manager, phpbb_db_migrator $migrator, $extension_name, $extension_path) { $this->container = $container; + $this->extension_manager = $extension_manager; + $this->migrator = $migrator; $this->extension_name = $extension_name; $this->extension_path = $extension_path; @@ -57,12 +66,12 @@ class phpbb_extension_base implements phpbb_extension_interface public function enable_step($old_state) { $migrations = $this->get_migration_file_list(); - $migrator = $this->container->get('migrator'); - $migrator->set_migrations($migrations); - $migrator->update(); + $this->migrator->set_migrations($migrations); - return !$migrator->finished(); + $this->migrator->update(); + + return !$this->migrator->finished(); } /** @@ -85,14 +94,14 @@ class phpbb_extension_base implements phpbb_extension_interface public function purge_step($old_state) { $migrations = $this->get_migration_file_list(); - $migrator = $this->container->get('migrator'); - $migrator->set_migrations($migrations); + + $this->migrator->set_migrations($migrations); foreach ($migrations as $migration) { - while ($migrator->migration_state($migration) !== false) + while ($this->migrator->migration_state($migration) !== false) { - $migrator->revert($migration); + $this->migrator->revert($migration); return true; } @@ -120,8 +129,7 @@ class phpbb_extension_base implements phpbb_extension_interface $this->extension_name => $this->extension_path, ); - $extension_manager = $this->container->get('ext.manager'); - $finder = $extension_manager->get_finder(); + $finder = $this->extension_manager->get_finder(); $migrations = array(); $file_list = $finder ->extension_directory('/migrations') diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index b42043748f..799c8b2418 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -133,13 +133,15 @@ class phpbb_extension_manager { $extension_class_name = 'phpbb_ext_' . str_replace('/', '_', $name) . '_ext'; + $migrator = $this->container->get('migrator'); + if (class_exists($extension_class_name)) { - return new $extension_class_name($this->container, $name, $this->get_extension_path($name, true)); + return new $extension_class_name($this->container, $this, $migrator, $name, $this->get_extension_path($name, true)); } else { - return new phpbb_extension_base($this->container, $name, $this->get_extension_path($name, true)); + return new phpbb_extension_base($this->container, $this, $migrator, $name, $this->get_extension_path($name, true)); } } From 07c972f5d71f7aa56d6623774e977ea7958a906e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 2 May 2013 15:39:26 -0500 Subject: [PATCH 039/172] [ticket/11413] Remove changes for ticket 11420 from this branch PHPBB3-11413 --- .../db/migration/data/310/notifications.php | 64 ++++++++++ tests/notification/convert_test.php | 110 ------------------ tests/notification/fixtures/convert.xml | 52 --------- 3 files changed, 64 insertions(+), 162 deletions(-) delete mode 100644 tests/notification/convert_test.php delete mode 100644 tests/notification/fixtures/convert.xml diff --git a/phpBB/includes/db/migration/data/310/notifications.php b/phpBB/includes/db/migration/data/310/notifications.php index 17c939d95a..82bfd4cb2d 100644 --- a/phpBB/includes/db/migration/data/310/notifications.php +++ b/phpBB/includes/db/migration/data/310/notifications.php @@ -91,6 +91,70 @@ class phpbb_db_migration_data_310_notifications extends phpbb_db_migration ), )), array('config.add', array('load_notifications', 1)), + array('custom', array(array($this, 'convert_notifications'))), ); } + + public function convert_notifications() + { + $convert_notifications = array( + array( + 'check' => ($this->config['allow_topic_notify']), + 'item_type' => 'post', + ), + array( + 'check' => ($this->config['allow_forum_notify']), + 'item_type' => 'topic', + ), + array( + 'check' => ($this->config['allow_bookmarks']), + 'item_type' => 'bookmark', + ), + array( + 'check' => ($this->config['allow_privmsg']), + 'item_type' => 'pm', + ), + ); + + foreach ($convert_notifications as $convert_data) + { + if ($convert_data['check']) + { + $sql = 'SELECT user_id, user_notify_type + FROM ' . USERS_TABLE . ' + WHERE user_notify = 1'; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => '', + ))); + + if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) + { + $this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => 'email', + ))); + } + + if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) + { + $this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => 'jabber', + ))); + } + } + $this->db->sql_freeresult($result); + } + } + } } diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php deleted file mode 100644 index ba586b681d..0000000000 --- a/tests/notification/convert_test.php +++ /dev/null @@ -1,110 +0,0 @@ -createXMLDataSet(dirname(__FILE__) . '/fixtures/convert.xml'); - } - - protected function setUp() - { - parent::setUp(); - - global $phpbb_root_path, $phpEx; - - $this->db = $this->new_dbal(); - - $this->migration = new phpbb_db_migration_data_310_notifications2( - new phpbb_config(array()), - $this->db, - new phpbb_db_tools($this->db), - $phpbb_root_path, - $phpEx, - 'phpbb_' - ); - } - - public function test_convert() - { - $buffer = new phpbb_mock_sql_insert_buffer($this->db, 'phpbb_user_notifications'); - $this->migration->perform_conversion($buffer, 'phpbb_user_notifications'); - - $expected = array_merge( - $this->create_expected('post', 1, 'email'), - $this->create_expected('topic', 1, 'email'), - - $this->create_expected('post', 2, 'email'), - $this->create_expected('topic', 2, 'email'), - $this->create_expected('pm', 2, 'email'), - - $this->create_expected('post', 3, 'jabber'), - $this->create_expected('topic', 3, 'jabber'), - - $this->create_expected('post', 4, 'jabber'), - $this->create_expected('topic', 4, 'jabber'), - $this->create_expected('pm', 4, 'jabber'), - - $this->create_expected('post', 5, 'both'), - $this->create_expected('topic', 5, 'both'), - - $this->create_expected('post', 6, 'both'), - $this->create_expected('topic', 6, 'both'), - $this->create_expected('pm', 6, 'both') - ); - - $this->assertEquals($expected, $buffer->get_buffer()); - } - - protected function create_expected($type, $user_id, $method = '') - { - $return = array(); - - if ($method != '') - { - $return[] = array( - 'item_type' => $type, - 'item_id' => 0, - 'user_id' => $user_id, - 'method' => '', - 'notify' => 1, - ); - } - - if ($method == 'email' || $method == 'both') - { - $return[] = array( - 'item_type' => $type, - 'item_id' => 0, - 'user_id' => $user_id, - 'method' => 'email', - 'notify' => 1, - ); - } - - if ($method == 'jabber' || $method == 'both') - { - $return[] = array( - 'item_type' => $type, - 'item_id' => 0, - 'user_id' => $user_id, - 'method' => 'jabber', - 'notify' => 1, - ); - } - - return $return; - } -} diff --git a/tests/notification/fixtures/convert.xml b/tests/notification/fixtures/convert.xml deleted file mode 100644 index a244070a95..0000000000 --- a/tests/notification/fixtures/convert.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - user_id - username - username_clean - user_notify_type - user_notify_pm - - 1 - 1 - 1 - 0 - 0 - - - 2 - 2 - 2 - 0 - 1 - - - 3 - 3 - 3 - 1 - 0 - - - 4 - 4 - 4 - 1 - 1 - - - 5 - 5 - 5 - 2 - 0 - - - 6 - 6 - 6 - 2 - 1 - -
-
From bc9b6c3b6c4081b1671224d69f973c923e105675 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 2 May 2013 15:49:17 -0500 Subject: [PATCH 040/172] [ticket/11413] Correct copyright year PHPBB3-11413 --- phpBB/includes/db/migration/data/310/notifications2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications2.php index c90944dcc9..f655c6734b 100644 --- a/phpBB/includes/db/migration/data/310/notifications2.php +++ b/phpBB/includes/db/migration/data/310/notifications2.php @@ -2,7 +2,7 @@ /** * * @package migration -* @copyright (c) 2012 phpBB Group +* @copyright (c) 2013 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 * */ From 5edae8af1f7d8d94141596b6391c8f967d9694db Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 2 May 2013 15:52:20 -0500 Subject: [PATCH 041/172] [ticket/11413] Remove conversion of user_notifications PHPBB3-11413 --- .../db/migration/data/310/notifications2.php | 90 ------------------- 1 file changed, 90 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications2.php index f655c6734b..ce8343089f 100644 --- a/phpBB/includes/db/migration/data/310/notifications2.php +++ b/phpBB/includes/db/migration/data/310/notifications2.php @@ -89,94 +89,4 @@ class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration ), ); } - - public function update_data() - { - return array( - array('custom', array(array($this, 'convert_notifications'))), - ); - } - - public function convert_notifications() - { - $insert_table = $this->table_prefix . 'user_notifications'; - $insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table); - - $this->perform_conversion($insert_buffer, $insert_table); - } - - /** - * Perform the conversion (separate for testability) - */ - public function perform_conversion($insert_buffer, $insert_table) - { - $sql = 'DELETE FROM ' . $insert_table; - $this->db->sql_query($sql); - - $sql = 'SELECT user_id, user_notify_type, user_notify_pm - FROM ' . USERS_TABLE; - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $notification_methods = array(); - - // In-board notification - $notification_methods[] = ''; - - if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) - { - $notification_methods[] = 'email'; - } - - if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) - { - $notification_methods[] = 'jabber'; - } - - // Notifications for posts - foreach (array('post', 'topic') as $item_type) - { - $this->add_method_rows( - $insert_buffer, - $item_type, - 0, - $row['user_id'], - $notification_methods - ); - } - - if ($row['user_notify_pm']) - { - // Notifications for private messages - // User either gets all methods or no method - $this->add_method_rows( - $insert_buffer, - 'pm', - 0, - $row['user_id'], - $notification_methods - ); - } - } - $this->db->sql_freeresult($result); - - $insert_buffer->flush(); - } - - protected function add_method_rows(phpbb_db_sql_insert_buffer $insert_buffer, $item_type, $item_id, $user_id, array $methods) - { - $row_base = array( - 'item_type' => $item_type, - 'item_id' => (int) $item_id, - 'user_id' => (int) $user_id, - 'notify' => 1 - ); - - foreach ($methods as $method) - { - $row_base['method'] = $method; - $insert_buffer->insert($row_base); - } - } } From 77147b53c119706f5fb6ea6036056aed554adf8c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 3 May 2013 08:38:00 -0500 Subject: [PATCH 042/172] [ticket/11413] Remove mock sql_insert_buffer.php (not relevant to PR) PHPBB3-11413 --- tests/mock/sql_insert_buffer.php | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/mock/sql_insert_buffer.php diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php deleted file mode 100644 index ba09aa8d7f..0000000000 --- a/tests/mock/sql_insert_buffer.php +++ /dev/null @@ -1,21 +0,0 @@ -buffer)) ? true : false; - } - - public function get_buffer() - { - return $this->buffer; - } -} From 3c76cdeb6701a4aded7a7c39b8c9b44c00b5848a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 3 May 2013 08:50:27 -0500 Subject: [PATCH 043/172] [ticket/11413] Remove remaining irrelevant code to this PR PHPBB3-11413 --- phpBB/config/notifications.yml | 34 +++++++++++------------ phpBB/includes/notification/type/base.php | 6 ++-- tests/notification/manager_helper.php | 8 ++---- tests/notification/notification_test.php | 4 +-- tests/notification/submit_post_base.php | 2 +- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index c66527941e..60aa63a854 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -19,7 +19,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -37,7 +37,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -55,7 +55,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -73,7 +73,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -91,7 +91,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -109,7 +109,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -127,7 +127,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -145,7 +145,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -163,7 +163,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -181,7 +181,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -199,7 +199,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -217,7 +217,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -235,7 +235,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -253,7 +253,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -271,7 +271,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -289,7 +289,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config @@ -304,7 +304,7 @@ services: arguments: - @user_loader - @dbal.conn - - @cache + - @cache.driver - @user - @auth - @config diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index 983383ce2a..46517f1c9b 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -30,7 +30,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i /** @var phpbb_db_driver */ protected $db; - /** @var phpbb_cache_service */ + /** @var phpbb_cache_driver_interface */ protected $cache; /** @var phpbb_template */ @@ -96,7 +96,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * * @param phpbb_user_loader $user_loader * @param phpbb_db_driver $db - * @param phpbb_cache_service $cache + * @param phpbb_cache_driver_interface $cache * @param phpbb_user $user * @param phpbb_auth $auth * @param phpbb_config $config @@ -107,7 +107,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i * @param string $user_notifications_table * @return phpbb_notification_type_base */ - public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->user_loader = $user_loader; $this->db = $db; diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 8d2ce5e002..7a794f922f 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -28,12 +28,10 @@ class phpbb_notification_manager_helper extends phpbb_notification_manager // Extra dependencies for get_*_class functions protected $auth = null; - protected $cache = null; protected $config = null; - public function setDependencies($auth, $cache, $config) + public function setDependencies($auth, $config) { $this->auth = $auth; - $this->cache = $cache; $this->config = $config; } @@ -44,7 +42,7 @@ class phpbb_notification_manager_helper extends phpbb_notification_manager { $item_type = 'phpbb_notification_type_' . $item_type; - $item = new $item_type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); + $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); $item->set_notification_manager($this); @@ -60,7 +58,7 @@ class phpbb_notification_manager_helper extends phpbb_notification_manager { $method_name = 'phpbb_notification_method_' . $method_name; - $method = new $method_name($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); + $method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); $method->set_notification_manager($this); diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 4ffd3587f1..c342b10a7f 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -61,7 +61,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'phpbb_user_notifications' ); - $this->notifications->setDependencies($this->auth, $this->cache, $this->config); + $this->notifications->setDependencies($this->auth, $this->config); $types = array(); foreach (array( @@ -123,7 +123,7 @@ class phpbb_notification_test extends phpbb_database_test_case { $this->assertEquals(3, $this->notifications->get_notification_type_id('fail')); - $this->fail('Non-existant type should throw exception'); + $this->fail('Non-existent type should throw an exception'); } catch (Exception $e) {} } diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index c3dbfc2535..59daf6c9cb 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -106,7 +106,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case { $class_name = 'phpbb_notification_type_' . $type; $class = new $class_name( - $user_loader, $db, $cache, $user, $auth, $config, + $user_loader, $db, $cache->get_driver(), $user, $auth, $config, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); From 1b34ddb330d1a666185947ec2325732466f9ce4e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 3 May 2013 09:02:50 -0500 Subject: [PATCH 044/172] [ticket/11415] Fix ext.manager constructor in tests PHPBB3-11415 --- tests/dbal/migrator_test.php | 1 - tests/extension/metadata_manager_test.php | 1 - tests/test_framework/phpbb_functional_test_case.php | 1 - 3 files changed, 3 deletions(-) diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 5fc05f2119..1e40c9c6d6 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -63,7 +63,6 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $container, $this->db, $this->config, - $this->migrator, new phpbb_filesystem(), 'phpbb_ext', dirname(__FILE__) . '/../../phpBB/', diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 92a0ff126c..059b7148da 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -66,7 +66,6 @@ class metadata_manager_test extends phpbb_database_test_case $container, $this->db, $this->config, - $this->migrator, new phpbb_filesystem(), 'phpbb_ext', $this->phpbb_root_path, diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a11c0f72ca..0157706b12 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -155,7 +155,6 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - $migrator, new phpbb_filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', From 109b1a3a952f8a590f6613c8d940e6d01b755af7 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Thu, 9 May 2013 23:12:19 -0400 Subject: [PATCH 045/172] [ticket/11458] Use helper to create/move/delete directories/files PHPBB3-11458 --- .../extension_permission_lang_test.php | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 234cbbbaf2..6f1048279a 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -14,8 +14,12 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t { protected $phpbb_extension_manager; + static private $helper; + + static private $copied_files = array(); + static protected $fixtures = array( - 'foo/bar/language/en/permissions_foo.php', + 'foo/bar/language/en/', ); /** @@ -27,26 +31,21 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t global $phpbb_root_path; parent::setUpBeforeClass(); - $directories = array( - $phpbb_root_path . 'ext/foo/bar/', - $phpbb_root_path . 'ext/foo/bar/language/', - $phpbb_root_path . 'ext/foo/bar/language/en/', - ); + self::$helper = new phpbb_test_case_helpers(self); - foreach ($directories as $dir) + self::$copied_files = array(); + + if (file_exists($phpbb_root_path . 'ext/')) { - if (!is_dir($dir)) - { - mkdir($dir, 0777, true); - } + // First, move any extensions setup on the board to a temp directory + self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); + + // Then empty the ext/ directory on the board (for accurate test cases) + self::$helper->empty_dir($phpbb_root_path . 'ext/'); } - foreach (self::$fixtures as $fixture) - { - copy( - "tests/functional/fixtures/ext/$fixture", - "{$phpbb_root_path}ext/$fixture"); - } + // Copy our ext/ files from the test case to the board + self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); } /** @@ -56,16 +55,20 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static public function tearDownAfterClass() { global $phpbb_root_path; - - foreach (self::$fixtures as $fixture) + + if (file_exists($phpbb_root_path . 'store/temp_ext/')) { - unlink("{$phpbb_root_path}ext/$fixture"); + // Copy back the board installed extensions from the temp directory + self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/'); } - rmdir("{$phpbb_root_path}ext/foo/bar/language/en"); - rmdir("{$phpbb_root_path}ext/foo/bar/language"); - rmdir("{$phpbb_root_path}ext/foo/bar"); - rmdir("{$phpbb_root_path}ext/foo"); + // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext) + self::$helper->remove_files(self::$copied_files); + + if (file_exists($phpbb_root_path . 'store/temp_ext/')) + { + self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/'); + } } public function setUp() From 6a1fa3e0f40d1ce63ff8686b47bd131417d9fc04 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 10 May 2013 11:53:26 +0200 Subject: [PATCH 046/172] [ticket/11465] Add comments explaining the tests PHPBB3-11465 --- tests/extension/ext/foo/acp/fail_info.php | 5 ++++- tests/extension/ext/foo/acp/fail_module.php | 5 ++++- tests/extension/modules_test.php | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/extension/ext/foo/acp/fail_info.php b/tests/extension/ext/foo/acp/fail_info.php index 98b0eb9529..99aa09551e 100644 --- a/tests/extension/ext/foo/acp/fail_info.php +++ b/tests/extension/ext/foo/acp/fail_info.php @@ -1,5 +1,8 @@ acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( @@ -68,6 +69,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // Find mcp module info files $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( @@ -81,6 +83,7 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // Find a specific module info file (mcp_a_module) $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); $this->assertEquals(array( @@ -94,10 +97,12 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // The mcp module info file we're looking for shouldn't exist $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); $this->assertEquals(array(), $acp_modules); + // As there are no ucp modules we shouldn't find any $this->acp_modules->module_class = 'ucp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array(), $acp_modules); From a50d23078e8964396bda1e2c9cfc6e503f4f6fb9 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Fri, 10 May 2013 10:15:25 -0400 Subject: [PATCH 047/172] [ticket/11458] Use finder to get all permission language files PHPBB3-11458 --- phpBB/includes/functions_admin.php | 47 ++++++++---------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index b5efa49159..d9e445cff9 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3042,50 +3042,27 @@ function add_permission_language() { global $user, $phpEx, $phpbb_extension_manager; - // First of all, our own file. We need to include it as the first file because it presets all relevant variables. - $user->add_lang('acp/permissions_phpbb'); - - $files_to_add = array(); - - // Now search in acp and mods folder for permissions_ files. - foreach (array('acp/', 'mods/') as $path) - { - $dh = @opendir($user->lang_path . $user->lang_name . '/' . $path); - - if ($dh) - { - while (($file = readdir($dh)) !== false) - { - if ($file !== 'permissions_phpbb.' . $phpEx && strpos($file, 'permissions_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx) - { - $files_to_add[] = $path . substr($file, 0, -(strlen($phpEx) + 1)); - } - } - closedir($dh); - } - } - - // find permission language files from extensions + // add permission language files from extensions $finder = $phpbb_extension_manager->get_finder(); - $ext_lang_files = $finder + $lang_files = $finder ->prefix('permissions_') ->suffix(".$phpEx") + ->core_path('language/' . $user->lang_name . '/') ->extension_directory('/language/' . $user->lang_name) ->find(); - foreach ($ext_lang_files as $lang_file => $ext_name) + foreach ($lang_files as $lang_file => $ext_name) { - $user->add_lang_ext($ext_name, $lang_file); + if ($ext_name === '/') + { + $user->add_lang($lang_file); + } + else + { + $user->add_lang_ext($ext_name, $lang_file); + } } - - if (!sizeof($files_to_add)) - { - return false; - } - - $user->add_lang($files_to_add); - return true; } /** From c9ff3151323fd764354dad5538740baa7c9d8104 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 10 May 2013 13:40:49 -0500 Subject: [PATCH 048/172] [ticket/11413] Rename file to something more helpful PHPBB3-11413 --- .../310/{notifications2.php => notifications_schema_fix.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename phpBB/includes/db/migration/data/310/{notifications2.php => notifications_schema_fix.php} (97%) diff --git a/phpBB/includes/db/migration/data/310/notifications2.php b/phpBB/includes/db/migration/data/310/notifications_schema_fix.php similarity index 97% rename from phpBB/includes/db/migration/data/310/notifications2.php rename to phpBB/includes/db/migration/data/310/notifications_schema_fix.php index ce8343089f..27e63e10d0 100644 --- a/phpBB/includes/db/migration/data/310/notifications2.php +++ b/phpBB/includes/db/migration/data/310/notifications_schema_fix.php @@ -7,7 +7,7 @@ * */ -class phpbb_db_migration_data_310_notifications2 extends phpbb_db_migration +class phpbb_db_migration_data_310_notifications_schema_fix extends phpbb_db_migration { static public function depends_on() { From 7d66a9ad525049b8df453ba0325e3dd38fb1157a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 10 May 2013 13:42:54 -0500 Subject: [PATCH 049/172] [ticket/11413] Translate the error PHPBB3-11413 --- phpBB/includes/notification/manager.php | 2 +- phpBB/language/en/common.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index a9eb503fb8..bf437e95f0 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -873,7 +873,7 @@ class phpbb_notification_manager { if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name])) { - throw new phpbb_notification_exception('Notification type ' . $notification_type_name . ' does not exist'); + throw new phpbb_notification_exception($user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name)); } $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index c1d6ef4af3..47a77d1dee 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -424,6 +424,7 @@ $lang = array_merge($lang, array( 'NOTIFICATION_TOPIC_APPROVED' => 'Your topic "%2$s" in the forum "%3$s" was approved.', 'NOTIFICATION_TOPIC_DISAPPROVED' => 'Your topic "%1$s" was disapproved for reason: "%2$s".', 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.', + 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s', 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', From 27b2bbb8ff9efc6e06cfc5077dc939b1f1f7d0e5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 10 May 2013 13:58:55 -0500 Subject: [PATCH 050/172] [ticket/11415] Create function in finder find_from_extension PHPBB3-11415 --- phpBB/includes/extension/base.php | 15 ++------------- phpBB/includes/extension/finder.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php index 2d22658ff1..a6c9bbb5bc 100644 --- a/phpBB/includes/extension/base.php +++ b/phpBB/includes/extension/base.php @@ -125,21 +125,10 @@ class phpbb_extension_base implements phpbb_extension_interface } // Only have the finder search in this extension path directory - $extensions = array( - $this->extension_name => $this->extension_path, - ); - $finder = $this->extension_manager->get_finder(); - $migrations = array(); - $file_list = $finder + $migrations = $finder ->extension_directory('/migrations') - ->find_from_paths($extensions); - - foreach ($file_list as $file) - { - $migrations[$file['named_path']] = $file['ext_name']; - } - + ->find_from_extension($this->extension_name, $this->extension_path); $migrations = $finder->get_classes_from_files($migrations); return $migrations; diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php index 766b9e9b63..49bb2a514f 100644 --- a/phpBB/includes/extension/finder.php +++ b/phpBB/includes/extension/finder.php @@ -377,6 +377,34 @@ class phpbb_extension_finder return $files; } + + /** + * Finds all file system entries matching the configured options for one + * specific extension + * + * @param string $extension_name Name of the extension + * @param string $extension_path Relative path to the extension root directory + * @param bool $cache Whether the result should be cached + * @param bool $is_dir Directories will be returned when true, only files + * otherwise + * @return array An array of paths to found items + */ + public function find_from_extension($extension_name, $extension_path, $cache = true, $is_dir = false) + { + $extensions = array( + $extension_name => $extension_path, + ); + + $files = array(); + $file_list = $this->find_from_paths($extensions, $cache, $is_dir); + + foreach ($file_list as $file) + { + $files[$file['named_path']] = $file['ext_name']; + } + + return $files; + } /** * Finds all file system entries matching the configured options from From f91f8666fd423c3e9f74d05355c8fa3e8ece2de9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 10 May 2013 14:01:31 -0500 Subject: [PATCH 051/172] [ticket/11415] Send the extension base the finder rather than the manager PHPBB3-11415 --- phpBB/includes/extension/base.php | 15 +++++++-------- phpBB/includes/extension/manager.php | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php index a6c9bbb5bc..c4462b64d8 100644 --- a/phpBB/includes/extension/base.php +++ b/phpBB/includes/extension/base.php @@ -27,8 +27,8 @@ class phpbb_extension_base implements phpbb_extension_interface /** @var ContainerInterface */ protected $container; - /** @var phpbb_extension_manager */ - protected $extension_manager; + /** @var phpbb_extension_finder */ + protected $finder; /** @var phpbb_db_migrator */ protected $migrator; @@ -43,14 +43,14 @@ class phpbb_extension_base implements phpbb_extension_interface * Constructor * * @param ContainerInterface $container Container object - * @param phpbb_extension_manager $extension_manager + * @param phpbb_extension_finder $extension_finder * @param string $extension_name Name of this extension (from ext.manager) * @param string $extension_path Relative path to this extension */ - public function __construct(ContainerInterface $container, phpbb_extension_manager $extension_manager, phpbb_db_migrator $migrator, $extension_name, $extension_path) + public function __construct(ContainerInterface $container, phpbb_extension_finder $extension_finder, phpbb_db_migrator $migrator, $extension_name, $extension_path) { $this->container = $container; - $this->extension_manager = $extension_manager; + $this->extension_finder = $extension_finder; $this->migrator = $migrator; $this->extension_name = $extension_name; @@ -125,11 +125,10 @@ class phpbb_extension_base implements phpbb_extension_interface } // Only have the finder search in this extension path directory - $finder = $this->extension_manager->get_finder(); - $migrations = $finder + $migrations = $this->extension_finder ->extension_directory('/migrations') ->find_from_extension($this->extension_name, $this->extension_path); - $migrations = $finder->get_classes_from_files($migrations); + $migrations = $this->extension_finder->get_classes_from_files($migrations); return $migrations; } diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 799c8b2418..48b72bcdd0 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -137,11 +137,11 @@ class phpbb_extension_manager if (class_exists($extension_class_name)) { - return new $extension_class_name($this->container, $this, $migrator, $name, $this->get_extension_path($name, true)); + return new $extension_class_name($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true)); } else { - return new phpbb_extension_base($this->container, $this, $migrator, $name, $this->get_extension_path($name, true)); + return new phpbb_extension_base($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true)); } } From 48e1be58db26ba09f7421082038f1f6353a38e91 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 11 May 2013 02:38:40 -0400 Subject: [PATCH 052/172] [ticket/11458] Update functional test Show that the phpbb permission lanuage file is being included PHPBB3-11458 --- tests/functional/extension_permission_lang_test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 6f1048279a..26ec4d28a1 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -108,6 +108,11 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $form->setValues($data); $crawler = $this->client->submit($form); $this->assert_response_success(); + + // language from language/en/acp/permissions_phpbb.php + $this->assertContains('Can attach files', $crawler->filter('body')->text()); + + // language from ext/foo/bar/language/en/permissions_foo.php $this->assertContains('Can view foo', $crawler->filter('body')->text()); } } From b40c6fe46ae6e9ebdbbafd22b75d2d0ac0804e97 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 11 May 2013 23:30:44 +0300 Subject: [PATCH 053/172] [ticket/11533] Columns counter for notification settings Add columns counter template variable. It counts number of notification types + column for name + column for checkbox PHPBB3-11533 --- phpBB/includes/ucp/ucp_notifications.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php index 338c921e94..72c41776b3 100644 --- a/phpBB/includes/ucp/ucp_notifications.php +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -200,6 +200,10 @@ class ucp_notifications } } } + + $template->assign_vars(array( + strtoupper($block) . '_COLS' => sizeof($notification_methods) + 2, + )); } /** From f129fdb5597413f15a61b9a1c98b7aa07feec3c8 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 11 May 2013 23:32:23 +0300 Subject: [PATCH 054/172] [ticket/11533] Change list to table for notification settings PHPBB3-11533 --- .../prosilver/template/ucp_notifications.html | 59 ++++++++----------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html index df59c55e40..723609e460 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications.html +++ b/phpBB/styles/prosilver/template/ucp_notifications.html @@ -9,44 +9,35 @@

{TITLE_EXPLAIN}

-
    -
  • -
    -
    {L_NOTIFICATION_TYPE}
    - -
    {notification_methods.NAME}
    - -
    {L_NOTIFICATIONS}
    -
    -
  • -
-
    - - - -
  • -
    -
    - {notification_types.GROUP_NAME} -
    -
    -
  • - -
  • -
    -
    + + + + + + + + + + + + + + + + + -
    checked="checked" /> {notification_methods.NAME}
    + -
    checked="checked" /> {L_NOTIFICATIONS}
    - - - - - + + + + + +
    {L_NOTIFICATION_TYPE}{notification_methods.NAME}{L_NOTIFICATIONS}
    {notification_types.GROUP_NAME}
    {notification_types.NAME}
       {notification_types.EXPLAIN} - +
    checked="checked" /> checked="checked" />
    From 858f644c38b15f8205ac862422370d8d46ceede2 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 11 May 2013 23:32:55 +0300 Subject: [PATCH 055/172] [ticket/11533] Fix colspan and unnecessary tables Fix colspan and remove unnecessary tables in notification settings page in subsilver2. PHPBB3-11533 --- .../template/ucp_notifications.html | 246 +++++++++--------- 1 file changed, 119 insertions(+), 127 deletions(-) diff --git a/phpBB/styles/subsilver2/template/ucp_notifications.html b/phpBB/styles/subsilver2/template/ucp_notifications.html index 1a1fda4c17..d85584d20e 100644 --- a/phpBB/styles/subsilver2/template/ucp_notifications.html +++ b/phpBB/styles/subsilver2/template/ucp_notifications.html @@ -2,145 +2,137 @@
    - + +
    - + - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + +
    {TITLE}{TITLE}
    {TITLE_EXPLAIN}{TITLE_EXPLAIN}
    {L_NOTIFICATION_TYPE}{L_NOTIFICATIONS}{notification_methods.NAME}
    {L_NOTIFICATION_TYPE}{L_NOTIFICATIONS}{notification_methods.NAME}
    {notification_types.GROUP_NAME}
    - {notification_types.NAME} -
       {notification_types.EXPLAIN} -
    checked="checked" /> checked="checked" />
    {notification_types.GROUP_NAME}
    + {notification_types.NAME} +
       {notification_types.EXPLAIN} +
    checked="checked" /> checked="checked" />
    + + {S_HIDDEN_FIELDS} +    + + {S_FORM_TOKEN} +
    + + - - - - -
    - - {S_HIDDEN_FIELDS} -    - - {S_FORM_TOKEN} -
    - + +
    + - - -
    - - - - - -
    - - - - - - -
     [ {TOTAL_COUNT}
    - -
    -
    - -
    - -
    - - - + + +
    - - - + - - - - - - - - - - - - - - - - -
    {L_NOTIFICATIONS}{L_MARK_READ}
    - {notification_list.AVATAR} - - - - - - - {notification_list.FORMATTED_TITLE} -
    - » {notification_list.TIME} -
    -
    - -
    - - {S_HIDDEN_FIELDS} - - {S_FORM_TOKEN} -
    - - -
    - - - - - - -
    - - - - -
    - -
    -
    - + +
    + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + +
    +
    {L_NOTIFICATIONS}{L_MARK_READ}
    + {notification_list.AVATAR} + + + + + + + {notification_list.FORMATTED_TITLE} +
    + » {notification_list.TIME} +
    +
    + +
    + + {S_HIDDEN_FIELDS} + + {S_FORM_TOKEN} +
    +
    + + + + + + +
    + + + + +
    + +
    +
    -
    + From f17e67364dca55c9ccd8416f41547fa4097cdcd4 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 11 May 2013 23:33:40 +0300 Subject: [PATCH 056/172] [ticket/11533] Update unit tests Update notification settings functional unit test for new layout PHPBB3-11533 --- tests/functional/notification_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index ec495da602..fa6513a0ba 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -43,7 +43,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options'); $this->assert_response_success(); - $cplist = $crawler->filter('.cplist'); + $cplist = $crawler->filter('.table1'); if ($expected_status) { $this->assert_checkbox_is_checked($cplist, $checkbox_name); From 7327f9326f739f9b602fd8896e8a4731caa93ee8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 16:49:49 +0200 Subject: [PATCH 057/172] [ticket/11465] Add tests for optional arguments of get_module_infos() The possibilities of the first argument have already been covered previously. The second argument will be covered with an entry that should exist, an incorrect entry, and the default false entry that should use the previously set module class. Unfortunately, the third argument doesn't have an effect in the tests, as the mocked extension manager will not properly handle enabled/disabled extensions. PHPBB3-11465 --- tests/extension/modules_test.php | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index f0acd6f2eb..d24a3ec52f 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -97,6 +97,20 @@ class phpbb_extension_modules_test extends phpbb_test_case ), ), $acp_modules); + // Find a specific module info file (mcp_a_module) with passing the module_class + $this->acp_modules->module_class = ''; + $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); + $this->assertEquals(array( + 'phpbb_ext_foo_mcp_a_module' => array( + 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')), + ), + ), + ), $acp_modules); + // The mcp module info file we're looking for shouldn't exist $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_fail'); @@ -106,5 +120,51 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'ucp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array(), $acp_modules); + + // Get module info of specified extension module + $this->acp_modules->module_class = 'acp'; + $acp_modules = $this->acp_modules->get_module_infos('phpbb_ext_foo_acp_a_module'); + $this->assertEquals(array( + 'phpbb_ext_foo_acp_a_module' => array ( + 'filename' => 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array ( + 'config' => array ('title' => 'Config', 'auth' => '', 'cat' => array ('ACP_MODS')), + ), + ), + ), $acp_modules); + + // No specific module and module class set to an incorrect name + $acp_modules = $this->acp_modules->get_module_infos('', 'wcp', true); + $this->assertEquals(array(), $acp_modules); + + // No specific module, no module_class set in the function parameter, and an incorrect module class + $this->acp_modules->module_class = 'wcp'; + $acp_modules = $this->acp_modules->get_module_infos(); + $this->assertEquals(array(), $acp_modules); + + // No specific module, module class set to false (will default to the above acp) + // Setting $use_all_available will have no effect here as the ext manager is just mocked + $this->acp_modules->module_class = 'acp'; + $acp_modules = $this->acp_modules->get_module_infos('', false, true); + $this->assertEquals(array( + 'phpbb_ext_foo_acp_a_module' => array( + 'filename' => 'phpbb_ext_foo_acp_a_module', + 'title' => 'Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ), + 'acp_foobar' => array( + 'filename' => 'acp_foobar', + 'title' => 'ACP Foobar', + 'version' => '3.1.0-dev', + 'modes' => array( + 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), + ), + ), + ), $acp_modules); } } From f90ed6c3cb9e1b8baeb352a07b81608fa7c067b5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 22:21:16 +0200 Subject: [PATCH 058/172] [ticket/11465] Add disabled ext to allow proper testing of get_module_infos() This will now also enable us to test the $use_all_available parameter of get_module_infos(), which will not only return the module infos for enabled extensions but also those from disabled extensions. PHPBB3-11465 --- tests/extension/ext/barfoo/acp/a_info.php | 16 ++++++++++++++ tests/extension/ext/barfoo/acp/a_module.php | 5 +++++ tests/extension/ext/barfoo/ext.php | 5 +++++ tests/extension/manager_test.php | 2 +- tests/extension/modules_test.php | 24 ++++++++++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/extension/ext/barfoo/acp/a_info.php create mode 100644 tests/extension/ext/barfoo/acp/a_module.php create mode 100644 tests/extension/ext/barfoo/ext.php diff --git a/tests/extension/ext/barfoo/acp/a_info.php b/tests/extension/ext/barfoo/acp/a_info.php new file mode 100644 index 0000000000..cd7e4e574b --- /dev/null +++ b/tests/extension/ext/barfoo/acp/a_info.php @@ -0,0 +1,16 @@ + 'phpbb_ext_barfoo_acp_a_module', + 'title' => 'Barfoo', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ); + } +} diff --git a/tests/extension/ext/barfoo/acp/a_module.php b/tests/extension/ext/barfoo/acp/a_module.php new file mode 100644 index 0000000000..5bedb49645 --- /dev/null +++ b/tests/extension/ext/barfoo/acp/a_module.php @@ -0,0 +1,5 @@ +assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); + $this->assertEquals(array('bar', 'barfoo', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); } public function test_enabled() diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index d24a3ec52f..fe71747c5d 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -10,6 +10,7 @@ require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; +require_once dirname(__FILE__) . '/ext/barfoo/acp/a_info.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; class phpbb_extension_modules_test extends phpbb_test_case @@ -145,7 +146,7 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->assertEquals(array(), $acp_modules); // No specific module, module class set to false (will default to the above acp) - // Setting $use_all_available will have no effect here as the ext manager is just mocked + // Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (barfoo) $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos('', false, true); $this->assertEquals(array( @@ -165,6 +166,27 @@ class phpbb_extension_modules_test extends phpbb_test_case 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), ), + 'phpbb_ext_barfoo_acp_a_module' => array( + 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'title' => 'Barfoo', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ) + ), $acp_modules); + + // Specific module set to disabled extension + $acp_modules = $this->acp_modules->get_module_infos('phpbb_ext_barfoo_acp_a_module', 'acp', true); + $this->assertEquals(array( + 'phpbb_ext_barfoo_acp_a_module' => array( + 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'title' => 'Barfoo', + 'version' => '3.1.0-dev', + 'modes' => array( + 'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')), + ), + ) ), $acp_modules); } } From bd6cebfe3882d5df810eb1725a10cd64f5473240 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 12 May 2013 22:44:59 +0200 Subject: [PATCH 059/172] [ticket/11465] Increase count of disabled extensions to 5 in functional test The ACP function test checks the amount of disabled extensions. Due to the added disabled extension for the tests of the acp_modules method get_module_infos(), this needed to be increased from 4 to 5. PHPBB3-11465 --- tests/functional/extension_acp_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 1879cbd62c..1b406e5042 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -112,7 +112,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); $this->assertCount(1, $crawler->filter('.ext_enabled')); - $this->assertCount(4, $crawler->filter('.ext_disabled')); + $this->assertCount(5, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text()); From d680aac7c5662223f1f491b244456220450cac23 Mon Sep 17 00:00:00 2001 From: gamerchan Date: Fri, 3 May 2013 11:10:53 +0530 Subject: [PATCH 060/172] [ticket/11105] Added spaces between ; and "url=" to adhere to w3c conventions. There was no space between ; and the string "url=". But according to w3c, we should have atleast one space between them. So, added space characters accordingly. PHPBB3-11105 --- phpBB/includes/functions.php | 2 +- phpBB/install/install_convert.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 98a1dab722..cf676a3351 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2740,7 +2740,7 @@ function meta_refresh($time, $url, $disable_cd_check = false) // For XHTML compatibility we change back & to & $template->assign_vars(array( - 'META' => '') + 'META' => '') ); return $url; diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 62efc3e46b..fb97255981 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -2087,7 +2087,7 @@ class install_convert extends module // Because we should not rely on correct settings, we simply use the relative path here directly. $template->assign_vars(array( 'S_REFRESH' => true, - 'META' => '') + 'META' => '') ); } } From a4d6486d8061049f5c40e971463b171f4ee33708 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 13 May 2013 00:35:01 -0500 Subject: [PATCH 061/172] [ticket/11413] Fix unit tests PHPBB3-11413 --- tests/notification/notification_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index c342b10a7f..ff168516e3 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -96,7 +96,7 @@ class phpbb_notification_test extends phpbb_database_test_case { global $phpbb_root_path, $phpEx; - return new $type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); + return new $type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notification_types', 'phpbb_notifications', 'phpbb_user_notifications'); } public function test_get_notification_type_id() From ad430ae406fc2bfc21f35ee068b1eb809f39f963 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 13 May 2013 00:41:57 -0500 Subject: [PATCH 062/172] [ticket/11413] $user should have been $this->user PHPBB3-11413 --- phpBB/includes/notification/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index bf437e95f0..97833710c0 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -873,7 +873,7 @@ class phpbb_notification_manager { if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name])) { - throw new phpbb_notification_exception($user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name)); + throw new phpbb_notification_exception($this->user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name)); } $sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( From bae42c6f0a7872d73518b7c3a221b6e23093e0a6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 13 May 2013 00:48:27 -0500 Subject: [PATCH 063/172] [ticket/11413] Use phpbb_user in test PHPBB3-11413 --- tests/notification/notification_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index ff168516e3..8f7eb3b8a8 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -33,7 +33,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'allow_topic_notify' => true, 'allow_forum_notify' => true, )); - $this->user = new phpbb_mock_user(); + $this->user = new phpbb_user(); $this->user_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $this->auth = new phpbb_mock_notifications_auth(); $this->cache = new phpbb_cache_service( From 05cd045923068b08962856ec5e0c36f72f8f831c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 13 May 2013 00:56:08 -0500 Subject: [PATCH 064/172] [ticket/11413] Revert some cache service related changes from earlier PHPBB3-11413 --- phpBB/includes/notification/method/base.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/notification/method/base.php b/phpBB/includes/notification/method/base.php index bae85310b2..b633956d01 100644 --- a/phpBB/includes/notification/method/base.php +++ b/phpBB/includes/notification/method/base.php @@ -30,7 +30,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth /** @var phpbb_db_driver */ protected $db; - /** @var phpbb_cache_service */ + /** @var phpbb_cache_driver_interface */ protected $cache; /** @var phpbb_template */ @@ -66,7 +66,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth * * @param phpbb_user_loader $user_loader * @param phpbb_db_driver $db - * @param phpbb_cache_service $cache + * @param phpbb_cache_driver_interface $cache * @param phpbb_user $user * @param phpbb_auth $auth * @param phpbb_config $config @@ -74,7 +74,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth * @param string $php_ext * @return phpbb_notification_method_base */ - public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) + public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) { $this->user_loader = $user_loader; $this->db = $db; From 6890bf9f8d97473d55f2d6819c8ec155f9d52658 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 13 May 2013 12:17:31 +0200 Subject: [PATCH 065/172] [ticket/11535] Correctly merge avatar_errors array into primary error array The $avatar_errors array needs to be merged into the primary $error array before the group settings get applied. This is currently not the case. Functional tests for this will be provided by PR #1401. PHPBB3-11535 --- phpBB/includes/acp/acp_groups.php | 10 ++++++++-- phpBB/includes/ucp/ucp_groups.php | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 865810687b..37c49d7d72 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -381,6 +381,9 @@ class acp_groups $submit_ary['avatar_width'] = 0; $submit_ary['avatar_height'] = 0; } + + // Merge any avatar errors into the primary error array + $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); } // Validate the length of "Maximum number of allowed recipients per private message" setting. @@ -570,8 +573,11 @@ class acp_groups $avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true); - // Merge any avatar errors into the primary error array - $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); + if (!$update) + { + // Merge any avatar errors into the primary error array + $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); + } $back_link = request_var('back_link', ''); diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 50d13e00b1..a633ce448c 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -547,6 +547,9 @@ class ucp_groups $submit_ary['avatar_width'] = 0; $submit_ary['avatar_height'] = 0; } + + // Merge any avatars errors into the primary error array + $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); } if (!check_form_key('ucp_groups')) @@ -672,8 +675,11 @@ class ucp_groups } } - // Merge any avatars errors into the primary error array - $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); + if (!$update) + { + // Merge any avatars errors into the primary error array + $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error)); + } $template->assign_vars(array( 'S_EDIT' => true, From 33521310c74d934a64d453e3adfac53bd6c505be Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 14 May 2013 09:16:39 +0300 Subject: [PATCH 066/172] [ticket/11489] CSS changes for topiclist lists PHPBB3-11489 --- phpBB/styles/prosilver/theme/bidi.css | 60 ++++++++--- phpBB/styles/prosilver/theme/colours.css | 5 - phpBB/styles/prosilver/theme/content.css | 126 +++++++++++++---------- 3 files changed, 115 insertions(+), 76 deletions(-) diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index 5cff0a811b..f617428565 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -268,8 +268,45 @@ left: 0; } -.rtl ul.topiclist dt { +.rtl ul.topiclist dt, .rtl li.header dt { float: right; + margin-right: 0; + margin-left: -410px; +} + +.rtl ul.topiclist.missing-column dt { + margin-right: 0; + margin-left: -330px; +} + +.rtl ul.topiclist.two-long-columns dt { + margin-right: 0; + margin-left: -250px; +} + +.rtl ul.topiclist.two-columns dt { + margin-right: 0; + margin-left: -80px; +} + +.rtl ul.topiclist dt .list-inner { + margin-right: 0; + margin-left: 410px; +} + +.rtl ul.topiclist.missing-column dt .list-inner { + margin-right: 0; + margin-left: 330px; +} + +.rtl ul.topiclist.two-long-columns dt .list-inner { + margin-right: 0; + margin-left: 250px; +} + +.rtl ul.topiclist.two-columns dt .list-inner { + margin-right: 0; + margin-left: 80px; } .rtl ul.topiclist dl { @@ -308,33 +345,26 @@ background-position: 99.5% 50%; } -.rtl li.header dl.icon dt { +.rtl li.header dl.icon dt .list-inner { /* Tweak for headers alignment when folder icon used */ padding-right: 0; padding-left: 50px; } .rtl dl.icon dt { - padding-left: 0; - padding-right: 45px; /* Space for folder icon */ background-position: 99.5% 95%; /* Position of topic icon */ } -.rtl dd.lastpost span, .rtl ul.topiclist dd.searchby span, .rtl ul.topiclist dd.info span, .rtl ul.topiclist dd.time span, .rtl dd.redirect span, .rtl dd.moderation span { +.rtl dl.icon dt .list-inner { + padding-left: 0; + padding-right: 45px; /* Space for folder icon */ +} + +.rtl dd.lastpost span, .rtl ul.topiclist dd.info span, .rtl ul.topiclist dd.time span, .rtl dd.redirect span, .rtl dd.moderation span { padding-left: 0; padding-right: 5px; } -.rtl dd.mark { - float: left !important; -} - -.rtl ul.topiclist dd.searchextra { - margin-left: 0; - margin-right: 5px; - border-right: none; -} - /* Post body styles ----------------------------------------*/ .rtl .postbody { diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index baff88d6b7..a2fe112b45 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -406,11 +406,6 @@ li.header dt, li.header dd { color: #FFFFFF; } -/* Forum list column styles */ -ul.topiclist dd.searchextra { - color: #333333; -} - /* Post body styles ----------------------------------------*/ .postbody { diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index bf9e587ce1..6eea435017 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -25,20 +25,53 @@ ul.topiclist li.row dl { padding: 2px 0; } -ul.topiclist dt { +ul.topiclist dt, ul.topiclist dd { display: block; float: left; - width: 50%; +} + +ul.topiclist dt { + width: 100%; + margin-right: -410px; font-size: 1.1em; +} + +ul.topiclist.missing-column dt { + margin-right: -330px; +} + +ul.topiclist.two-long-columns dt { + margin-right: -250px; +} + +ul.topiclist.two-columns dt { + margin-right: -80px; +} + +ul.topiclist dt .list-inner { + margin-right: 410px; padding-left: 5px; padding-right: 5px; } +ul.topiclist.missing-column dt .list-inner { + margin-right: 330px; +} + +ul.topiclist.two-long-columns dt .list-inner { + margin-right: 250px; +} + +ul.topiclist.two-columns dt .list-inner { + margin-right: 80px; +} + ul.topiclist dd { - display: block; - float: left; border-left: 1px solid transparent; padding: 4px 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } ul.topiclist dfn { @@ -85,17 +118,26 @@ li.header dt, li.header dd { li.header dt { font-weight: bold; + width: 100%; + margin-right: -410px; +} + +li.header dt .list-inner { + margin-right: 410px; } li.header dd { - margin-left: 1px; + padding-left: 1px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } -li.header dl.icon { +li.header dl.icon dt, li.header dl.icon dd { min-height: 0; } -li.header dl.icon dt { +li.header dl.icon dt .list-inner { /* Tweak for headers alignment when folder icon used */ padding-left: 0; padding-right: 50px; @@ -103,19 +145,27 @@ li.header dl.icon dt { /* Forum list column styles */ dl.icon { - min-height: 35px; background-position: 10px 50%; /* Position of folder icon */ background-repeat: no-repeat; } dl.icon dt { - padding-left: 45px; /* Space for folder icon */ background-repeat: no-repeat; background-position: 5px 95%; /* Position of topic icon */ } -dd.posts, dd.topics, dd.views { - width: 8%; +dl.icon dt .list-inner { + padding-left: 45px; /* Space for folder icon */ +} + +dl.icon dt, dl.icon dd { + min-height: 40px; + *min-height: 32px; +} + +dd.posts, dd.topics, dd.views, dd.extra, dd.mark { + width: 80px; + *width: 79px; text-align: center; line-height: 2.2em; font-size: 1.2em; @@ -133,73 +183,37 @@ dl.icon dt li { list-style-type: inherit; } -dd.lastpost { - width: 25%; +dd.lastpost, dd.redirect, dd.moderation, dd.time, dd.info { + width: 250px; + *width: 249px; font-size: 1.1em; } dd.redirect { - font-size: 1.1em; line-height: 2.5em; } -dd.moderation { - font-size: 1.1em; +dd.time { + line-height: 200%; } -dd.lastpost span, ul.topiclist dd.searchby span, ul.topiclist dd.info span, ul.topiclist dd.time span, dd.redirect span, dd.moderation span { +dd.lastpost span, ul.topiclist dd.info span, ul.topiclist dd.time span, dd.redirect span, dd.moderation span { display: block; padding-left: 5px; } -dd.time { - width: auto; +dd.extra, dd.mark { line-height: 200%; - font-size: 1.1em; -} - -dd.extra { - width: 12%; - line-height: 200%; - text-align: center; - font-size: 1.1em; -} - -dd.mark { - float: right !important; - width: 9%; - text-align: center; - line-height: 200%; - font-size: 1.2em; -} - -dd.info { - width: 30%; } dd.option { - width: 15%; + width: 125px; + *width: 124px; line-height: 200%; text-align: center; font-size: 1.1em; } -dd.searchby { - width: 47%; - font-size: 1.1em; - line-height: 1em; -} - -ul.topiclist dd.searchextra { - margin-left: 5px; - padding: 0.2em 0; - font-size: 1.1em; - border-left: none; - clear: both; - width: 98%; - overflow: hidden; -} - /* Container for post/reply buttons and pagination */ .topic-actions { margin-bottom: 3px; From 0d8ba50b644015604b9047e439f385ecdaab87c0 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 14 May 2013 09:17:11 +0300 Subject: [PATCH 067/172] [ticket/11489] Template changes for new topiclist layout PHPBB3-11489 --- .../prosilver/template/forumlist_body.html | 30 ++++----- .../styles/prosilver/template/mcp_forum.html | 13 ++-- .../styles/prosilver/template/mcp_front.html | 38 +++++++----- .../styles/prosilver/template/mcp_queue.html | 12 ++-- .../prosilver/template/mcp_reports.html | 20 +++--- .../prosilver/template/search_results.html | 42 +++++++------ .../prosilver/template/ucp_attachments.html | 10 ++- .../prosilver/template/ucp_groups_manage.html | 14 +++-- .../template/ucp_groups_membership.html | 62 +++++++++++-------- .../template/ucp_main_bookmarks.html | 49 ++++++++------- .../prosilver/template/ucp_main_drafts.html | 18 +++--- .../prosilver/template/ucp_main_front.html | 34 +++++----- .../template/ucp_main_subscribed.html | 54 ++++++++-------- .../prosilver/template/ucp_notifications.html | 28 +++++---- .../prosilver/template/ucp_pm_viewfolder.html | 9 ++- .../prosilver/template/viewforum_body.html | 41 ++++++------ 16 files changed, 267 insertions(+), 207 deletions(-) diff --git a/phpBB/styles/prosilver/template/forumlist_body.html b/phpBB/styles/prosilver/template/forumlist_body.html index 539ed047c9..0c67de76ec 100644 --- a/phpBB/styles/prosilver/template/forumlist_body.html +++ b/phpBB/styles/prosilver/template/forumlist_body.html @@ -13,7 +13,7 @@
    • -
      {forumrow.FORUM_NAME}{L_FORUM}
      +
      {L_TOPICS}
      {L_POSTS}
      {L_LAST_POST}
      @@ -27,20 +27,22 @@
    • - +
      + - {forumrow.FORUM_IMAGE} - {forumrow.FORUM_NAME}
      - {forumrow.FORUM_DESC} - -
      {forumrow.L_MODERATOR_STR}{L_COLON} {forumrow.MODERATORS} - - -
      {forumrow.L_SUBFORUM_STR} - - {forumrow.subforum.SUBFORUM_NAME}, - - + {forumrow.FORUM_IMAGE} + {forumrow.FORUM_NAME}
      + {forumrow.FORUM_DESC} + +
      {forumrow.L_MODERATOR_STR}{L_COLON} {forumrow.MODERATORS} + + +
      {forumrow.L_SUBFORUM_STR} + + {forumrow.subforum.SUBFORUM_NAME}, + + +
      {L_REDIRECTS}{L_COLON} {forumrow.CLICKS}
      diff --git a/phpBB/styles/prosilver/template/mcp_forum.html b/phpBB/styles/prosilver/template/mcp_forum.html index e559f178f2..ac686932b7 100644 --- a/phpBB/styles/prosilver/template/mcp_forum.html +++ b/phpBB/styles/prosilver/template/mcp_forum.html @@ -24,22 +24,24 @@ -
        +
        • -
          {L_TOPICS}
          +
          {L_TOPICS}
          {L_REPLIES}
          {L_LAST_POST}
          {L_MARK}
        -
    + {topicrow.ATTACH_ICON_IMG} {L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} » {topicrow.FIRST_POST_TIME} + + +
    {topicrow.REPLIES} {L_REPLIES}
    {L_LAST_POST} {L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
    {topicrow.LAST_POST_TIME}
    diff --git a/phpBB/styles/prosilver/template/mcp_front.html b/phpBB/styles/prosilver/template/mcp_front.html index 886a4b784b..e88b7c62df 100644 --- a/phpBB/styles/prosilver/template/mcp_front.html +++ b/phpBB/styles/prosilver/template/mcp_front.html @@ -13,22 +13,24 @@

    {L_UNAPPROVED_TOTAL}

    -
      +
      • -
        {L_VIEW_DETAILS}
        +
        {L_VIEW_DETAILS}
        {L_TOPIC} & {L_FORUM}
      -
        +
        • - {unapproved.SUBJECT} {unapproved.ATTACH_ICON_IMG}
          - {L_POSTED} {L_POST_BY_AUTHOR} {unapproved.AUTHOR_FULL} » {unapproved.POST_TIME} +
          + {unapproved.SUBJECT} {unapproved.ATTACH_ICON_IMG}
          + {L_POSTED} {L_POST_BY_AUTHOR} {unapproved.AUTHOR_FULL} » {unapproved.POST_TIME} +
          {L_TOPIC}{L_COLON} {unapproved.TOPIC_TITLE} [{L_MODERATE}]
          @@ -65,22 +67,24 @@

          {L_REPORTS_TOTAL}

          -
            +
            • -
              {L_VIEW_DETAILS}
              +
              {L_VIEW_DETAILS}
              {L_REPORTER} & {L_FORUM}
            -
              +
              • - {report.SUBJECT} {report.ATTACH_ICON_IMG}
                - {L_POSTED} {L_POST_BY_AUTHOR} {report.AUTHOR_FULL} » {report.POST_TIME} +
                + {report.SUBJECT} {report.ATTACH_ICON_IMG}
                + {L_POSTED} {L_POST_BY_AUTHOR} {report.AUTHOR_FULL} » {report.POST_TIME} +
                {L_REPORTED} {L_POST_BY_AUTHOR} {report.REPORTER_FULL} {L_REPORTED_ON_DATE} {report.REPORT_TIME}
                @@ -104,23 +108,25 @@

                {L_PM_REPORTS_TOTAL}

                -
                  +
                  • -
                    {L_VIEW_DETAILS}
                    +
                    {L_VIEW_DETAILS}
                    {L_REPORTER}
                  -
                    +
                    • - {pm_report.PM_SUBJECT} {pm_report.ATTACH_ICON_IMG}
                      - {L_MESSAGE_BY_AUTHOR} {pm_report.PM_AUTHOR_FULL} » {pm_report.PM_TIME}
                      - {L_MESSAGE_TO} {pm_report.RECIPIENTS} +
                      + {pm_report.PM_SUBJECT} {pm_report.ATTACH_ICON_IMG}
                      + {L_MESSAGE_BY_AUTHOR} {pm_report.PM_AUTHOR_FULL} » {pm_report.PM_TIME}
                      + {L_MESSAGE_TO} {pm_report.RECIPIENTS} +
                      {L_REPORTED} {L_POST_BY_AUTHOR} {pm_report.REPORTER_FULL} {L_REPORTED_ON_DATE} {pm_report.REPORT_TIME} diff --git a/phpBB/styles/prosilver/template/mcp_queue.html b/phpBB/styles/prosilver/template/mcp_queue.html index 847151a01e..4d20804e66 100644 --- a/phpBB/styles/prosilver/template/mcp_queue.html +++ b/phpBB/styles/prosilver/template/mcp_queue.html @@ -26,16 +26,16 @@
                    -
                      +
                      • -
                        {L_TOPIC}{L_POST}
                        +
                        {L_TOPIC}{L_POST}
                        {L_TOPIC} & {L_FORUM}
                        {L_MARK}
                      -
                        +
                          @@ -46,8 +46,10 @@
                        • - {postrow.POST_SUBJECT} {postrow.ATTACH_ICON_IMG}
                          - {L_POSTED} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_TIME} +
                          + {postrow.POST_SUBJECT} {postrow.ATTACH_ICON_IMG}
                          + {L_POSTED} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_TIME} +
                          diff --git a/phpBB/styles/prosilver/template/mcp_reports.html b/phpBB/styles/prosilver/template/mcp_reports.html index ea9a4edd6f..9a70b4a62a 100644 --- a/phpBB/styles/prosilver/template/mcp_reports.html +++ b/phpBB/styles/prosilver/template/mcp_reports.html @@ -28,33 +28,37 @@
                        -
                          +
                          • -
                            {L_VIEW_DETAILS}
                            +
                            {L_VIEW_DETAILS}
                            {L_REPORTER} & {L_FORUM}
                            {L_MARK}
                          -
                            +
                            • - {postrow.PM_SUBJECT} {postrow.ATTACH_ICON_IMG}
                              - {L_MESSAGE_BY_AUTHOR} {postrow.PM_AUTHOR_FULL} » {postrow.PM_TIME}
                              - {L_MESSAGE_TO} {postrow.RECIPIENTS} +
                              + {postrow.PM_SUBJECT} {postrow.ATTACH_ICON_IMG}
                              + {L_MESSAGE_BY_AUTHOR} {postrow.PM_AUTHOR_FULL} » {postrow.PM_TIME}
                              + {L_MESSAGE_TO} {postrow.RECIPIENTS} +
                              {postrow.REPORTER_FULL} « {postrow.REPORT_TIME}
                              - {postrow.POST_SUBJECT} {postrow.ATTACH_ICON_IMG}
                              - {L_POSTED} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_TIME} +
                              + {postrow.POST_SUBJECT} {postrow.ATTACH_ICON_IMG}
                              + {L_POSTED} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_TIME} +
                              {postrow.REPORTER_FULL} « {postrow.REPORT_TIME}
                              diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html index 6e63a65993..34fbb4cb12 100644 --- a/phpBB/styles/prosilver/template/search_results.html +++ b/phpBB/styles/prosilver/template/search_results.html @@ -48,7 +48,7 @@
                              • -
                                {L_TOPICS}
                                +
                                {L_TOPICS}
                                {L_REPLIES}
                                {L_VIEWS}
                                {L_LAST_POST}
                                @@ -61,25 +61,29 @@
                              • style="background-image: url({T_ICONS_PATH}{searchresults.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{searchresults.TOPIC_FOLDER_IMG_ALT}"> - {NEWEST_POST_IMG} - {searchresults.TOPIC_TITLE} {searchresults.ATTACH_ICON_IMG} - {searchresults.UNAPPROVED_IMG} - {REPORTED_IMG}
                                - -
                                {searchresults.TOPIC_REPLIES}
                                {searchresults.TOPIC_VIEWS}
                                diff --git a/phpBB/styles/prosilver/template/ucp_attachments.html b/phpBB/styles/prosilver/template/ucp_attachments.html index 478b14ab86..6e1bdfdd57 100644 --- a/phpBB/styles/prosilver/template/ucp_attachments.html +++ b/phpBB/styles/prosilver/template/ucp_attachments.html @@ -24,7 +24,7 @@
                                • -
                                  {L_FILENAME}
                                  +
                                  {L_DOWNLOADS}
                                  {L_POST_TIME}
                                  {L_MARK}
                                  @@ -36,8 +36,12 @@
                                • -
                                  {attachrow.FILENAME} ({attachrow.SIZE})
                                  - {L_PM}{L_COLON} {L_TOPIC}{L_COLON} {attachrow.TOPIC_TITLE}
                                  +
                                  +
                                  + {attachrow.FILENAME} ({attachrow.SIZE})
                                  + {L_PM}{L_COLON} {L_TOPIC}{L_COLON} {attachrow.TOPIC_TITLE} +
                                  +
                                  {attachrow.DOWNLOAD_COUNT}
                                  {attachrow.POST_TIME}
                                  diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html index f6fcfa043d..0ef6faf25d 100644 --- a/phpBB/styles/prosilver/template/ucp_groups_manage.html +++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html @@ -207,21 +207,25 @@ -
                                    +
                                    • -
                                      {L_GROUP_LEADER}
                                      +
                                      {L_GROUP_LEADER}
                                      {L_OPTIONS}
                                    -
                                      +
                                      • -
                                        style="color: #{leader.GROUP_COLOUR};">{leader.GROUP_NAME} -
                                        {leader.GROUP_DESC}
                                        +
                                        + +
                                        {L_EDIT}
                                        {L_GROUP_LIST}
                                        diff --git a/phpBB/styles/prosilver/template/ucp_groups_membership.html b/phpBB/styles/prosilver/template/ucp_groups_membership.html index bf266208f2..d7df3b02c2 100644 --- a/phpBB/styles/prosilver/template/ucp_groups_membership.html +++ b/phpBB/styles/prosilver/template/ucp_groups_membership.html @@ -10,15 +10,15 @@

                                        {L_GROUPS_EXPLAIN}

                                        -
                                          +
                                          • -
                                            {L_GROUP_LEADER}
                                            +
                                            {L_GROUP_LEADER}
                                            {L_SELECT}
                                          -
                                            +
                                              @@ -26,10 +26,13 @@
                                            • -
                                              checked="checked" value="{leader.GROUP_ID}" /> - style="color:#{leader.GROUP_COLOUR}">{leader.GROUP_NAME} -
                                              {leader.GROUP_DESC} -
                                              {leader.GROUP_STATUS} +
                                              +
                                              + checked="checked" value="{leader.GROUP_ID}" /> + style="color:#{leader.GROUP_COLOUR}">{leader.GROUP_NAME} +
                                              {leader.GROUP_DESC} +
                                              {leader.GROUP_STATUS} +
                                              disabled="disabled" />
                                              @@ -39,15 +42,15 @@ -
                                                +
                                                • -
                                                  {L_GROUP_MEMBER}
                                                  +
                                                  {L_GROUP_MEMBER}
                                                  {L_SELECT}
                                                -
                                                  +
                                                    @@ -55,10 +58,13 @@
                                                  • -
                                                    checked="checked" value="{member.GROUP_ID}" /> - style="color:#{member.GROUP_COLOUR}">{member.GROUP_NAME} -
                                                    {member.GROUP_DESC} -
                                                    {member.GROUP_STATUS} +
                                                    +
                                                    + checked="checked" value="{member.GROUP_ID}" /> + style="color:#{member.GROUP_COLOUR}">{member.GROUP_NAME} +
                                                    {member.GROUP_DESC} +
                                                    {member.GROUP_STATUS} +
                                                    disabled="disabled" />
                                                    @@ -72,15 +78,15 @@
                                                    -
                                                      +
                                                      • -
                                                        {L_GROUP_PENDING}
                                                        +
                                                        {L_GROUP_PENDING}
                                                        {L_SELECT}
                                                      -
                                                        +
                                                          @@ -89,9 +95,11 @@
                                                        • - style="color:#{pending.GROUP_COLOUR}">{pending.GROUP_NAME} -
                                                          {pending.GROUP_DESC} -
                                                          {pending.GROUP_STATUS} +
                                                          + style="color:#{pending.GROUP_COLOUR}">{pending.GROUP_NAME} +
                                                          {pending.GROUP_DESC} +
                                                          {pending.GROUP_STATUS} +
                                                          disabled="disabled" />
                                                          @@ -104,15 +112,15 @@
                                                          -
                                                            +
                                                            • -
                                                              {L_GROUP_NONMEMBER}
                                                              +
                                                              {L_GROUP_NONMEMBER}
                                                              {L_SELECT}
                                                            -
                                                              +
                                                                @@ -121,9 +129,11 @@
                                                              • - style="color:#{nonmember.GROUP_COLOUR}">{nonmember.GROUP_NAME} -
                                                                {nonmember.GROUP_DESC} -
                                                                {nonmember.GROUP_STATUS} +
                                                                + style="color:#{nonmember.GROUP_COLOUR}">{nonmember.GROUP_NAME} +
                                                                {nonmember.GROUP_DESC} +
                                                                {nonmember.GROUP_STATUS} +
                                                                disabled="disabled" />
                                                                diff --git a/phpBB/styles/prosilver/template/ucp_main_bookmarks.html b/phpBB/styles/prosilver/template/ucp_main_bookmarks.html index 8707a749c1..017fadad77 100644 --- a/phpBB/styles/prosilver/template/ucp_main_bookmarks.html +++ b/phpBB/styles/prosilver/template/ucp_main_bookmarks.html @@ -14,43 +14,48 @@ -
                                                                  +
                                                                  • -
                                                                    {L_BOOKMARKS}
                                                                    +
                                                                    {L_BOOKMARKS}
                                                                    {L_LAST_POST}
                                                                    +
                                                                    {L_MARK}
                                                                  -
                                                                    +
                                                                    • -
                                                                      {L_DELETED_TOPIC}
                                                                      -
                                                                      +
                                                                      +
                                                                      {L_DELETED_TOPIC}
                                                                      +
                                                                       
                                                                      +
                                                                      style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{topicrow.TOPIC_FOLDER_IMG_ALT}"> - {NEWEST_POST_IMG} {topicrow.TOPIC_TITLE} - {topicrow.UNAPPROVED_IMG} - {REPORTED_IMG}
                                                                      - -