1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge remote-tracking branch 'upstream/develop' into ticket/11015

* upstream/develop: (101 commits)
  [ticket/10491] Make recreate_database static.
  [ticket/11088] Pass required objects in as arguments
  [ticket/11088] Globalize objects in new permission function
  [ticket/11088] Move permission creation to a function
  [ticket/11088] Copy a_styles permission for a_extensions
  [ticket/11088] Remove extraneous word from sentence in comment
  [ticket/11088] Changed "file extensions" to "attachment extensions"
  [ticket/11088] Fix the database updater to correctly manipulate the modules
  [ticket/11088] Put language pack module move below extension module creation
  [ticket/11088] Untested, progress on update script
  [ticket/11088] Fix typo (period instead of comma)
  [ticket/11088] Untested progress for update script
  [ticket/11088] Added missing comma
  [ticket/11088] Removed added space
  [ticket/11088] Move style, extension and language pack management to customise
  [ticket/11243] Show download all link on all pages of topic with attachments
  [feature/template-events] Pass arguments in correct order.
  [feature/template-events] Pass arguments in correct order.
  [ticket/10491] Install board once per test run.
  [ticket/11257] Do not require set_name() method to exist
  ...
This commit is contained in:
Oleg Pudeyev
2012-12-13 07:56:40 -05:00
69 changed files with 1255 additions and 167 deletions

View File

@@ -817,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 dbal $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, dbal $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 *
*****************************************************************************/
@@ -2458,6 +2522,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(
@@ -2495,10 +2565,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);
@@ -2730,8 +2857,6 @@ function change_database_data(&$no_updates, $version)
$config->set('display_last_subject', '1');
}
$no_updates = false;
if (!isset($config['assets_version']))
{
$config->set('assets_version', '1');
@@ -2770,7 +2895,7 @@ function change_database_data(&$no_updates, $version)
}
// PHPBB3-10601: Make inbox default. Add basename to ucp's pm category
// Get the category wanted while checking, at the same time, if this has already been applied
$sql = 'SELECT module_id, module_basename
FROM ' . MODULES_TABLE . "
@@ -2787,10 +2912,27 @@ function change_database_data(&$no_updates, $version)
SET module_basename = 'ucp_pm'
WHERE module_id = " . (int) $row['module_id'];
_sql($sql, $errored, $error_ary);
_sql($sql, $errored, $error_ary);
}
$db->sql_freeresult($result);
// Add new permissions
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
$auth_admin = new auth_admin();
_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 . "
SET module_auth = 'acl_u_chgprofileinfo'
WHERE module_class = 'ucp'
AND module_basename = 'ucp_profile'
AND module_mode = 'profile_info'";
_sql($sql, $errored, $error_ary);
$no_updates = false;
break;
}
}

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

@@ -2089,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

@@ -132,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'],

View File

@@ -387,6 +387,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgemail', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chggrp', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgname', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgpasswd', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_chgprofileinfo', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_download', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_hideonline', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('u_ignoreflood', 1);
@@ -548,7 +549,7 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 22, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option NOT IN ('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_sticky', 'f_user_lock', 'f_votechg');
# New Member (u_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 23, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group');
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 23, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group', 'u_chgprofileinfo');
# New Member (f_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 24, auth_option_id, 0 FROM phpbb_acl_options WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove');