From e58c6536f0407ec5f82c634c058270c4e627d03d Mon Sep 17 00:00:00 2001
From: David King <imkingdavid@gmail.com>
Date: Fri, 28 Sep 2012 18:03:35 -0400
Subject: [PATCH] [ticket/11088] Untested progress for update script

PHPBB3-11088
---
 phpBB/install/database_update.php | 55 +++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 14 deletions(-)

diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index d276cdbc57..73efa3f7f6 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -2459,6 +2459,19 @@ function change_database_data(&$no_updates, $version)
 				unset($next_legend);
 			}
 
+			// Create new Customise ACP tab
+			$module_manager = new acp_modules();
+			$module_manager->update_module_data(array(
+				'parent_id'         => 0,
+				'module_enabled'    => 1,
+				'module_display'    => 1,
+				'module_basename'   => ''.
+				'module_class'      => 'acp',
+				'module_mode'       => '',
+				'module_auth'       => '',
+				'module_langname'	=> 'ACP_CAT_CUSTOMISE',
+			));
+
 			// Install modules
 			$modules_to_install = array(
 				'position'	=> array(
@@ -2489,20 +2502,6 @@ function change_database_data(&$no_updates, $version)
 					'auth'		=> 'acl_a_styles',
 					'cat'		=> 'ACP_STYLE_MANAGEMENT',
 				),
-				'extensions'	=> array(
-					'base'		=> 'acp_extensions',
-					'class'		=> 'acp',
-					'title'		=> 'ACP_EXTENSIONS',
-					'auth'		=> 'acl_a_extensions',
-					'cat'		=> 'ACP_EXTENSION_MANAGEMENT',
-				),
-				'lang_management'	=> array(
-					'base'		=> 'acp_language',
-					'class'		=> 'acp',
-					'title'		=> 'ACL_LANGUAGE_PACKS',
-					'auth'		=> 'acl_a_language',
-					'cat'		=> 'ACL_LANGUAGE',
-				),
 				'autologin_keys'	=> array(
 					'base'		=> 'ucp_profile',
 					'class'		=> 'ucp',
@@ -2510,6 +2509,13 @@ function change_database_data(&$no_updates, $version)
 					'auth'		=> '',
 					'cat'		=> 'UCP_PROFILE',
 				),
+				'extensions'    => array(
+					'base'		=> 'acp_extensions',
+					'class'		=> 'acp',
+					'title'		=> 'ACP_EXTENSIONS',
+					'auth'		=> 'acl_a_extensions',
+					'cat'		=> 'ACP_EXTENSION_MANAGEMENT',
+				),
 			);
 
 			_add_modules($modules_to_install);
@@ -2518,6 +2524,27 @@ function change_database_data(&$no_updates, $version)
 				WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')";
 			_sql($sql, $errored, $error_ary);
 
+			// Move language management to Customise
+			// First select the current language managment module ID
+			$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
+				WHERE module_basename = 'language' OR module_langname = 'styles'";
+			$result = $db->sql_query($sql);
+			$modules_to_move = $db->sql_fetchrowset($result);
+			$db->sql_freeresult($result);
+
+			// Next, selec the ID of the new parent module
+			$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
+				WHERE module_langname = 'ACP_CAT_CUSTOMISE'";
+			$result = $db->sql_query($sql);
+			$customise_category_id = $db->sql_fetchfield('module_id');
+			$db->sql_freeresult($result);
+
+			// Now perform the move
+			foreach ($modules_to_move as $module_id)
+			{
+				$module_manager->move_module($module_id, $customise_category_id);
+			}
+
 			// Localise Global Announcements
 			$sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
 				FROM ' . TOPICS_TABLE . '