mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11088] Fix the database updater to correctly manipulate the modules
PHPBB3-11088
This commit is contained in:
parent
80f68c358f
commit
70aea6fd7c
2 changed files with 87 additions and 19 deletions
|
@ -2460,18 +2460,10 @@ function change_database_data(&$no_updates, $version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename styles module to Customise
|
// Rename styles module to Customise
|
||||||
$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
|
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||||
WHERE module_langname = 'ACP_STYLE_MANAGEMENT'";
|
SET module_langname = 'ACP_CAT_CUSTOMISE'
|
||||||
$result = _sql($sql, $errored, $error_ary);
|
WHERE module_langname = 'ACP_CAT_STYLES'";
|
||||||
$row = $db->sql_fetchrow($result);
|
_sql($sql, $errored, $error_ary);
|
||||||
$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',
|
|
||||||
));
|
|
||||||
|
|
||||||
// Install modules
|
// Install modules
|
||||||
$modules_to_install = array(
|
$modules_to_install = array(
|
||||||
|
@ -2510,6 +2502,15 @@ function change_database_data(&$no_updates, $version)
|
||||||
'auth' => '',
|
'auth' => '',
|
||||||
'cat' => 'UCP_PROFILE',
|
'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(
|
'extensions' => array(
|
||||||
'base' => 'acp_extensions',
|
'base' => 'acp_extensions',
|
||||||
'class' => 'acp',
|
'class' => 'acp',
|
||||||
|
@ -2521,15 +2522,46 @@ function change_database_data(&$no_updates, $version)
|
||||||
|
|
||||||
_add_modules($modules_to_install);
|
_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 . "
|
$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
|
||||||
WHERE module_basename = 'language'";
|
WHERE module_basename = 'acp_language'";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while($row = $db->sql_fetchrow($result))
|
$language_module_id = $db->sql_fetchfield('module_id');
|
||||||
{
|
|
||||||
$module_manager->move_module($row['module_id'], $styles_module_id);
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
$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'))
|
||||||
|
{
|
||||||
|
include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
|
||||||
|
}
|
||||||
|
// 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 . "
|
$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')";
|
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();
|
$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
|
// Update the auth setting for the module
|
||||||
$sql = 'UPDATE ' . MODULES_TABLE . "
|
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||||
SET module_auth = 'acl_u_chgprofileinfo'
|
SET module_auth = 'acl_u_chgprofileinfo'
|
||||||
|
|
|
@ -82,8 +82,8 @@ $lang = array_merge($lang, array(
|
||||||
|
|
||||||
'ACP_EMAIL_SETTINGS' => 'Email settings',
|
'ACP_EMAIL_SETTINGS' => 'Email settings',
|
||||||
'ACP_EXTENSION_GROUPS' => 'Manage file extension groups',
|
'ACP_EXTENSION_GROUPS' => 'Manage file extension groups',
|
||||||
|
'ACP_EXTENSION_MANAGEMENT' => 'Extension management',
|
||||||
'ACP_EXTENSIONS' => 'Extensions',
|
'ACP_EXTENSIONS' => 'Extensions',
|
||||||
'ACP_EXTENSIONS_MANAGEMENT' => 'Extension management',
|
|
||||||
|
|
||||||
|
|
||||||
'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions',
|
'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions',
|
||||||
|
|
Loading…
Add table
Reference in a new issue