1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

Merge branch 'develop' of github.com:marc1706/phpbb3 into feature/avatars

This commit is contained in:
Marc Alexander
2012-12-24 14:34:10 +01:00
144 changed files with 4213 additions and 2301 deletions

View File

@@ -24,6 +24,8 @@ if (!defined('IN_PHPBB'))
include($phpbb_root_path . 'config.' . $phpEx);
unset($dbpasswd);
$dbms = phpbb_convert_30_dbms_to_31($dbms);
/**
* $convertor_data provides some basic information about this convertor which is
* used on the initial list of convertors and to populate the default settings

View File

@@ -83,7 +83,6 @@ phpbb_require_updated('includes/functions_content.' . $phpEx, true);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
phpbb_require_updated('includes/db/db_tools.' . $phpEx);
@@ -818,6 +817,70 @@ function _add_modules($modules_to_install)
$_module->remove_cache_file();
}
/**
* Add a new permission, optionally copy permission setting from another
*
* @param auth_admin $auth_admin auth_admin object
* @param phpbb_db_driver $db Database object
* @param string $permission_name Name of the permission to add
* @param bool $is_global True is global, false is local
* @param string $copy_from Optional permission name from which to copy
* @return bool true on success, false on failure
*/
function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permission_name, $is_global = true, $copy_from = '')
{
// Only add a permission that don't already exist
if (!empty($auth_admin->acl_options['id'][$permission_name]))
{
return true;
}
$permission_scope = $is_global ? 'global' : 'local';
$result = $auth_admin->acl_add_option(array(
$permission_scope => array($permission_name),
));
if (!$result)
{
return $result;
}
// The permission has been added, now we can copy it if needed
if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from]))
{
$old_id = $auth_admin->acl_options['id'][$copy_from];
$new_id = $auth_admin->acl_options['id'][$permission_name];
$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);
}
}
$auth_admin->acl_clear_prefetch();
}
return true;
}
/****************************************************************************
* ADD YOUR DATABASE SCHEMA CHANGES HERE *
*****************************************************************************/
@@ -1149,7 +1212,7 @@ function database_update_info()
*****************************************************************************/
function change_database_data(&$no_updates, $version)
{
global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx, $db_tools;
global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx;
$update_helpers = new phpbb_update_helpers();
@@ -1466,8 +1529,6 @@ function change_database_data(&$no_updates, $version)
),
);
global $db_tools;
$statements = $db_tools->perform_schema_changes($changes);
foreach ($statements as $sql)
@@ -2109,26 +2170,41 @@ function change_database_data(&$no_updates, $version)
}
$db->sql_freeresult($result);
global $db_tools, $table_prefix;
// Recover from potentially broken Q&A CAPTCHA table on firebird
// Q&A CAPTCHA was uninstallable, so it's safe to remove these
// without data loss
/*
* Due to a bug, vanilla phpbb could not create captcha tables
* in 3.0.8 on firebird. It was possible for board administrators
* to adjust the code to work. If code was manually adjusted by
* board administrators, index names would not be the same as
* what 3.0.9 and newer expect. This code fragment drops captcha
* tables, destroying all entered Q&A captcha configuration, such
* that when Q&A is configured next the respective tables will be
* created with correct index names.
*
* If you wish to preserve your Q&A captcha configuration, you can
* manually rename indexes to the currently expected name:
* phpbb_captcha_questions_lang_iso => phpbb_captcha_questions_lang
* phpbb_captcha_answers_question_id => phpbb_captcha_answers_qid
*
* Again, this needs to be done only if a board was manually modified
* to fix broken captcha code.
*
if ($db_tools->sql_layer == 'firebird')
{
$tables = array(
$table_prefix . 'captcha_questions',
$table_prefix . 'captcha_answers',
$table_prefix . 'qa_confirm',
$changes = array(
'drop_tables' => array(
$table_prefix . 'captcha_questions',
$table_prefix . 'captcha_answers',
$table_prefix . 'qa_confirm',
),
);
foreach ($tables as $table)
$statements = $db_tools->perform_schema_changes($changes);
foreach ($statements as $sql)
{
if ($db_tools->sql_table_exists($table))
{
$db_tools->sql_table_drop($table);
}
_sql($sql, $errored, $error_ary);
}
}
*/
$no_updates = false;
break;
@@ -2461,6 +2537,12 @@ function change_database_data(&$no_updates, $version)
unset($next_legend);
}
// Rename styles module to 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(
'position' => array(
@@ -2498,10 +2580,67 @@ 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 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',
'title' => 'ACP_EXTENSIONS',
'auth' => 'acl_a_extensions',
'cat' => 'ACP_EXTENSION_MANAGEMENT',
),
);
_add_modules($modules_to_install);
// 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 = 'acp_language'";
$result = $db->sql_query($sql);
$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'))
{
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 . "
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);
@@ -2794,7 +2933,11 @@ function change_database_data(&$no_updates, $version)
set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst']));
// After we have calculated the timezones we can delete user_dst column from user table.
$db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
$statements = $db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
foreach ($statements as $sql)
{
_sql($sql, $errored, $error_ary);
}
}
if (!isset($config['site_home_url']))
@@ -2825,45 +2968,12 @@ function change_database_data(&$no_updates, $version)
}
$db->sql_freeresult($result);
// Add new permission u_chgprofileinfo and duplicate settings from u_sig
// Add new permissions
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
$auth_admin = new auth_admin();
// Only add the new permission if it does not already exist
if (empty($auth_admin->acl_options['id']['u_chgprofileinfo']))
{
$auth_admin->acl_add_option(array('global' => array('u_chgprofileinfo')));
// Now the tricky part, filling the permission
$old_id = $auth_admin->acl_options['id']['u_sig'];
$new_id = $auth_admin->acl_options['id']['u_chgprofileinfo'];
$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();
}
_add_permission($auth_admin, $db, 'u_chgprofileinfo', true, 'u_sig');
_add_permission($auth_admin, $db, 'a_extensions', true, 'a_styles');
// Update the auth setting for the module
$sql = 'UPDATE ' . MODULES_TABLE . "

