diff options
Diffstat (limited to 'phpBB/install/convertors/functions_phpbb20.php')
-rw-r--r-- | phpBB/install/convertors/functions_phpbb20.php | 159 |
1 files changed, 135 insertions, 24 deletions
diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 466f57a572..817c007274 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -1,10 +1,13 @@ <?php /** * -* @package install -* @version $Id$ -* @copyright (c) 2006 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* 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. * */ @@ -14,7 +17,7 @@ if (!defined('IN_PHPBB')) } /** -* Helper functions for phpBB 2.0.x to phpBB 3.0.x conversion +* Helper functions for phpBB 2.0.x to phpBB 3.1.x conversion */ /** @@ -72,7 +75,6 @@ function phpbb_insert_forums() $prune_enabled = (int) $src_db->sql_fetchfield('config_value'); $src_db->sql_freeresult($result); - // Insert categories $sql = 'SELECT cat_id, cat_title FROM ' . $convert->src_table_prefix . 'categories @@ -90,7 +92,7 @@ function phpbb_insert_forums() $src_db->sql_query("SET NAMES 'utf8'"); } - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mssql': case 'mssql_odbc': @@ -221,7 +223,7 @@ function phpbb_insert_forums() 'forum_desc' => htmlspecialchars(phpbb_set_default_encoding($row['forum_desc']), ENT_COMPAT, 'UTF-8'), 'forum_type' => FORUM_POST, 'forum_status' => is_item_locked($row['forum_status']), - 'enable_prune' => ($prune_enabled) ? (int)$row['prune_enable'] : 0, + 'enable_prune' => ($prune_enabled) ? (int) $row['prune_enable'] : 0, 'prune_next' => (int) null_to_zero($row['prune_next']), 'prune_days' => (int) null_to_zero($row['prune_days']), 'prune_viewed' => 0, @@ -244,9 +246,12 @@ function phpbb_insert_forums() 'forum_rules_options' => 7, 'forum_rules_uid' => '', 'forum_topics_per_page' => 0, - 'forum_posts' => 0, - 'forum_topics' => 0, - 'forum_topics_real' => 0, + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0, 'forum_last_poster_id' => 0, 'forum_last_post_subject' => '', @@ -284,7 +289,7 @@ function phpbb_insert_forums() } $src_db->sql_freeresult($result); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'postgres': $db->sql_query("SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));'); @@ -458,7 +463,7 @@ function phpbb_get_birthday($birthday = '') { $birthday = (int) $birthday; - if (!$birthday || $birthday == 999999 || ((version_compare(PHP_VERSION, '5.1.0') < 0) && $birthday < 0)) + if (!$birthday || $birthday == 999999) { return ' 0- 0- 0'; } @@ -538,6 +543,15 @@ function phpbb_user_id($user_id) return (int) $user_id; } +/** +* Return correct user id value +* Everyone's id will be one higher to allow the guest/anonymous user to have a positive id as well +*/ +function phpbb_topic_replies_to_posts($num_replies) +{ + return (int) $num_replies + 1; +} + /* Copy additional table fields from old forum to new forum if user wants this (for Mod compatibility for example) function phpbb_copy_table_fields() { @@ -560,7 +574,6 @@ function phpbb_convert_authentication($mode) // What we will do is handling all 2.0.x admins as founder to replicate what is common in 2.0.x. // After conversion the main admin need to make sure he is removing permissions and the founder status if wanted. - // Grab user ids of users with user_level of ADMIN $sql = "SELECT user_id FROM {$convert->src_table_prefix}users @@ -1404,6 +1417,55 @@ function phpbb_attachment_category($cat_id) } /** +* Convert the attachment extension names +* This is only used if the Attachment MOD was installed +*/ +function phpbb_attachment_extension_group_name() +{ + global $db, $phpbb_root_path, $phpEx; + + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + $lang_file = $phpbb_root_path . 'language/' . $lang_dir . '/acp/attachments.' . $phpEx; + + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach ($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; + $db->sql_query($sql); + + $extension_groups_updated[$lang_key] = true; + } + } + $db->sql_freeresult($result); +} + +/** * Obtain list of forums in which different attachment categories can be used */ function phpbb_attachment_forum_perms($forum_permissions) @@ -1706,7 +1768,7 @@ function phpbb_create_userconv_table() global $db, $src_db, $convert, $table_prefix, $user, $lang; $map_dbms = ''; - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql': $map_dbms = 'mysql_40'; @@ -1734,7 +1796,7 @@ function phpbb_create_userconv_table() break; default: - $map_dbms = $db->sql_layer; + $map_dbms = $db->get_sql_layer(); break; } @@ -1742,13 +1804,6 @@ function phpbb_create_userconv_table() $drop_sql = 'DROP TABLE ' . USERCONV_TABLE; switch ($map_dbms) { - case 'firebird': - $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( - user_id INTEGER NOT NULL, - username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT \'\' NOT NULL COLLATE UNICODE - )'; - break; - case 'mssql': $create_sql = 'CREATE TABLE [' . USERCONV_TABLE . '] ( [user_id] [int] NOT NULL , @@ -1785,6 +1840,7 @@ function phpbb_create_userconv_table() break; case 'sqlite': + case 'sqlite3': $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' ( user_id INTEGER NOT NULL DEFAULT \'0\', username_clean varchar(255) NOT NULL DEFAULT \'\' @@ -1867,4 +1923,59 @@ function phpbb_check_username_collisions() $db->sql_query($drop_sql); } -?>
\ No newline at end of file +function phpbb_convert_timezone($timezone) +{ + global $config, $db, $phpbb_root_path, $phpEx, $table_prefix; + $timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, new \phpbb\db\tools($db), $phpbb_root_path, $phpEx, $table_prefix); + return $timezone_migration->convert_phpbb30_timezone($timezone, 0); +} + +function phpbb_add_notification_options($user_notify_pm) +{ + global $convert_row, $db; + + $user_id = phpbb_user_id($convert_row['user_id']); + if ($user_id == ANONYMOUS) + { + return; + } + + $rows = array(); + + $rows[] = array( + 'item_type' => 'post', + 'item_id' => 0, + 'user_id' => (int) $user_id, + 'notify' => 1, + 'method' => 'email', + ); + $rows[] = array( + 'item_type' => 'topic', + 'item_id' => 0, + 'user_id' => (int) $user_id, + 'notify' => 1, + 'method' => 'email', + ); + if ($user_notify_pm) + { + $rows[] = array( + 'item_type' => 'pm', + 'item_id' => 0, + 'user_id' => (int) $user_id, + 'notify' => 1, + 'method' => 'email', + ); + } + + $sql = $db->sql_multi_insert(USER_NOTIFICATIONS_TABLE, $rows); +} + +function phpbb_convert_password_hash($hash) +{ + global $phpbb_container; + + $manager = $phpbb_container->get('passwords.manager'); + $hash = $manager->hash($hash, '$H$'); + + return '$CP$' . $hash; +} |