aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-12 21:01:20 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-12 21:01:20 -0500
commit5da78cae0950c60fd02480d896fe44ee29b33d6d (patch)
tree475ea31673d3081af179a741a629de6e3d679fd4
parent9420647c43b300699afe6fe72f09d1746daf64a2 (diff)
parenta5783211c90e226a9d1a2b3636f63f1a80aced19 (diff)
downloadforums-5da78cae0950c60fd02480d896fe44ee29b33d6d.tar
forums-5da78cae0950c60fd02480d896fe44ee29b33d6d.tar.gz
forums-5da78cae0950c60fd02480d896fe44ee29b33d6d.tar.bz2
forums-5da78cae0950c60fd02480d896fe44ee29b33d6d.tar.xz
forums-5da78cae0950c60fd02480d896fe44ee29b33d6d.zip
Merge PR #985 branch 'imkingdavid/ticket/11088' into develop
* imkingdavid/ticket/11088: [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
-rw-r--r--phpBB/includes/acp/info/acp_extensions.php4
-rw-r--r--phpBB/includes/acp/info/acp_language.php2
-rw-r--r--phpBB/install/database_update.php166
-rw-r--r--phpBB/install/install_install.php5
-rw-r--r--phpBB/language/en/acp/common.php10
5 files changed, 142 insertions, 45 deletions
diff --git a/phpBB/includes/acp/info/acp_extensions.php b/phpBB/includes/acp/info/acp_extensions.php
index f5953fb1dd..03d7059165 100644
--- a/phpBB/includes/acp/info/acp_extensions.php
+++ b/phpBB/includes/acp/info/acp_extensions.php
@@ -16,10 +16,10 @@ class acp_extensions_info
{
return array(
'filename' => 'acp_extensions',
- 'title' => 'ACP_EXTENSIONS',
+ 'title' => 'ACP_EXTENSIONS_MANAGEMENT',
'version' => '1.0.0',
'modes' => array(
- 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_GENERAL_TASKS')),
+ 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSIONS_MANAGEMENT')),
),
);
}
diff --git a/phpBB/includes/acp/info/acp_language.php b/phpBB/includes/acp/info/acp_language.php
index 85dfb119ea..7f33a22fa6 100644
--- a/phpBB/includes/acp/info/acp_language.php
+++ b/phpBB/includes/acp/info/acp_language.php
@@ -19,7 +19,7 @@ class acp_language_info
'title' => 'ACP_LANGUAGE',
'version' => '1.0.0',
'modes' => array(
- 'lang_packs' => array('title' => 'ACP_LANGUAGE_PACKS', 'auth' => 'acl_a_language', 'cat' => array('ACP_GENERAL_TASKS')),
+ 'lang_packs' => array('title' => 'ACP_LANGUAGE_PACKS', 'auth' => 'acl_a_language', 'cat' => array('ACP_LANGUAGE')),
),
);
}
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 30592b995d..7aa346b817 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -818,6 +818,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 *
*****************************************************************************/
@@ -2459,6 +2523,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(
@@ -2496,10 +2566,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);
@@ -2790,45 +2917,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 . "
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 4b2fa046bc..1857b9f3fd 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -2095,9 +2095,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',
diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php
index 5eb10d50b3..427e4f4d98 100644
--- a/phpBB/language/en/acp/common.php
+++ b/phpBB/language/en/acp/common.php
@@ -59,6 +59,7 @@ $lang = array_merge($lang, array(
'ACP_CAPTCHA' => 'CAPTCHA',
+ 'ACP_CAT_CUSTOMISE' => 'Customise',
'ACP_CAT_DATABASE' => 'Database',
'ACP_CAT_DOT_MODS' => '.MODs',
'ACP_CAT_FORUMS' => 'Forums',
@@ -80,8 +81,10 @@ $lang = array_merge($lang, array(
'ACP_DISALLOW_USERNAMES' => 'Disallow usernames',
'ACP_EMAIL_SETTINGS' => 'Email settings',
- 'ACP_EXTENSION_GROUPS' => 'Manage extension groups',
- 'ACP_EXTENSIONS' => 'Manage board extensions',
+ 'ACP_EXTENSION_GROUPS' => 'Manage attachment extension groups',
+ 'ACP_EXTENSION_MANAGEMENT' => 'Extension management',
+ 'ACP_EXTENSIONS' => 'Extensions',
+
'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions',
'ACP_FORUM_LOGS' => 'Forum logs',
@@ -119,7 +122,7 @@ $lang = array_merge($lang, array(
'ACP_MANAGE_ATTACHMENTS' => 'Manage attachments',
'ACP_MANAGE_ATTACHMENTS_EXPLAIN' => 'Here you can list and delete files attached to posts and private messages.',
- 'ACP_MANAGE_EXTENSIONS' => 'Manage extensions',
+ 'ACP_MANAGE_EXTENSIONS' => 'Manage attachment extensions',
'ACP_MANAGE_FORUMS' => 'Manage forums',
'ACP_MANAGE_RANKS' => 'Manage ranks',
'ACP_MANAGE_REASONS' => 'Manage report/denial reasons',
@@ -166,7 +169,6 @@ $lang = array_merge($lang, array(
'ACP_SERVER_SETTINGS' => 'Server settings',
'ACP_SIGNATURE_SETTINGS' => 'Signature settings',
'ACP_SMILIES' => 'Smilies',
- 'ACP_STYLE_COMPONENTS' => 'Style components',
'ACP_STYLE_MANAGEMENT' => 'Style management',
'ACP_STYLES' => 'Styles',
'ACP_STYLES_CACHE' => 'Purge Cache',