View File

@@ -215,7 +215,7 @@ $phpbb_style_path_provider = new phpbb_style_path_provider();
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, new phpbb_template_context());
$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template);
$phpbb_style->set_ext_dir_prefix('adm/');
$phpbb_style->set_custom_style('admin', '../adm/style', '');
$phpbb_style->set_custom_style('admin', '../adm/style', array(), '');
$template->assign_var('T_ASSETS_PATH', '../assets');
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');

View File

@@ -121,10 +121,11 @@ class install_convert extends module
require($phpbb_root_path . 'config.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
$db = new $sql_db();
$dbms = phpbb_convert_30_dbms_to_31($dbms);
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@@ -209,10 +210,11 @@ class install_convert extends module
require($phpbb_root_path . 'config.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
$db = new $sql_db();
$dbms = phpbb_convert_30_dbms_to_31($dbms);
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@@ -332,10 +334,11 @@ class install_convert extends module
require($phpbb_root_path . 'config.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
$db = new $sql_db();
$dbms = phpbb_convert_30_dbms_to_31($dbms);
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@@ -425,8 +428,7 @@ class install_convert extends module
if ($src_dbms != $dbms || $src_dbhost != $dbhost || $src_dbport != $dbport || $src_dbname != $dbname || $src_dbuser != $dbuser)
{
$sql_db = 'dbal_' . $src_dbms;
$src_db = new $sql_db();
$src_db = new $src_dbms();
$src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd), $src_dbname, $src_dbport, false, true);
$same_db = false;
}
@@ -575,10 +577,11 @@ class install_convert extends module
require($phpbb_root_path . 'config.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/functions_convert.' . $phpEx);
$db = new $sql_db();
$dbms = phpbb_convert_30_dbms_to_31($dbms);
$db = new $dbms();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
@@ -639,12 +642,8 @@ class install_convert extends module
$src_db = $same_db = null;
if ($convert->src_dbms != $dbms || $convert->src_dbhost != $dbhost || $convert->src_dbport != $dbport || $convert->src_dbname != $dbname || $convert->src_dbuser != $dbuser)
{
if ($convert->src_dbms != $dbms)
{
require($phpbb_root_path . 'includes/db/' . $convert->src_dbms . '.' . $phpEx);
}
$sql_db = 'dbal_' . $convert->src_dbms;
$src_db = new $sql_db();
$dbms = $convert->src_dbms;
$src_db = new $dbms();
$src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, htmlspecialchars_decode($convert->src_dbpasswd), $convert->src_dbname, $convert->src_dbport, false, true);
$same_db = false;
}

View File

@@ -1118,11 +1118,8 @@ class install_install extends module
$dbms = $available_dbms[$data['dbms']]['DRIVER'];
// Load the appropriate database class if not already loaded
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
// Instantiate the database
$db = new $sql_db();
$db = new $dbms();
$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
// NOTE: trigger_error does not work here.
@@ -1418,11 +1415,8 @@ class install_install extends module
$dbms = $available_dbms[$data['dbms']]['DRIVER'];
// Load the appropriate database class if not already loaded
include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
// Instantiate the database
$db = new $sql_db();
$db = new $dbms();
$db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
// NOTE: trigger_error does not work here.
@@ -2095,9 +2089,10 @@ class install_install extends module
'ACP_PERMISSION_ROLES',
'ACP_PERMISSION_MASKS',
),
'ACP_CAT_STYLES' => array(
'ACP_CAT_CUSTOMISE' => array(
'ACP_STYLE_MANAGEMENT',
'ACP_STYLE_COMPONENTS',
'ACP_EXTENSIONS_MANAGEMENT',
'ACP_LANGUAGE',
),
'ACP_CAT_MAINTENANCE' => array(
'ACP_FORUM_LOGS',

View File

@@ -83,7 +83,6 @@ class install_update extends module
// Init DB
require($phpbb_root_path . 'config.' . $phpEx);
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
// Special options for conflicts/modified files
@@ -92,7 +91,9 @@ class install_update extends module
define('MERGE_NEW_FILE', 3);
define('MERGE_MOD_FILE', 4);
$db = new $sql_db();
$dbms = phpbb_convert_30_dbms_to_31($dbms);
$db = new $dbms();
// Connect to DB
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
@@ -131,7 +132,7 @@ class install_update extends module
}
// Set custom template again. ;)
$phpbb_style->set_custom_style('admin', '../adm/style', '');
$phpbb_style->set_custom_style('admin', '../adm/style', array(), '');
$template->assign_vars(array(
'S_USER_LANG' => $user->lang['USER_LANG'],