diff options
author | David King <imkingdavid@gmail.com> | 2012-12-12 12:48:27 -0500 |
---|---|---|
committer | David King <imkingdavid@gmail.com> | 2012-12-12 12:48:27 -0500 |
commit | 70aea6fd7c1af79774d800eaafe11c5381e3ff32 (patch) | |
tree | a7977007a66c4bfbaee7443a05978e4324de3d71 /phpBB/install/database_update.php | |
parent | 80f68c358ff9e01d5cf4327c5c0d748e6e6de448 (diff) | |
download | forums-70aea6fd7c1af79774d800eaafe11c5381e3ff32.tar forums-70aea6fd7c1af79774d800eaafe11c5381e3ff32.tar.gz forums-70aea6fd7c1af79774d800eaafe11c5381e3ff32.tar.bz2 forums-70aea6fd7c1af79774d800eaafe11c5381e3ff32.tar.xz forums-70aea6fd7c1af79774d800eaafe11c5381e3ff32.zip |
[ticket/11088] Fix the database updater to correctly manipulate the modules
PHPBB3-11088
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r-- | phpBB/install/database_update.php | 102 |
1 files changed, 85 insertions, 17 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 47983676cc..afc816845d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2460,18 +2460,10 @@ function change_database_data(&$no_updates, $version) } // Rename styles module to Customise - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_STYLE_MANAGEMENT'"; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $styles_module_id = (int) $row['module_id']; - $db->sql_freeresult($result); - - $module_manager = new acp_modules(); - $module_manager->update_module_data(array( - 'module_id' => $styles_module_id, - 'module_langname' => 'ACP_CAT_CUSTOMISE', - )); + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + _sql($sql, $errored, $error_ary); // Install modules $modules_to_install = array( @@ -2510,6 +2502,15 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + // To add a category, the mode and basename must be empty + // The mode is taken from the this array key + '' => array( + 'base' => '', + 'class' => 'acp', + 'title' => 'ACP_EXTENSION_MANAGEMENT', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_CAT_CUSTOMISE', + ), 'extensions' => array( 'base' => 'acp_extensions', 'class' => 'acp', @@ -2521,15 +2522,46 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); - // Move language management to Customise + // We need a separate array for the new language sub heading + // because it requires another empty key + $modules_to_install = array( + '' => array( + 'base' => '', + 'class' => 'acp', + 'title' => 'ACP_LANGUAGE', + 'auth' => 'acl_a_language', + 'cat' => 'ACP_CAT_CUSTOMISE', + ), + ); + + _add_modules($modules_to_install); + + // Move language management to new location in the Customise tab + // First get language module id $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; + WHERE module_basename = 'acp_language'"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + $language_module_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $db->sql_query($sql); + $language_management_module_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + if (!class_exists('acp_modules')) { - $module_manager->move_module($row['module_id'], $styles_module_id); + include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); } - $db->sql_freeresult($result); + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($phpbb_root_path . 'includes/functions_acp.' . $phpEx); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); $sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; @@ -2861,6 +2893,42 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_clear_prefetch(); } + // Add acl_a_extensions + if (empty($auth_admin->acl_options['id']['a_extensions'])) + { + $auth_admin->acl_add_option(array('global' => array('a_extensions'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['a_']; + $new_id = $auth_admin->acl_options['id']['a_extensions']; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + // Remove any old permission entries + $auth_admin->acl_clear_prefetch(); + } + // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_u_chgprofileinfo' |