diff options
Diffstat (limited to 'phpBB/phpbb/db/migration')
24 files changed, 914 insertions, 64 deletions
diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php new file mode 100644 index 0000000000..51475f5a05 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_14.php @@ -0,0 +1,37 @@ +<?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\v30x; + +class release_3_0_14 extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return phpbb_version_compare($this->config['version'], '3.0.14', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<'); +	} + +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v30x\release_3_0_14_rc1'); +	} + +	public function update_data() +	{ +		return array( +			array('if', array( +				phpbb_version_compare($this->config['version'], '3.0.14', '<'), +				array('config.update', array('version', '3.0.14')), +			)), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v30x/release_3_0_14_rc1.php b/phpBB/phpbb/db/migration/data/v30x/release_3_0_14_rc1.php new file mode 100644 index 0000000000..421ef06dd3 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v30x/release_3_0_14_rc1.php @@ -0,0 +1,37 @@ +<?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\v30x; + +class release_3_0_14_rc1 extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return phpbb_version_compare($this->config['version'], '3.0.14-RC1', '>=') && phpbb_version_compare($this->config['version'], '3.1.0-dev', '<'); +	} + +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v30x\release_3_0_13'); +	} + +	public function update_data() +	{ +		return array( +			array('if', array( +				phpbb_version_compare($this->config['version'], '3.0.14-RC1', '<'), +				array('config.update', array('version', '3.0.14-RC1')), +			)), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php index 0ca4f2f19c..725c57ca86 100644 --- a/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php +++ b/phpBB/phpbb/db/migration/data/v310/acp_prune_users_module.php @@ -13,7 +13,7 @@  namespace phpbb\db\migration\data\v310; -class acp_prune_users_module extends \phpbb\db\migration\migration +class acp_prune_users_module extends \phpbb\db\migration\container_aware_migration  {  	public function effectively_installed()  	{ @@ -70,12 +70,7 @@ class acp_prune_users_module extends \phpbb\db\migration\migration  		$acp_cat_users_id = (int) $this->db->sql_fetchfield('module_id');  		$this->db->sql_freeresult($result); -		if (!class_exists('\acp_modules')) -		{ -			include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); -		} -		$module_manager = new \acp_modules(); -		$module_manager->module_class = 'acp'; -		$module_manager->move_module($acp_prune_users_id, $acp_cat_users_id); +		$module_manager = $this->container->get('module.manager'); +		$module_manager->move_module($acp_prune_users_id, $acp_cat_users_id, 'acp');  	}  } diff --git a/phpBB/phpbb/db/migration/data/v310/avatars.php b/phpBB/phpbb/db/migration/data/v310/avatars.php index 2698adeed5..9b03a8fa94 100644 --- a/phpBB/phpbb/db/migration/data/v310/avatars.php +++ b/phpBB/phpbb/db/migration/data/v310/avatars.php @@ -17,7 +17,29 @@ class avatars extends \phpbb\db\migration\migration  {  	public function effectively_installed()  	{ -		return isset($this->config['allow_avatar_gravatar']); +		// Get current avatar type of guest user +		$sql = 'SELECT user_avatar_type +			FROM ' . $this->table_prefix . 'users +			WHERE user_id = ' . ANONYMOUS; +		$result = $this->db->sql_query($sql); +		$backup_type = $this->db->sql_fetchfield('user_avatar_type'); +		$this->db->sql_freeresult($result); + +		// Try to set avatar type to string +		$sql = 'UPDATE ' . $this->table_prefix . "users +			SET user_avatar_type = 'avatar.driver.upload' +			WHERE user_id = " . ANONYMOUS; +		$this->db->sql_return_on_error(true); +		$effectively_installed = $this->db->sql_query($sql); +		$this->db->sql_return_on_error(); + +		// Restore avatar type of guest user to previous state +		$sql = 'UPDATE ' . $this->table_prefix . "users +			SET user_avatar_type = '{$backup_type}' +			WHERE user_id = " . ANONYMOUS; +		$this->db->sql_query($sql); + +		return $effectively_installed !== false;  	}  	static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/v310/dev.php b/phpBB/phpbb/db/migration/data/v310/dev.php index f037191c2a..250258eea7 100644 --- a/phpBB/phpbb/db/migration/data/v310/dev.php +++ b/phpBB/phpbb/db/migration/data/v310/dev.php @@ -13,7 +13,7 @@  namespace phpbb\db\migration\data\v310; -class dev extends \phpbb\db\migration\migration +class dev extends \phpbb\db\migration\container_aware_migration  {  	public function effectively_installed()  	{ @@ -204,18 +204,13 @@ class dev extends \phpbb\db\migration\migration  		$language_management_module_id = $this->db->sql_fetchfield('module_id');  		$this->db->sql_freeresult($result); -		if (!class_exists('acp_modules')) -		{ -			include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); -		}  		// acp_modules calls adm_back_link, which is undefined at this point  		if (!function_exists('adm_back_link'))  		{  			include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext);  		} -		$module_manager = new \acp_modules(); -		$module_manager->module_class = 'acp'; -		$module_manager->move_module($language_module_id, $language_management_module_id); +		$module_manager = $this->container->get('module.manager'); +		$module_manager->move_module($language_module_id, $language_management_module_id, 'acp');  	}  	public function update_ucp_pm_basename() diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php index 918a565e06..2c7b7edf2e 100644 --- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php @@ -62,8 +62,6 @@ class style_update_p1 extends \phpbb\db\migration\migration  	public function styles_update()  	{ -		global $config; -  		// Get list of valid 3.1 styles  		$available_styles = array('prosilver'); @@ -138,7 +136,7 @@ class style_update_p1 extends \phpbb\db\migration\migration  		if (!sizeof($valid_styles))  		{  			// No valid styles: remove everything and add prosilver -			$this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); +			$this->sql_query('DELETE FROM ' . STYLES_TABLE);  			$sql_ary = array(  				'style_name'		=> 'prosilver', @@ -159,13 +157,13 @@ class style_update_p1 extends \phpbb\db\migration\migration  			$this->sql_query($sql);  			$sql = 'SELECT style_id -				FROM ' . $table . " +				FROM ' . STYLES_TABLE . "  				WHERE style_name = 'prosilver'";  			$result = $this->sql_query($sql); -			$default_style = $this->db->sql_fetchfield($result); +			$default_style = $this->db->sql_fetchfield('style_id');  			$this->db->sql_freeresult($result); -			$config->set('default_style', $default_style); +			$this->config->set('default_style', $default_style);  			$sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0';  			$this->sql_query($sql); diff --git a/phpBB/phpbb/db/migration/data/v31x/m_pm_report.php b/phpBB/phpbb/db/migration/data/v31x/m_pm_report.php new file mode 100644 index 0000000000..9b5710c639 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/m_pm_report.php @@ -0,0 +1,64 @@ +<?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\v31x; + +class m_pm_report extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v31x\v316rc1'); +	} + +	public function update_data() +	{ +		return array( +			array('permission.add', array('m_pm_report', true, 'm_report')), +			array('custom', array( +					array($this, 'update_module_auth'), +				), +			), +		); +	} + +	public function revert_data() +	{ +		return array( +			array('permission.remove', array('m_pm_report')), +			array('custom', array( +					array($this, 'revert_module_auth'), +				), +			), +		); +	} + +	public function update_module_auth() +	{ +		$sql = 'UPDATE ' . MODULES_TABLE . " +			SET module_auth = 'acl_m_pm_report' +			WHERE module_class = 'mcp' +				AND module_basename = 'mcp_pm_reports' +				AND module_auth = 'aclf_m_report'"; +		$this->db->sql_query($sql); +	} + +	public function revert_module_auth() +	{ +		$sql = 'UPDATE ' . MODULES_TABLE . " +			SET module_auth = 'aclf_m_report' +			WHERE module_class = 'mcp' +				AND module_basename = 'mcp_pm_reports' +				AND module_auth = 'acl_m_pm_report'"; +		$this->db->sql_query($sql); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v314.php b/phpBB/phpbb/db/migration/data/v31x/v314.php new file mode 100644 index 0000000000..b7793ca569 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v314.php @@ -0,0 +1,32 @@ +<?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\v31x; + +class v314 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v30x\release_3_0_14', +			'\phpbb\db\migration\data\v31x\v314rc2', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.4')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v314rc1.php b/phpBB/phpbb/db/migration/data/v31x/v314rc1.php new file mode 100644 index 0000000000..10cdbe3f9c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v314rc1.php @@ -0,0 +1,31 @@ +<?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\v31x; + +class v314rc1 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v31x\v313', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.4-RC1')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v314rc2.php b/phpBB/phpbb/db/migration/data/v31x/v314rc2.php new file mode 100644 index 0000000000..b75b7a9be8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v314rc2.php @@ -0,0 +1,32 @@ +<?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\v31x; + +class v314rc2 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v30x\release_3_0_14_rc1', +			'\phpbb\db\migration\data\v31x\v314rc1', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.4-RC2')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v315.php b/phpBB/phpbb/db/migration/data/v31x/v315.php new file mode 100644 index 0000000000..778cdf717e --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v315.php @@ -0,0 +1,31 @@ +<?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\v31x; + +class v315 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v31x\v315rc1', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.5')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v315rc1.php b/phpBB/phpbb/db/migration/data/v31x/v315rc1.php new file mode 100644 index 0000000000..4cf4472aa7 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v315rc1.php @@ -0,0 +1,31 @@ +<?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\v31x; + +class v315rc1 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v31x\v314', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.5-RC1')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v316.php b/phpBB/phpbb/db/migration/data/v31x/v316.php new file mode 100644 index 0000000000..cec113eff2 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v316.php @@ -0,0 +1,31 @@ +<?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\v31x; + +class v316 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v31x\v316rc1', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.6')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v31x/v316rc1.php b/phpBB/phpbb/db/migration/data/v31x/v316rc1.php new file mode 100644 index 0000000000..487cd05e5d --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v31x/v316rc1.php @@ -0,0 +1,31 @@ +<?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\v31x; + +class v316rc1 extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array( +			'\phpbb\db\migration\data\v31x\v315', +		); +	} + +	public function update_data() +	{ +		return array( +			array('config.update', array('version', '3.1.6-RC1')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php b/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php new file mode 100644 index 0000000000..de127e3745 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php @@ -0,0 +1,24 @@ +<?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 allowed_schemes_links extends \phpbb\db\migration\migration +{ +	public function update_data() +	{ +		return array( +			array('config.add', array('allowed_schemes_links', 'http,https,ftp')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php b/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php new file mode 100644 index 0000000000..fe30a1c1b8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/announce_global_permission.php @@ -0,0 +1,41 @@ +<?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 announce_global_permission extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		$sql = 'SELECT auth_option_id +			FROM ' . ACL_OPTIONS_TABLE . " +			WHERE auth_option = 'f_announce_global'"; +		$result = $this->db->sql_query($sql); +		$auth_option_id = $this->db->sql_fetchfield('auth_option_id'); +		$this->db->sql_freeresult($result); + +		return $auth_option_id !== false; +	} + +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\rc2'); +	} + +	public function update_data() +	{ +		return array( +			array('permission.add', array('f_announce_global', false, 'f_announce')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php b/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php new file mode 100644 index 0000000000..6ffaf18b4a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/font_awesome_update.php @@ -0,0 +1,29 @@ +<?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 font_awesome_update extends \phpbb\db\migration\migration +{ +	public function effectively_installed() +	{ +		return isset($this->config['load_font_awesome_url']); +	} + +	public function update_data() +	{ +		return array( +			array('config.add', array('load_font_awesome_url', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css')), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/icons_alt.php b/phpBB/phpbb/db/migration/data/v320/icons_alt.php new file mode 100644 index 0000000000..7071ae78db --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/icons_alt.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 icons_alt extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\dev'); +	} + +	public function update_schema() +	{ +		return array( +			'add_columns'        => array( +				$this->table_prefix . 'icons'        => array( +					'icons_alt'    => array('VCHAR', '', 'after' => 'icons_height'), +				), +			), +		); +	} + +	public function revert_schema() +	{ +		return array( +			'drop_columns'        => array( +				$this->table_prefix . 'icons'        => array( +					'icons_alt', +				), +			), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/log_post_id.php b/phpBB/phpbb/db/migration/data/v320/log_post_id.php new file mode 100644 index 0000000000..0f155d543c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/log_post_id.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 log_post_id extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\dev'); +	} + +	public function update_schema() +	{ +		return array( +			'add_columns'        => array( +				$this->table_prefix . 'log'        => array( +					'post_id'    => array('UINT', 0, 'after' => 'topic_id'), +				), +			), +		); +	} + +	public function revert_schema() +	{ +		return array( +			'drop_columns'        => array( +				$this->table_prefix . 'log'        => array( +					'post_id', +				), +			), +		); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/notifications_board.php b/phpBB/phpbb/db/migration/data/v320/notifications_board.php new file mode 100644 index 0000000000..fd9f1a2ad6 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/notifications_board.php @@ -0,0 +1,73 @@ +<?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 notifications_board extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\notifications'); +	} + +	public function update_data() +	{ +		return array( +			array('config.add', array('allow_board_notifications', 1)), +			array('custom', array(array($this, 'update_user_subscriptions'))), +			array('custom', array(array($this, 'update_module'))), +		); +	} + +	public function update_module() +	{ +		$sql = 'UPDATE ' . MODULES_TABLE . " +			SET auth = 'cfg_allow_board_notifications' +			WHERE module_basename = 'ucp_notifications' +				AND module_mode = 'notification_list'"; +		$this->sql_query($sql); +	} + +	public function update_user_subscriptions() +	{ +		$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " +			SET method = 'notification.method.board' +			WHERE method = ''"; +		$this->sql_query($sql); +	} + +	public function revert_data() +	{ +		return array( +			array('custom', array(array($this, 'revert_user_subscriptions'))), +			array('custom', array(array($this, 'revert_module'))), +		); +	} + +	public function revert_user_subscriptions() +	{ +		$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " +			SET method = '' +			WHERE method = 'notification.method.board'"; +		$this->sql_query($sql); +	} + +	public function revert_module() +	{ +		$sql = 'UPDATE ' . MODULES_TABLE . " +			SET auth = '' +			WHERE module_basename = 'ucp_notifications' +				AND module_mode = 'notification_list'"; +		$this->sql_query($sql); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php new file mode 100644 index 0000000000..59208be4dc --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/remove_outdated_media.php @@ -0,0 +1,83 @@ +<?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 remove_outdated_media extends \phpbb\db\migration\migration +{ +	protected $cat_id = array( +			ATTACHMENT_CATEGORY_WM, +			ATTACHMENT_CATEGORY_RM, +			ATTACHMENT_CATEGORY_QUICKTIME, +		); + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'change_extension_group'))), +		); +	} + +	public function change_extension_group() +	{ +		// select group ids of outdated media +		$sql = 'SELECT group_id +			FROM ' . EXTENSION_GROUPS_TABLE . ' +			WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id); +		$result = $this->db->sql_query($sql); + +		$group_ids = array(); +		while ($group_id = (int) $this->db->sql_fetchfield('group_id')) +		{ +			$group_ids[] = $group_id; +		} +		$this->db->sql_freeresult($result); + +		// nothing to do, admin has removed all the outdated media extension groups +		if (empty($group_ids)) +		{ +			return true; +		} + +		// get the group id of downloadable files +		$sql = 'SELECT group_id +			FROM ' . EXTENSION_GROUPS_TABLE . " +			WHERE group_name = 'DOWNLOADABLE_FILES'"; +		$result = $this->db->sql_query($sql); +		$download_id = (int) $this->db->sql_fetchfield('group_id'); +		$this->db->sql_freeresult($result); + +		if (empty($download_id)) +		{ +			$sql = 'UPDATE ' . EXTENSIONS_TABLE . ' +				SET group_id = 0 +				WHERE ' . $this->db->sql_in_set('group_id', $group_ids); +		} +		else +		{ +			// move outdated media extensions to downloadable files +			$sql = 'UPDATE ' . EXTENSIONS_TABLE . " +				SET group_id = $download_id" . ' +				WHERE ' . $this->db->sql_in_set('group_id', $group_ids); +		} + +		$result = $this->db->sql_query($sql); +		$this->db->sql_freeresult($result); + +		// delete the now empty, outdated media extension groups +		$sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . ' +			WHERE ' . $this->db->sql_in_set('group_id', $group_ids); +		$result = $this->db->sql_query($sql); +		$this->db->sql_freeresult($result); +	} +} diff --git a/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php b/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php new file mode 100644 index 0000000000..2898c708f8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/remove_profilefield_wlm.php @@ -0,0 +1,150 @@ +<?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 remove_profilefield_wlm extends \phpbb\db\migration\migration +{ +	static public function depends_on() +	{ +		return array('\phpbb\db\migration\data\v310\profilefield_wlm'); +	} + +	public function update_schema() +	{ +		return array( +			'drop_columns'	=> array( +				$this->table_prefix . 'profile_fields_data'			=> array( +					'pf_phpbb_wlm', +				), +			), +		); +	} + +	public function revert_schema() +	{ +		return array( +			'add_columns'	=> array( +				$this->table_prefix . 'profile_fields_data'			=> array( +					'pf_phpbb_wlm'		=> array('VCHAR', ''), +				), +			), +		); +	} + +	public function update_data() +	{ +		return array( +			array('custom', array(array($this, 'delete_custom_profile_field_data'))), +		); +	} + +	public function revert_data() +	{ +		return array( +			array('custom', array(array($this, 'create_custom_field'))), +		); +	} + +	public function delete_custom_profile_field_data() +	{ +		$field_id = $this->get_custom_profile_field_id(); + +		$sql = 'DELETE FROM ' . PROFILE_FIELDS_TABLE . ' +			WHERE field_id = ' . (int) $field_id; +		$this->db->sql_query($sql); + +		$sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . ' +			WHERE field_id = ' . (int) $field_id; +		$this->db->sql_query($sql); + +		$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . ' +			WHERE field_id = ' . (int) $field_id; +		$this->db->sql_query($sql); +	} + +	/** +	 * Get custom profile field id +	 * @return	int	custom profile filed id +	 */ +	public function get_custom_profile_field_id() +	{ +		$sql = 'SELECT field_id +			FROM ' . PROFILE_FIELDS_TABLE . " +			WHERE field_name = 'phpbb_wlm'"; +		$result = $this->db->sql_query($sql); +		$field_id = (int) $this->db->sql_fetchfield('field_id'); +		$this->db->sql_freeresult($result); + +		return $field_id; +	} + +	public function create_custom_field() +	{ +		$sql = 'SELECT MAX(field_order) as max_field_order +			FROM ' . PROFILE_FIELDS_TABLE; +		$result = $this->db->sql_query($sql); +		$max_field_order = (int) $this->db->sql_fetchfield('max_field_order'); +		$this->db->sql_freeresult($result); + +		$sql_ary = array( +			'field_name'			=> 'phpbb_wlm', +			'field_type'			=> 'profilefields.type.string', +			'field_ident'			=> 'phpbb_wlm', +			'field_length'			=> '40', +			'field_minlen'			=> '5', +			'field_maxlen'			=> '255', +			'field_novalue'			=> '', +			'field_default_value'	=> '', +			'field_validation'		=> '.*', +			'field_required'		=> 0, +			'field_show_novalue'	=> 0, +			'field_show_on_reg'		=> 0, +			'field_show_on_pm'		=> 1, +			'field_show_on_vt'		=> 1, +			'field_show_on_ml'		=> 0, +			'field_show_profile'	=> 1, +			'field_hide'			=> 0, +			'field_no_view'			=> 0, +			'field_active'			=> 1, +			'field_is_contact'		=> 1, +			'field_contact_desc'	=> '', +			'field_contact_url'		=> '', +			'field_order'			=> $max_field_order + 1, +		); + +		$sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); +		$this->db->sql_query($sql); +		$field_id = (int) $this->db->sql_nextid(); + +		$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE); + +		$sql = 'SELECT lang_id +			FROM ' . LANG_TABLE; +		$result = $this->db->sql_query($sql); +		$lang_name = 'WLM'; +		while ($lang_id = (int) $this->db->sql_fetchfield('lang_id')) +		{ +			$insert_buffer->insert(array( +				'field_id'				=> (int) $field_id, +				'lang_id'				=> (int) $lang_id, +				'lang_name'				=> $lang_name, +				'lang_explain'			=> '', +				'lang_default_value'	=> '', +			)); +		} +		$this->db->sql_freeresult($result); + +		$insert_buffer->flush(); +	} +} diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index b6f0372181..69ac71abb7 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -13,6 +13,8 @@  namespace phpbb\db\migration\tool; +use phpbb\module\exception\module_exception; +  /**  * Migration module management tool  */ @@ -27,6 +29,9 @@ class module implements \phpbb\db\migration\tool\tool_interface  	/** @var \phpbb\user */  	protected $user; +	/** @var \phpbb\module\module_manager */ +	protected $module_manager; +  	/** @var string */  	protected $phpbb_root_path; @@ -42,15 +47,17 @@ class module implements \phpbb\db\migration\tool\tool_interface  	* @param \phpbb\db\driver\driver_interface $db  	* @param \phpbb\cache\service $cache  	* @param \phpbb\user $user +	* @param \phpbb\module\module_manager	$module_manager  	* @param string $phpbb_root_path  	* @param string $php_ext  	* @param string $modules_table  	*/ -	public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, $phpbb_root_path, $php_ext, $modules_table) +	public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, \phpbb\module\module_manager $module_manager, $phpbb_root_path, $php_ext, $modules_table)  	{  		$this->db = $db;  		$this->cache = $cache;  		$this->user = $user; +		$this->module_manager = $module_manager;  		$this->phpbb_root_path = $phpbb_root_path;  		$this->php_ext = $php_ext;  		$this->modules_table = $modules_table; @@ -188,7 +195,6 @@ class module implements \phpbb\db\migration\tool\tool_interface  			$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';  			$module = $this->get_module_info($class, $basename); -			$result = '';  			foreach ($module['modes'] as $mode => $module_info)  			{  				if (!isset($data['modes']) || in_array($mode, $data['modes'])) @@ -239,13 +245,6 @@ class module implements \phpbb\db\migration\tool\tool_interface  			return;  		} -		if (!class_exists('acp_modules')) -		{ -			include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); -			$this->user->add_lang('acp/modules'); -		} -		$acp_modules = new \acp_modules(); -  		$module_data = array(  			'module_enabled'	=> (isset($data['module_enabled'])) ? $data['module_enabled'] : 1,  			'module_display'	=> (isset($data['module_display'])) ? $data['module_display'] : 1, @@ -256,16 +255,11 @@ class module implements \phpbb\db\migration\tool\tool_interface  			'module_mode'		=> (isset($data['module_mode'])) ? $data['module_mode'] : '',  			'module_auth'		=> (isset($data['module_auth'])) ? $data['module_auth'] : '',  		); -		$result = $acp_modules->update_module_data($module_data, true); -		// update_module_data can either return a string or an empty array... -		if (is_string($result)) -		{ -			// Error -			throw new \phpbb\db\migration\exception('MODULE_ERROR', $result); -		} -		else +		try  		{ +			$this->module_manager->update_module_data($module_data); +  			// 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)); @@ -318,6 +312,11 @@ class module implements \phpbb\db\migration\tool\tool_interface  				$this->db->sql_query($sql);  			}  		} +		catch (module_exception $e) +		{ +			// Error +			throw new \phpbb\db\migration\exception('MODULE_ERROR', $e->getMessage()); +		}  		// Clear the Modules Cache  		$this->cache->destroy("_modules_$class"); @@ -417,21 +416,9 @@ class module implements \phpbb\db\migration\tool\tool_interface  				$module_ids[] = (int) $module;  			} -			if (!class_exists('acp_modules')) -			{ -				include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); -				$this->user->add_lang('acp/modules'); -			} -			$acp_modules = new \acp_modules(); -			$acp_modules->module_class = $class; -  			foreach ($module_ids as $module_id)  			{ -				$result = $acp_modules->delete_module($module_id); -				if (!empty($result)) -				{ -					return; -				} +				$this->module_manager->delete_module($module_id, $class);  			}  			$this->cache->destroy("_modules_$class"); @@ -474,13 +461,7 @@ class module implements \phpbb\db\migration\tool\tool_interface  	*/  	protected function get_module_info($class, $basename)  	{ -		if (!class_exists('acp_modules')) -		{ -			include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext); -			$this->user->add_lang('acp/modules'); -		} -		$acp_modules = new \acp_modules(); -		$module = $acp_modules->get_module_infos($basename, $class, true); +		$module = $this->module_manager->get_module_infos($class, $basename, true);  		if (empty($module))  		{ diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index 1a91127d2d..ceff6d7d5a 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -425,13 +425,27 @@ class permission implements \phpbb\db\migration\tool\tool_interface  				$role_id = (int) $this->db->sql_fetchfield('auth_role_id');  				if ($role_id)  				{ -					$sql = 'SELECT role_name +					$sql = 'SELECT role_name, role_type  						FROM ' . ACL_ROLES_TABLE . '  						WHERE role_id = ' . $role_id;  					$this->db->sql_query($sql); -					$role_name = $this->db->sql_fetchfield('role_name'); - -					return $this->permission_set($role_name, $auth_option, 'role', $has_permission); +					$role_data = $this->db->sql_fetchrow(); +					$role_name = $role_data['role_name']; +					$role_type = $role_data['role_type']; + +					// Filter new auth options to match the role type: a_ | f_ | m_ | u_ +					// Set new auth options to the role only if options matching the role type were found +					$auth_option = array_filter($auth_option, +						function ($option) use ($role_type) +						{ +							return strpos($option, $role_type) === 0; +						} +					); + +					if (sizeof($auth_option)) +					{ +						return $this->permission_set($role_name, $auth_option, 'role', $has_permission); +					}  				}  				$sql = 'SELECT auth_option_id, auth_setting  | 
