diff options
Diffstat (limited to 'phpBB/phpbb')
55 files changed, 357 insertions, 192 deletions
diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php index b7f6e60337..0508500c52 100644 --- a/phpBB/phpbb/db/driver/sqlite3.php +++ b/phpBB/phpbb/db/driver/sqlite3.php @@ -102,7 +102,7 @@ class sqlite3 extends \phpbb\db\driver\driver break; case 'rollback': - return $this->dbo->exec('ROLLBACK'); + return @$this->dbo->exec('ROLLBACK'); break; } @@ -134,9 +134,26 @@ class sqlite3 extends \phpbb\db\driver\driver if ($this->query_result === false) { + if ($this->transaction === true && strpos($query, 'INSERT') === 0) + { + $query = preg_replace('/^INSERT INTO/', 'INSERT OR ROLLBACK INTO', $query); + } + if (($this->query_result = @$this->dbo->query($query)) === false) { - $this->sql_error($query); + // Try to recover a lost database connection + if ($this->dbo && !@$this->dbo->lastErrorMsg()) + { + if ($this->sql_connect($this->server, $this->user, '', $this->dbname)) + { + $this->query_result = @$this->dbo->query($query); + } + } + + if ($this->query_result === false) + { + $this->sql_error($query); + } } if (defined('DEBUG')) @@ -213,6 +230,7 @@ class sqlite3 extends \phpbb\db\driver\driver if ($query_id === false) { + /** @var \SQLite3Result $query_id */ $query_id = $this->query_result; } @@ -221,7 +239,7 @@ class sqlite3 extends \phpbb\db\driver\driver return $cache->sql_fetchrow($query_id); } - return is_object($query_id) ? $query_id->fetchArray(SQLITE3_ASSOC) : false; + return is_object($query_id) ? @$query_id->fetchArray(SQLITE3_ASSOC) : false; } /** diff --git a/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php b/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php index de127e3745..726822bc71 100644 --- a/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php +++ b/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php @@ -15,6 +15,13 @@ namespace phpbb\db\migration\data\v320; class allowed_schemes_links extends \phpbb\db\migration\migration { + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + public function update_data() { return array( diff --git a/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php b/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php index fe30a1c1b8..7afecb884b 100644 --- a/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php +++ b/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php @@ -29,7 +29,9 @@ class announce_global_permission extends \phpbb\db\migration\migration static public function depends_on() { - return array('\phpbb\db\migration\data\v310\rc2'); + return array( + '\phpbb\db\migration\data\v320\dev', + ); } public function update_data() diff --git a/phpBB/phpbb/db/migration/data/v320/dev.php b/phpBB/phpbb/db/migration/data/v320/dev.php new file mode 100644 index 0000000000..ad2da3c1f4 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/dev.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class dev extends \phpbb\db\migration\container_aware_migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-dev', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v31x\v316', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-dev')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php b/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php index 6ffaf18b4a..817b638037 100644 --- a/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php +++ b/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php @@ -15,6 +15,13 @@ namespace phpbb\db\migration\data\v320; class font_awesome_update extends \phpbb\db\migration\migration { + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + public function effectively_installed() { return isset($this->config['load_font_awesome_url']); diff --git a/phpBB/phpbb/db/migration/data/v320/icons_alt.php b/phpBB/phpbb/db/migration/data/v320/icons_alt.php index 7071ae78db..80132e579e 100644 --- a/phpBB/phpbb/db/migration/data/v320/icons_alt.php +++ b/phpBB/phpbb/db/migration/data/v320/icons_alt.php @@ -17,7 +17,9 @@ class icons_alt extends \phpbb\db\migration\migration { static public function depends_on() { - return array('\phpbb\db\migration\data\v310\dev'); + return array( + '\phpbb\db\migration\data\v320\dev', + ); } public function update_schema() diff --git a/phpBB/phpbb/db/migration/data/v320/log_post_id.php b/phpBB/phpbb/db/migration/data/v320/log_post_id.php index 0f155d543c..ead53c8138 100644 --- a/phpBB/phpbb/db/migration/data/v320/log_post_id.php +++ b/phpBB/phpbb/db/migration/data/v320/log_post_id.php @@ -17,7 +17,9 @@ class log_post_id extends \phpbb\db\migration\migration { static public function depends_on() { - return array('\phpbb\db\migration\data\v310\dev'); + return array( + '\phpbb\db\migration\data\v320\dev', + ); } public function update_schema() diff --git a/phpBB/phpbb/db/migration/data/v320/notifications_board.php b/phpBB/phpbb/db/migration/data/v320/notifications_board.php index fd9f1a2ad6..8a76ebab58 100644 --- a/phpBB/phpbb/db/migration/data/v320/notifications_board.php +++ b/phpBB/phpbb/db/migration/data/v320/notifications_board.php @@ -17,7 +17,9 @@ class notifications_board extends \phpbb\db\migration\migration { static public function depends_on() { - return array('\phpbb\db\migration\data\v310\notifications'); + return array( + '\phpbb\db\migration\data\v320\dev', + ); } public function update_data() diff --git a/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php index 59208be4dc..c14d31f1c0 100644 --- a/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php +++ b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php @@ -21,6 +21,13 @@ class remove_outdated_media extends \phpbb\db\migration\migration ATTACHMENT_CATEGORY_QUICKTIME, ); + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + ); + } + public function update_data() { return array( diff --git a/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php b/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php index 2898c708f8..1cb9070bf9 100644 --- a/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php +++ b/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php @@ -17,7 +17,9 @@ class remove_profilefield_wlm extends \phpbb\db\migration\migration { static public function depends_on() { - return array('\phpbb\db\migration\data\v310\profilefield_wlm'); + return array( + '\phpbb\db\migration\data\v320\dev', + ); } public function update_schema() diff --git a/phpBB/phpbb/db/migration/data/v320/v320a1.php b/phpBB/phpbb/db/migration/data/v320/v320a1.php new file mode 100644 index 0000000000..d7ecb36f90 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/v320a1.php @@ -0,0 +1,44 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v320; + +class v320a1 extends \phpbb\db\migration\container_aware_migration +{ + public function effectively_installed() + { + return version_compare($this->config['version'], '3.2.0-a1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v320\dev', + '\phpbb\db\migration\data\v320\allowed_schemes_links', + '\phpbb\db\migration\data\v320\announce_global_permission', + '\phpbb\db\migration\data\v320\remove_profilefield_wlm', + '\phpbb\db\migration\data\v320\font_awesome_update', + '\phpbb\db\migration\data\v320\icons_alt', + '\phpbb\db\migration\data\v320\log_post_id', + '\phpbb\db\migration\data\v320\remove_outdated_media', + '\phpbb\db\migration\data\v320\notifications_board', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.0-dev')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 69ac71abb7..a5ed62fd65 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -262,7 +262,7 @@ class module implements \phpbb\db\migration\tool\tool_interface // Success $module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']); - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name)); + $phpbb_log->add('admin', (isset($user->data['user_id'])) ? $user->data['user_id'] : ANONYMOUS, $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name)); // Move the module if requested above/below an existing one if (isset($data['before']) && $data['before']) diff --git a/phpBB/phpbb/files/upload.php b/phpBB/phpbb/files/upload.php index e011e714e5..a9bf74094d 100644 --- a/phpBB/phpbb/files/upload.php +++ b/phpBB/phpbb/files/upload.php @@ -65,9 +65,6 @@ class upload /** @var request_interface Request class */ protected $request; - /** @var string phpBB root path */ - protected $phpbb_root_path; - /** * Init file upload class. * @@ -76,16 +73,14 @@ class upload * @param language $language Language class * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini ini_get() wrapper * @param request_interface $request Request class - * @param string $phpbb_root_path phpBB root path */ - public function __construct(filesystem_interface $filesystem, factory $factory, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path) + public function __construct(filesystem_interface $filesystem, factory $factory, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, request_interface $request) { $this->filesystem = $filesystem; $this->factory = $factory; $this->language = $language; $this->php_ini = $php_ini; $this->request = $request; - $this->phpbb_root_path = $phpbb_root_path; } /** diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index 4155440fc3..5d82d8d1ef 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); return; } diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 81ad1039f6..d76182af92 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -116,7 +116,7 @@ class install extends \phpbb\console\command\command if (!is_file($config_file)) { - $iohandler->add_error_message(array('MISSING_FILE', array($config_file))); + $iohandler->add_error_message(array('MISSING_FILE', $config_file)); return 1; } @@ -127,7 +127,7 @@ class install extends \phpbb\console\command\command } catch (ParseException $e) { - $iohandler->add_error_message('INVALID_YAML_FILE'); + $iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file)); return 1; } diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index bfa9ec6238..ed817f7396 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -197,13 +197,14 @@ class helper $this->language_cookie = $lang; } - $lang = (!empty($lang) && strpos($lang, '/')) ? $lang : null; + $lang = (!empty($lang) && strpos($lang, '/') === false) ? $lang : null; $this->render_language_select($lang); if ($lang !== null) { $this->language->set_user_language($lang, true); + $this->installer_config->set('user_language', $lang); } } diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 77e0a896bc..a41b4cd6a6 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -13,6 +13,7 @@ namespace phpbb\install; +use phpbb\cache\driver\driver_interface; use phpbb\di\ordered_service_collection; use phpbb\install\exception\installer_config_not_writable_exception; use phpbb\install\exception\jump_to_restart_point_exception; @@ -26,6 +27,11 @@ use phpbb\path_helper; class installer { /** + * @var driver_interface + */ + protected $cache; + + /** * @var config */ protected $install_config; @@ -55,11 +61,13 @@ class installer /** * Constructor * - * @param config $config Installer config handler - * @param path_helper $path_helper Path helper + * @param driver_interface $cache Cache service + * @param config $config Installer config handler + * @param path_helper $path_helper Path helper */ - public function __construct(config $config, path_helper $path_helper) + public function __construct(driver_interface $cache, config $config, path_helper $path_helper) { + $this->cache = $cache; $this->install_config = $config; $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); @@ -235,6 +243,7 @@ class installer if ($install_finished || $fail_cleanup) { $this->install_config->clean_up_config_file(); + $this->cache->purge(); } else { diff --git a/phpBB/phpbb/install/module/install_data/task/add_bots.php b/phpBB/phpbb/install/module/install_data/task/add_bots.php index b45d3808db..2ee641ff63 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_bots.php +++ b/phpBB/phpbb/install/module/install_data/task/add_bots.php @@ -197,6 +197,11 @@ class add_bots extends \phpbb\install\task_base 'user_allow_pm' => 0, ); + if (!function_exists('user_add')) + { + include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); + } + $user_id = user_add($user_row); if (!$user_id) diff --git a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php index 25da36e01d..6fb03ff73d 100644 --- a/phpBB/phpbb/install/module/install_database/task/add_config_settings.php +++ b/phpBB/phpbb/install/module/install_database/task/add_config_settings.php @@ -233,7 +233,7 @@ class add_config_settings extends \phpbb\install\task_base SET username = '" . $this->db->sql_escape($this->install_config->get('admin_name')) . "', user_password='" . $this->password_manager->hash($this->install_config->get('admin_passwd')) . "', user_ip = '" . $this->db->sql_escape($user_ip) . "', - user_lang = '" . $this->db->sql_escape($this->install_config->get('language')) . "', + user_lang = '" . $this->db->sql_escape($this->install_config->get('user_language', 'en')) . "', user_email='" . $this->db->sql_escape($this->install_config->get('board_email')) . "', user_dateformat='" . $this->db->sql_escape($this->language->lang('default_dateformat')) . "', user_email_hash = " . $this->db->sql_escape(phpbb_email_hash($this->install_config->get('board_email'))) . ", diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema.php b/phpBB/phpbb/install/module/install_database/task/create_schema.php index 7cc521eee8..cabb78787f 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema.php @@ -80,6 +80,16 @@ class create_schema extends \phpbb\install\task_base $factory = new \phpbb\db\tools\factory(); $this->db = new $dbms(); + $this->db->sql_connect( + $config->get('dbhost'), + $config->get('dbuser'), + $config->get('dbpasswd'), + $config->get('dbname'), + $config->get('dbport'), + false, + false + ); + $this->config = $config; $this->db_tools = $factory->get($this->db); $this->database_helper = $db_helper; @@ -89,9 +99,6 @@ class create_schema extends \phpbb\install\task_base $this->php_ext = $php_ext; parent::__construct(true); - - // Connect to DB - $this->db->sql_connect($config->get('dbhost'), $config->get('dbuser'), $config->get('dbpasswd'), $config->get('dbname'), $config->get('dbport'), false, false); } /** diff --git a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php index 337d401216..e0890a929c 100644 --- a/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php +++ b/phpBB/phpbb/install/module/install_filesystem/task/create_config_file.php @@ -51,6 +51,11 @@ class create_config_file extends \phpbb\install\task_base protected $php_ext; /** + * @var array + */ + protected $options; + + /** * Constructor * * @param \phpbb\filesystem\filesystem_interface $filesystem @@ -59,13 +64,15 @@ class create_config_file extends \phpbb\install\task_base * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler * @param string $phpbb_root_path * @param string $php_ext + * @param array $options */ public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\install\helper\config $install_config, \phpbb\install\helper\database $db_helper, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path, - $php_ext) + $php_ext, + $options = array()) { $this->install_config = $install_config; $this->db_helper = $db_helper; @@ -73,6 +80,11 @@ class create_config_file extends \phpbb\install\task_base $this->iohandler = $iohandler; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->options = array_merge(array( + 'debug' => false, + 'debug_container' => false, + 'environment' => null, + ), $options); parent::__construct(true); } @@ -93,7 +105,7 @@ class create_config_file extends \phpbb\install\task_base $config_written = false; } - $config_content = $this->get_config_data(); + $config_content = $this->get_config_data($this->options['debug'], $this->options['debug_container'], $this->options['environment']); if (!@fwrite($fp, $config_content)) { @@ -145,15 +157,14 @@ class create_config_file extends \phpbb\install\task_base /** * Returns the content which should be dumped to config.php * - * @param bool $debug If the debug constants should be enabled by default or not - * @param bool $debug_container If the container should be compiled on + * @param bool $debug If the debug constants should be enabled by default or not + * @param bool $debug_container If the container should be compiled on * every page load or not - * @param bool $debug_test If the DEBUG_TEST constant should be added - * NOTE: Only for use within the testing framework + * @param string $environment The environment to use * * @return string content to be written to the config file */ - protected function get_config_data($debug = false, $debug_container = false, $debug_test = false) + protected function get_config_data($debug = false, $debug_container = false, $environment = null) { $config_content = "<?php\n"; $config_content .= "// phpBB 3.2.x auto-generated configuration file\n// Do not change anything in this file!\n"; @@ -184,7 +195,7 @@ class create_config_file extends \phpbb\install\task_base $config_content .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; - if ($debug_test) + if ($environment) { $config_content .= "@define('PHPBB_ENVIRONMENT', 'test');\n"; } @@ -206,7 +217,7 @@ class create_config_file extends \phpbb\install\task_base $config_content .= "// @define('DEBUG_CONTAINER', true);\n"; } - if ($debug_test) + if ($environment === 'test') { $config_content .= "@define('DEBUG_TEST', true);\n"; diff --git a/phpBB/phpbb/install/module/install_finish/task/notify_user.php b/phpBB/phpbb/install/module/install_finish/task/notify_user.php index 0af76f6f60..5268b85a42 100644 --- a/phpBB/phpbb/install/module/install_finish/task/notify_user.php +++ b/phpBB/phpbb/install/module/install_finish/task/notify_user.php @@ -41,6 +41,11 @@ class notify_user extends \phpbb\install\task_base protected $config; /** + * @var \phpbb\language\language + */ + protected $language; + + /** * @var \phpbb\log\log_interface */ protected $log; @@ -75,6 +80,7 @@ class notify_user extends \phpbb\install\task_base $this->iohandler = $iohandler; $this->auth = $container->get('auth'); + $this->language = $container->get('language'); $this->log = $container->get('log'); $this->user = $container->get('user'); $this->phpbb_root_path = $phpbb_root_path; @@ -86,6 +92,8 @@ class notify_user extends \phpbb\install\task_base $container->get('cache.driver'), $container->get_parameter('tables.config') ); + + parent::__construct(true); } /** @@ -100,8 +108,13 @@ class notify_user extends \phpbb\install\task_base { include ($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); + // functions_messenger.php uses config to determine language paths + // Remove when able + global $config; + $config = $this->config; + $messenger = new \messenger(false); - $messenger->template('installed', $this->install_config->get('language')); + $messenger->template('installed', $this->install_config->get('user_language', 'en')); $messenger->to($this->config['board_email'], $this->install_config->get('admin_name')); $messenger->anti_abuse_headers($this->config, $this->user); $messenger->assign_vars(array( diff --git a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php index b2a4800f86..8629d9aea3 100644 --- a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php +++ b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php @@ -37,6 +37,8 @@ class populate_migrations extends \phpbb\install\task_base { $this->extension_manager = $container->get('ext.manager'); $this->migrator = $container->get('migrator'); + + parent::__construct(true); } /** diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php index 41616e995a..ac305e8ab5 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_admin_data.php @@ -70,7 +70,7 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta $admin_name = $this->io_handler->get_input('admin_name', '', true); $admin_pass1 = $this->io_handler->get_input('admin_pass1', '', true); $admin_pass2 = $this->io_handler->get_input('admin_pass2', '', true); - $board_email = $this->io_handler->get_input('board_email', ''); + $board_email = $this->io_handler->get_input('board_email', '', true); $admin_data_valid = $this->check_admin_data($admin_name, $admin_pass1, $admin_pass2, $board_email); diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php index 0726cc449c..6c54561d14 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_board_data.php @@ -76,8 +76,8 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta { // Board data $default_lang = $this->io_handler->get_input('default_lang', ''); - $board_name = $this->io_handler->get_input('board_name', ''); - $board_desc = $this->io_handler->get_input('board_description', ''); + $board_name = $this->io_handler->get_input('board_name', '', true); + $board_desc = $this->io_handler->get_input('board_description', '', true); // Check default lang $langs = $this->language_helper->get_available_languages(); @@ -116,8 +116,8 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta { if ($use_request_data) { - $board_name = $this->io_handler->get_input('board_name', ''); - $board_desc = $this->io_handler->get_input('board_description', ''); + $board_name = $this->io_handler->get_input('board_name', '', true); + $board_desc = $this->io_handler->get_input('board_description', '', true); } else { @@ -126,7 +126,7 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta } // Use language because we only check this to be valid - $default_lang = $this->install_config->get('language', ''); + $default_lang = $this->install_config->get('user_language', 'en'); $langs = $this->language_helper->get_available_languages(); $lang_options = array(); diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php index ae7526a9e3..b04b8e353f 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php @@ -116,12 +116,12 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta ), 'smtp_host' => array( 'label' => 'SMTP_SERVER', - 'description' => 'SMTP_SERVER_EXPLAIN', 'type' => 'text', 'default' => $smtp_host, ), 'smtp_auth' => array( 'label' => 'SMTP_AUTH_METHOD', + 'description' => 'SMTP_AUTH_METHOD_EXPLAIN', 'type' => 'select', 'options' => $auth_options, ), diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 2d640134a3..84ec6f73f5 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -172,7 +172,7 @@ class update extends task_base { $this->log->add( 'admin', - $this->user->data['user_id'], + (isset($this->user->data['user_id'])) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php index 1c6b9aa058..e712b8ad6a 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php @@ -100,7 +100,7 @@ class show_file_status extends task_base { $this->file_updater->create_new_file( $filename, - $this->cache->get('_file_' . md5($filename)), + base64_decode($this->cache->get('_file_' . md5($filename))), true ); } diff --git a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php index 747a86281b..fbb465cc66 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php @@ -164,20 +164,20 @@ class update_files extends task_base { case 'delete': $this->file_updater->delete_file($path); - break; + break; case 'new': $this->file_updater->create_new_file($path, $new_path . $path); - break; + break; case 'update_without_diff': $this->file_updater->update_file($path, $new_path . $path); - break; + break; case 'update_with_diff': $this->file_updater->update_file( $path, - $this->cache->get('_file_' . md5($path)), + base64_decode($this->cache->get('_file_' . md5($path))), true ); - break; + break; } // Save progress diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php index 47f055f56a..382d4db89e 100644 --- a/phpBB/phpbb/language/language.php +++ b/phpBB/phpbb/language/language.php @@ -549,6 +549,16 @@ class language } /** + * Returns the ISO code of the used language + * + * @return string The ISO code of the currently used language + */ + public function get_used_language() + { + return $this->language_fallback[0]; + } + + /** * Returns language fallback data * * @param bool $reload Whether or not to reload language files @@ -559,12 +569,12 @@ class language { $fallback_array = array(); - if ($this->user_language !== false) + if ($this->user_language) { $fallback_array[] = $this->user_language; } - if ($this->default_language !== false) + if ($this->default_language) { $fallback_array[] = $this->default_language; } diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 4be678ac91..ea1b800dc5 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -44,6 +44,9 @@ class manager /** @var \phpbb\cache\service */ protected $cache; + /** @var \phpbb\language\language */ + protected $language; + /** @var \phpbb\user */ protected $user; @@ -63,13 +66,14 @@ class manager * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher * @param \phpbb\db\driver\driver_interface $db * @param \phpbb\cache\service $cache + * @param \phpbb\language\language $language * @param \phpbb\user $user * @param string $notification_types_table * @param string $user_notifications_table * * @return \phpbb\notification\manager */ - public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, $notification_types_table, $user_notifications_table) + public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\language\language $language, \phpbb\user $user, $notification_types_table, $user_notifications_table) { $this->notification_types = $notification_types; $this->notification_methods = $notification_methods; @@ -79,6 +83,7 @@ class manager $this->phpbb_dispatcher = $phpbb_dispatcher; $this->db = $db; $this->cache = $cache; + $this->language = $language; $this->user = $user; $this->notification_types_table = $notification_types_table; @@ -111,7 +116,7 @@ class manager if (! $method instanceof \phpbb\notification\method\method_interface) { - throw new \phpbb\notification\exception($this->user->lang('NOTIFICATION_METHOD_INVALID', $method_name)); + throw new \phpbb\notification\exception($this->language->lang('NOTIFICATION_METHOD_INVALID', $method_name)); } else if ($method->is_available()) { @@ -166,7 +171,7 @@ class manager $notification_type_id = false; } - /** @var method_interface $method */ + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->mark_notifications($notification_type_id, $item_id, $user_id, $time, $mark_read); @@ -208,6 +213,7 @@ class manager $notification_type_id = $this->get_notification_type_id($notification_type_name); } + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time, $mark_read); @@ -263,8 +269,6 @@ class manager return $notified_users; } - $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($notification_type_name)->find_users_for_notification($data, $options); @@ -317,7 +321,7 @@ class manager $item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data); $user_ids = array(); - $notification_objects = $notification_methods = array(); + $notification_methods = array(); // Never send notifications to the anonymous user! unset($notify_users[ANONYMOUS]); @@ -325,6 +329,7 @@ class 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 // We remove each user which was already notified by at least one method. + /** @var method\method_interface $method */ foreach ($this->get_subscription_methods_instances() as $method) { $notified_users = $method->get_notified_users($notification_type_id, array('item_id' => $item_id)); @@ -415,6 +420,7 @@ class manager $options['item_id'] = $notification->get_item_id($data); } + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->update_notification($notification, $data, $options); @@ -443,6 +449,7 @@ class manager $notification_type_id = $this->get_notification_type_id($notification_type_name); + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->delete_notifications($notification_type_id, $item_id, $parent_id, $user_id); @@ -462,6 +469,7 @@ class manager foreach ($this->notification_types as $type_name => $data) { + /** @var type\base $type */ $type = $this->get_item_type_class($type_name); if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available()) @@ -497,6 +505,7 @@ class manager { $subscription_methods = array(); + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method_name => $method) { $subscription_methods[$method_name] = array( @@ -539,6 +548,7 @@ class manager { $subscription_methods = array(); + /** @var method\method_interface $method */ foreach ($this->get_subscription_methods_instances() as $method_name => $method) { if ($method->is_available()) @@ -768,6 +778,7 @@ class manager { $notification_type_id = $this->get_notification_type_id($notification_type_name); + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->purge_notifications($notification_type_id); @@ -805,6 +816,7 @@ class manager */ public function prune_notifications($timestamp, $only_read = true) { + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->prune_notifications($timestamp, $only_read); @@ -834,6 +846,8 @@ class manager /** * Helper to get the notifications item type class and set it up * + * @param string $notification_type_name + * @param array $data * @return type\type_interface */ public function get_item_type_class($notification_type_name, $data = array()) @@ -848,6 +862,7 @@ class manager /** * Helper to get the notifications method class and set it up * + * @param string $method_name * @return method\method_interface */ public function get_method_class($method_name) @@ -858,6 +873,7 @@ class manager /** * Helper to load objects (notification types/methods) * + * @param string $object_name * @return method\method_interface|type\type_interface */ protected function load_object($object_name) @@ -950,6 +966,8 @@ class manager $notification_type_id = $this->get_notification_type_id($notification_type_name); $notified_users = array(); + + /** @var method\method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $notified_users = $notified_users + $method->get_notified_users($notification_type_id, $options); diff --git a/phpBB/phpbb/notification/method/board.php b/phpBB/phpbb/notification/method/board.php index c45f3a8caa..931b252daa 100644 --- a/phpBB/phpbb/notification/method/board.php +++ b/phpBB/phpbb/notification/method/board.php @@ -266,6 +266,7 @@ class board extends \phpbb\notification\method\base { $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notifications_table); + /** @var \phpbb\notification\type\type_interface $notification */ foreach ($this->queue as $notification) { $data = $notification->get_insert_array(); diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php index 61119b9882..8a8e284e13 100644 --- a/phpBB/phpbb/notification/method/messenger_base.php +++ b/phpBB/phpbb/notification/method/messenger_base.php @@ -82,6 +82,7 @@ abstract class messenger_base extends \phpbb\notification\method\base $messenger = new \messenger(); // Time to go through the queue and send emails + /** @var \phpbb\notification\type\type_interface $notification */ foreach ($this->queue as $notification) { if ($notification->get_email_template() === false) diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php index b191fa62ae..9f2ae857ef 100644 --- a/phpBB/phpbb/notification/type/admin_activate_user.php +++ b/phpBB/phpbb/notification/type/admin_activate_user.php @@ -130,7 +130,7 @@ class admin_activate_user extends \phpbb\notification\type\base { $username = $this->user_loader->get_username($this->item_id, 'no_profile'); - return $this->user->lang($this->language_key, $username); + return $this->language->lang($this->language_key, $username); } /** diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 31e853d7d9..4aacb1c99e 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -24,6 +24,9 @@ abstract class base implements \phpbb\notification\type\type_interface /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** @var \phpbb\language\language */ + protected $language; + /** @var \phpbb\user */ protected $user; @@ -56,7 +59,7 @@ abstract class base implements \phpbb\notification\type\type_interface protected $notification_type_id; /** - * Indentification data + * Identification data * 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) @@ -71,19 +74,20 @@ abstract class base implements \phpbb\notification\type\type_interface private $data = array(); /** - * Notification Type Base Constructor - * - * @param \phpbb\db\driver\driver_interface $db - * @param \phpbb\user $user - * @param \phpbb\auth\auth $auth - * @param string $phpbb_root_path - * @param string $php_ext - * @param string $user_notifications_table - * @return \phpbb\notification\type\base - */ - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table) + * Notification Type Base Constructor + * + * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\language\language $language + * @param \phpbb\user $user + * @param \phpbb\auth\auth $auth + * @param string $phpbb_root_path + * @param string $php_ext + * @param string $user_notifications_table + */ + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\language\language $language, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table) { $this->db = $db; + $this->language = $language; $this->user = $user; $this->auth = $auth; @@ -192,7 +196,7 @@ abstract class base implements \phpbb\notification\type\type_interface 'notification_time' => time(), 'notification_read' => false, - 'notification_data' => array(), + 'notification_data' => array(), ), $this->data); } @@ -304,6 +308,7 @@ abstract class base implements \phpbb\notification\type\type_interface * URL to unsubscribe to this notification (fall back) * * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item + * @return false */ public function get_unsubscribe_url($method = false) { @@ -371,8 +376,11 @@ abstract class base implements \phpbb\notification\type\type_interface } /** - * Load the special items (fall back) - */ + * Load the special items (fall back) + * + * @param array $data + * @param array $notifications + */ public function load_special($data, $notifications) { return; @@ -389,10 +397,12 @@ abstract class base implements \phpbb\notification\type\type_interface } /** - * Pre create insert array function (fall back) - * - * @return array - */ + * Pre create insert array function (fall back) + * + * @param array $type_data + * @param array $notify_users + * @return array + */ public function pre_create_insert_array($type_data, $notify_users) { return array(); @@ -403,13 +413,13 @@ abstract class base implements \phpbb\notification\type\type_interface */ /** - * Find the users who want to receive notifications (helper) - * - * @param array $user_ids User IDs to check if they want to receive notifications - * (Bool False to check all users besides anonymous and bots (USER_IGNORE)) - * - * @return array - */ + * Find the users who want to receive notifications (helper) + * + * @param array|bool $user_ids User IDs to check if they want to receive notifications + * (Bool False to check all users besides anonymous and bots (USER_IGNORE)) + * @param array $options + * @return array + */ protected function check_user_notification_options($user_ids = false, $options = array()) { $options = array_merge(array( @@ -505,6 +515,8 @@ abstract class base implements \phpbb\notification\type\type_interface { $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read); } + + return null; } /** diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php index 21338bddb7..2d908eb254 100644 --- a/phpBB/phpbb/notification/type/disapprove_post.php +++ b/phpBB/phpbb/notification/type/disapprove_post.php @@ -73,7 +73,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post */ public function get_title() { - return $this->user->lang($this->language_key); + return $this->language->lang($this->language_key); } /** @@ -83,7 +83,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('topic_title')) ); @@ -96,7 +96,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post */ public function get_reason() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', $this->get_data('disapprove_reason') ); diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php index 30a23a83fe..c2522fb562 100644 --- a/phpBB/phpbb/notification/type/disapprove_topic.php +++ b/phpBB/phpbb/notification/type/disapprove_topic.php @@ -73,7 +73,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic */ public function get_title() { - return $this->user->lang($this->language_key); + return $this->language->lang($this->language_key); } /** @@ -83,7 +83,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('topic_title')) ); @@ -96,7 +96,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic */ public function get_reason() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', $this->get_data('disapprove_reason') ); diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php index 8a0027bfec..28a9e73bf9 100644 --- a/phpBB/phpbb/notification/type/group_request.php +++ b/phpBB/phpbb/notification/type/group_request.php @@ -114,7 +114,7 @@ class group_request extends \phpbb\notification\type\base { $username = $this->user_loader->get_username($this->item_id, 'no_profile'); - return $this->user->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name')); + return $this->language->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name')); } /** diff --git a/phpBB/phpbb/notification/type/group_request_approved.php b/phpBB/phpbb/notification/type/group_request_approved.php index dc353f3380..f55d28bafd 100644 --- a/phpBB/phpbb/notification/type/group_request_approved.php +++ b/phpBB/phpbb/notification/type/group_request_approved.php @@ -69,7 +69,7 @@ class group_request_approved extends \phpbb\notification\type\base */ public function get_title() { - return $this->user->lang('NOTIFICATION_GROUP_REQUEST_APPROVED', $this->get_data('group_name')); + return $this->language->lang('NOTIFICATION_GROUP_REQUEST_APPROVED', $this->get_data('group_name')); } /** diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php index 2de2dcfa0b..8fb9172911 100644 --- a/phpBB/phpbb/notification/type/pm.php +++ b/phpBB/phpbb/notification/type/pm.php @@ -128,7 +128,7 @@ class pm extends \phpbb\notification\type\base { $username = $this->user_loader->get_username($this->get_data('from_user_id'), 'no_profile'); - return $this->user->lang('NOTIFICATION_PM', $username); + return $this->language->lang('NOTIFICATION_PM', $username); } /** @@ -138,7 +138,7 @@ class pm extends \phpbb\notification\type\base */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', $this->get_data('message_subject') ); diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index b16014ff74..b9afc6d70a 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -83,6 +83,7 @@ class post extends \phpbb\notification\type\base * Get the id of the item * * @param array $post The data from the post + * @return int The post id */ static public function get_item_id($post) { @@ -93,6 +94,7 @@ class post extends \phpbb\notification\type\base * Get the id of the parent * * @param array $post The data from the post + * @return int The topic id */ static public function get_item_parent_id($post) { @@ -218,14 +220,14 @@ class post extends \phpbb\notification\type\base if ($trimmed_responders_cnt > 20) { - $usernames[] = $this->user->lang('NOTIFICATION_MANY_OTHERS'); + $usernames[] = $this->language->lang('NOTIFICATION_MANY_OTHERS'); } else if ($trimmed_responders_cnt) { - $usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); + $usernames[] = $this->language->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); } - return $this->user->lang( + return $this->language->lang( $this->language_key, phpbb_generate_string_list($usernames, $this->user), $responders_cnt @@ -239,7 +241,7 @@ class post extends \phpbb\notification\type\base */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('topic_title')) ); @@ -407,6 +409,7 @@ class post extends \phpbb\notification\type\base * Add responders to the notification * * @param mixed $post + * @return array Array of responder data */ public function add_responders($post) { diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index 2edf37efc7..684463c8c3 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -106,6 +106,7 @@ class quote extends \phpbb\notification\type\post * Update a notification * * @param array $post Data specific for this type that will be updated + * @return true */ public function update_notifications($post) { diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php index 4be4705d05..6091919769 100644 --- a/phpBB/phpbb/notification/type/report_pm.php +++ b/phpBB/phpbb/notification/type/report_pm.php @@ -70,6 +70,7 @@ class report_pm extends \phpbb\notification\type\pm * Get the id of the parent * * @param array $pm The data from the pm + * @return int The report id */ static public function get_item_parent_id($pm) { @@ -144,10 +145,10 @@ class report_pm extends \phpbb\notification\type\pm $user_data = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); return array( - 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), - 'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))), + 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), + 'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))), - 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details", + 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details", ); } @@ -168,11 +169,11 @@ class report_pm extends \phpbb\notification\type\pm */ public function get_title() { - $this->user->add_lang('mcp'); + $this->language->add_lang('mcp'); $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); - return $this->user->lang( + return $this->language->lang( $this->language_key, $username ); @@ -185,7 +186,7 @@ class report_pm extends \phpbb\notification\type\pm */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('message_subject')) ); @@ -200,21 +201,21 @@ class report_pm extends \phpbb\notification\type\pm { if ($this->get_data('report_text')) { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', $this->get_data('report_text') ); } - if (isset($this->user->lang[$this->get_data('reason_title')])) + if ($this->language->is_set($this->get_data('reason_title'))) { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', - $this->user->lang[$this->get_data('reason_title')] + $this->language->lang($this->get_data('reason_title')) ); } - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', $this->get_data('reason_description') ); diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index f793c7df9a..5e98eb5feb 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -106,7 +106,7 @@ class report_pm_closed extends \phpbb\notification\type\pm { $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile'); - return $this->user->lang( + return $this->language->lang( $this->language_key, $username ); @@ -119,7 +119,7 @@ class report_pm_closed extends \phpbb\notification\type\pm */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('message_subject')) ); diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index 6eefd53832..84a5241417 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -139,11 +139,11 @@ class report_post extends \phpbb\notification\type\post_in_queue */ public function get_title() { - $this->user->add_lang('mcp'); + $this->language->add_lang('mcp'); $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); - return $this->user->lang( + return $this->language->lang( $this->language_key, $username ); @@ -156,7 +156,7 @@ class report_post extends \phpbb\notification\type\post_in_queue */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('post_subject')) ); @@ -171,21 +171,21 @@ class report_post extends \phpbb\notification\type\post_in_queue { if ($this->get_data('report_text')) { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', $this->get_data('report_text') ); } - if (isset($this->user->lang[$this->get_data('reason_title')])) + if ($this->language->is_set($this->get_data('reason_title'))) { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', - $this->user->lang[$this->get_data('reason_title')] + $this->language->lang($this->get_data('reason_title')) ); } - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REASON', $this->get_data('reason_description') ); diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index 6327011f2d..165034d57e 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -113,7 +113,7 @@ class report_post_closed extends \phpbb\notification\type\post { $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile'); - return $this->user->lang( + return $this->language->lang( $this->language_key, $username ); @@ -126,7 +126,7 @@ class report_post_closed extends \phpbb\notification\type\post */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('post_subject')) ); diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 4812e8b5af..671c34fe96 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -83,6 +83,7 @@ class topic extends \phpbb\notification\type\base * Get the id of the item * * @param array $post The data from the post + * @return int The topic id */ static public function get_item_id($post) { @@ -93,6 +94,7 @@ class topic extends \phpbb\notification\type\base * Get the id of the parent * * @param array $post The data from the post + * @return int The forum id */ static public function get_item_parent_id($post) { @@ -154,7 +156,7 @@ class topic extends \phpbb\notification\type\base $username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile'); } - return $this->user->lang( + return $this->language->lang( $this->language_key, $username ); @@ -167,7 +169,7 @@ class topic extends \phpbb\notification\type\base */ public function get_reference() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_REFERENCE', censor_text($this->get_data('topic_title')) ); @@ -180,7 +182,7 @@ class topic extends \phpbb\notification\type\base */ public function get_forum() { - return $this->user->lang( + return $this->language->lang( 'NOTIFICATION_FORUM', $this->get_data('forum_name') ); diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php index 0302dc3082..b0f5a42452 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_description.php +++ b/phpBB/phpbb/textreparser/plugins/forum_description.php @@ -27,12 +27,4 @@ class forum_description extends \phpbb\textreparser\row_based_plugin 'options' => 'forum_desc_options', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return FORUMS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php index ce550225f2..d131d00707 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_rules.php +++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php @@ -27,12 +27,4 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin 'options' => 'forum_rules_options', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return FORUMS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php index 3346ccf25e..2c45c00474 100644 --- a/phpBB/phpbb/textreparser/plugins/group_description.php +++ b/phpBB/phpbb/textreparser/plugins/group_description.php @@ -27,12 +27,4 @@ class group_description extends \phpbb\textreparser\row_based_plugin 'options' => 'group_desc_options', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return GROUPS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/pm_text.php b/phpBB/phpbb/textreparser/plugins/pm_text.php index 4d06a2878b..867da624ee 100644 --- a/phpBB/phpbb/textreparser/plugins/pm_text.php +++ b/phpBB/phpbb/textreparser/plugins/pm_text.php @@ -29,12 +29,4 @@ class pm_text extends \phpbb\textreparser\row_based_plugin 'bbcode_uid' => 'bbcode_uid', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return PRIVMSGS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index 038ae0c366..76d30655c9 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -39,12 +39,4 @@ class poll_title extends \phpbb\textreparser\row_based_plugin return $sql; } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return TOPICS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/post_text.php b/phpBB/phpbb/textreparser/plugins/post_text.php index 4a07c98cea..1c98e86067 100644 --- a/phpBB/phpbb/textreparser/plugins/post_text.php +++ b/phpBB/phpbb/textreparser/plugins/post_text.php @@ -29,12 +29,4 @@ class post_text extends \phpbb\textreparser\row_based_plugin 'bbcode_uid' => 'bbcode_uid', ); } - - /** - * {@inheritdoc} - */ - public function get_table_name() - { - return POSTS_TABLE; - } } diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index f657a45d38..647d3a7b14 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -55,14 +55,6 @@ class user_signature extends \phpbb\textreparser\row_based_plugin } /** - * {@inheritdoc} - */ - public function get_table_name() - { - return USERS_TABLE; - } - - /** * Save the keyoptions var from \phpbb\user */ protected function save_keyoptions() diff --git a/phpBB/phpbb/textreparser/row_based_plugin.php b/phpBB/phpbb/textreparser/row_based_plugin.php index d3ca334591..2d32104493 100644 --- a/phpBB/phpbb/textreparser/row_based_plugin.php +++ b/phpBB/phpbb/textreparser/row_based_plugin.php @@ -21,13 +21,20 @@ abstract class row_based_plugin extends base protected $db; /** + * @var string + */ + protected $table; + + /** * Constructor * * @param \phpbb\db\driver\driver_interface $db Database connection + * @param string $table */ - public function __construct(\phpbb\db\driver\driver_interface $db) + public function __construct(\phpbb\db\driver\driver_interface $db, $table) { $this->db = $db; + $this->table = $table; } /** @@ -38,20 +45,13 @@ abstract class row_based_plugin extends base abstract public function get_columns(); /** - * Return the name of the table used by this plugin - * - * @return string - */ - abstract public function get_table_name(); - - /** * {@inheritdoc} */ public function get_max_id() { $columns = $this->get_columns(); - $sql = 'SELECT MAX(' . $columns['id'] . ') AS max_id FROM ' . $this->get_table_name(); + $sql = 'SELECT MAX(' . $columns['id'] . ') AS max_id FROM ' . $this->table; $result = $this->db->sql_query($sql); $max_id = (int) $this->db->sql_fetchfield('max_id'); $this->db->sql_freeresult($result); @@ -96,7 +96,7 @@ abstract class row_based_plugin extends base } $sql = 'SELECT ' . implode(', ', $fields) . ' - FROM ' . $this->get_table_name() . ' + FROM ' . $this->table . ' WHERE ' . $columns['id'] . ' BETWEEN ' . $min_id . ' AND ' . $max_id; return $sql; @@ -109,7 +109,7 @@ abstract class row_based_plugin extends base { $columns = $this->get_columns(); - $sql = 'UPDATE ' . $this->get_table_name() . ' + $sql = 'UPDATE ' . $this->table . ' SET ' . $columns['text'] . " = '" . $this->db->sql_escape($record['text']) . "' WHERE " . $columns['id'] . ' = ' . $record['id']; $this->db->sql_query($sql); |