From 4980d8b01150593175274dad45890544f56075d6 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 2 Sep 2012 23:44:13 -0400 Subject: [PATCH 01/14] [ticket/11088] Move style, extension and language pack management to customise Instead of being separated, these related ACP modules are now grouped intuitively. PHPBB3-11088 --- phpBB/includes/acp/info/acp_extensions.php | 4 ++-- phpBB/includes/acp/info/acp_language.php | 2 +- phpBB/install/database_update.php | 14 ++++++++++++++ phpBB/install/install_install.php | 5 +++-- phpBB/language/en/acp/common.php | 12 +++++++----- 5 files changed, 27 insertions(+), 10 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..d276cdbc57 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2489,6 +2489,20 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), + 'lang_management' => array( + 'base' => 'acp_language', + 'class' => 'acp', + 'title' => 'ACL_LANGUAGE_PACKS', + 'auth' => 'acl_a_language', + 'cat' => 'ACL_LANGUAGE', + ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 4b2fa046bc..b29b5c8605 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..61fc704b65 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 file extension groups', + 'ACP_EXTENSIONS' => 'Extensions', + 'ACP_EXTENSIONS_MANAGEMENT' => 'Extension management', + '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 file extensions', 'ACP_MANAGE_FORUMS' => 'Manage forums', 'ACP_MANAGE_RANKS' => 'Manage ranks', 'ACP_MANAGE_REASONS' => 'Manage report/denial reasons', @@ -165,8 +168,7 @@ $lang = array_merge($lang, array( 'ACP_SERVER_CONFIGURATION' => 'Server configuration', 'ACP_SERVER_SETTINGS' => 'Server settings', 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', - 'ACP_SMILIES' => 'Smilies', - 'ACP_STYLE_COMPONENTS' => 'Style components', + 'ACP_SMILIES' => 'Smilies', 'ACP_STYLE_MANAGEMENT' => 'Style management', 'ACP_STYLES' => 'Styles', 'ACP_STYLES_CACHE' => 'Purge Cache', From f7d9b15a973feec355ed50313207f4b71c50930e Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 3 Sep 2012 12:32:57 -0300 Subject: [PATCH 02/14] [ticket/11088] Removed added space PHPBB3-11088 --- phpBB/language/en/acp/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 61fc704b65..e490a2c31f 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -168,7 +168,7 @@ $lang = array_merge($lang, array( 'ACP_SERVER_CONFIGURATION' => 'Server configuration', 'ACP_SERVER_SETTINGS' => 'Server settings', 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', - 'ACP_SMILIES' => 'Smilies', + 'ACP_SMILIES' => 'Smilies', 'ACP_STYLE_MANAGEMENT' => 'Style management', 'ACP_STYLES' => 'Styles', 'ACP_STYLES_CACHE' => 'Purge Cache', From e2aef2bfd1385b31e923690c3a12628a876c2b13 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 28 Sep 2012 17:23:27 -0400 Subject: [PATCH 03/14] [ticket/11088] Added missing comma PHPBB3-11088 --- phpBB/install/install_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index b29b5c8605..1857b9f3fd 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -2098,7 +2098,7 @@ class install_install extends module 'ACP_CAT_CUSTOMISE' => array( 'ACP_STYLE_MANAGEMENT', 'ACP_EXTENSIONS_MANAGEMENT', - 'ACP_LANGUAGE' + 'ACP_LANGUAGE', ), 'ACP_CAT_MAINTENANCE' => array( 'ACP_FORUM_LOGS', From e58c6536f0407ec5f82c634c058270c4e627d03d Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 28 Sep 2012 18:03:35 -0400 Subject: [PATCH 04/14] [ticket/11088] Untested progress for update script PHPBB3-11088 --- phpBB/install/database_update.php | 55 +++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d276cdbc57..73efa3f7f6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,6 +2459,19 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } + // Create new Customise ACP tab + $module_manager = new acp_modules(); + $module_manager->update_module_data(array( + 'parent_id' => 0, + 'module_enabled' => 1, + 'module_display' => 1, + 'module_basename' => ''. + 'module_class' => 'acp', + 'module_mode' => '', + 'module_auth' => '', + 'module_langname' => 'ACP_CAT_CUSTOMISE', + )); + // Install modules $modules_to_install = array( 'position' => array( @@ -2489,20 +2502,6 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), - 'extensions' => array( - 'base' => 'acp_extensions', - 'class' => 'acp', - 'title' => 'ACP_EXTENSIONS', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_EXTENSION_MANAGEMENT', - ), - 'lang_management' => array( - 'base' => 'acp_language', - 'class' => 'acp', - 'title' => 'ACL_LANGUAGE_PACKS', - 'auth' => 'acl_a_language', - 'cat' => 'ACL_LANGUAGE', - ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', @@ -2510,6 +2509,13 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), ); _add_modules($modules_to_install); @@ -2518,6 +2524,27 @@ function change_database_data(&$no_updates, $version) 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); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language' OR module_langname = 'styles'"; + $result = $db->sql_query($sql); + $modules_to_move = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + // Next, selec the ID of the new parent module + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; + $result = $db->sql_query($sql); + $customise_category_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + // Now perform the move + foreach ($modules_to_move as $module_id) + { + $module_manager->move_module($module_id, $customise_category_id); + } + // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' From 72d1a210de0f08550ce6a1b44c5ac468520146f2 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:25:24 -0400 Subject: [PATCH 05/14] [ticket/11088] Fix typo (period instead of comma) PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 73efa3f7f6..7fa853938d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,7 +2465,7 @@ function change_database_data(&$no_updates, $version) 'parent_id' => 0, 'module_enabled' => 1, 'module_display' => 1, - 'module_basename' => ''. + 'module_basename' => '', 'module_class' => 'acp', 'module_mode' => '', 'module_auth' => '', From 30c64f6a01e7d5706c4c0e6b429c1d200f1c3e46 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:37:46 -0400 Subject: [PATCH 06/14] [ticket/11088] Untested, progress on update script This should rename Styles category to Customise, move language packs, and add extension management PHPBB3-11088 --- phpBB/install/database_update.php | 49 +++++++++++++------------------ 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7fa853938d..610c591fcc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,19 +2459,31 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } - // Create new Customise ACP tab + // 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( - 'parent_id' => 0, - 'module_enabled' => 1, - 'module_display' => 1, - 'module_basename' => '', - 'module_class' => 'acp', - 'module_mode' => '', - 'module_auth' => '', + 'module_id' => $styles_module_id, 'module_langname' => 'ACP_CAT_CUSTOMISE', )); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $customise_category_id); + } + $db->sql_freeresult($result); + // Install modules $modules_to_install = array( 'position' => array( @@ -2524,27 +2536,6 @@ function change_database_data(&$no_updates, $version) 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); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language' OR module_langname = 'styles'"; - $result = $db->sql_query($sql); - $modules_to_move = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - // Next, selec the ID of the new parent module - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; - $result = $db->sql_query($sql); - $customise_category_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - // Now perform the move - foreach ($modules_to_move as $module_id) - { - $module_manager->move_module($module_id, $customise_category_id); - } - // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' From 80f68c358ff9e01d5cf4327c5c0d748e6e6de448 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 11:38:44 -0500 Subject: [PATCH 07/14] [ticket/11088] Put language pack module move below extension module creation PHPBB3-11088 --- phpBB/install/database_update.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 610c591fcc..47983676cc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2473,17 +2473,6 @@ function change_database_data(&$no_updates, $version) 'module_langname' => 'ACP_CAT_CUSTOMISE', )); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; - $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) - { - $module_manager->move_module($row['module_id'], $customise_category_id); - } - $db->sql_freeresult($result); - // Install modules $modules_to_install = array( 'position' => array( @@ -2532,6 +2521,16 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Move language management to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $styles_module_id); + } + $db->sql_freeresult($result); + $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); From 70aea6fd7c1af79774d800eaafe11c5381e3ff32 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 12:48:27 -0500 Subject: [PATCH 08/14] [ticket/11088] Fix the database updater to correctly manipulate the modules PHPBB3-11088 --- phpBB/install/database_update.php | 104 ++++++++++++++++++++++++------ phpBB/language/en/acp/common.php | 2 +- 2 files changed, 87 insertions(+), 19 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)) - { - $module_manager->move_module($row['module_id'], $styles_module_id); - } + $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')"; @@ -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' diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index e490a2c31f..037b76b907 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -82,8 +82,8 @@ $lang = array_merge($lang, array( 'ACP_EMAIL_SETTINGS' => 'Email settings', 'ACP_EXTENSION_GROUPS' => 'Manage file extension groups', + 'ACP_EXTENSION_MANAGEMENT' => 'Extension management', 'ACP_EXTENSIONS' => 'Extensions', - 'ACP_EXTENSIONS_MANAGEMENT' => 'Extension management', 'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions', From 6dc89d6e31442f8d2024b8e9b7b0071f199f7952 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:36:52 -0500 Subject: [PATCH 09/14] [ticket/11088] Changed "file extensions" to "attachment extensions" PHPBB3-11088 --- phpBB/language/en/acp/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 037b76b907..427e4f4d98 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -81,7 +81,7 @@ $lang = array_merge($lang, array( 'ACP_DISALLOW_USERNAMES' => 'Disallow usernames', 'ACP_EMAIL_SETTINGS' => 'Email settings', - 'ACP_EXTENSION_GROUPS' => 'Manage file extension groups', + 'ACP_EXTENSION_GROUPS' => 'Manage attachment extension groups', 'ACP_EXTENSION_MANAGEMENT' => 'Extension management', 'ACP_EXTENSIONS' => 'Extensions', @@ -122,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 file extensions', + 'ACP_MANAGE_EXTENSIONS' => 'Manage attachment extensions', 'ACP_MANAGE_FORUMS' => 'Manage forums', 'ACP_MANAGE_RANKS' => 'Manage ranks', 'ACP_MANAGE_REASONS' => 'Manage report/denial reasons', From 61adfa502684727f071f85afde08227ebc448232 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:37:39 -0500 Subject: [PATCH 10/14] [ticket/11088] Remove extraneous word from sentence in comment PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index afc816845d..1d4c71767b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2503,7 +2503,7 @@ function change_database_data(&$no_updates, $version) 'cat' => 'UCP_PROFILE', ), // To add a category, the mode and basename must be empty - // The mode is taken from the this array key + // The mode is taken from the array key '' => array( 'base' => '', 'class' => 'acp', From 8e4c1526fc3d0b8897886a12dff59808398b2304 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:39:48 -0500 Subject: [PATCH 11/14] [ticket/11088] Copy a_styles permission for a_extensions PHPBB3-11088 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1d4c71767b..db5659db7c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2899,7 +2899,7 @@ function change_database_data(&$no_updates, $version) $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_']; + $old_id = $auth_admin->acl_options['id']['a_styles']; $new_id = $auth_admin->acl_options['id']['a_extensions']; $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); From 13f8e64a33a862554cfa185bcf09af9ccdace95c Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:01:58 -0500 Subject: [PATCH 12/14] [ticket/11088] Move permission creation to a function PHPBB3-11088 --- phpBB/install/database_update.php | 138 ++++++++++++++---------------- 1 file changed, 66 insertions(+), 72 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index db5659db7c..3815f5e8b3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -818,6 +818,69 @@ 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 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, $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 * *****************************************************************************/ @@ -2853,81 +2916,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 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_styles']; - $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(); - } + _add_permission($auth_admin, 'u_chgprofileinfo', true, 'u_sig'); + _add_permission($auth_admin, 'a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " From 5fc6752178ebc814c83b88b5891c568273d36c94 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:04:20 -0500 Subject: [PATCH 13/14] [ticket/11088] Globalize objects in new permission function PHPBB3-11088 --- phpBB/install/database_update.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3815f5e8b3..fb762c6137 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -827,8 +827,9 @@ function _add_modules($modules_to_install) * @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, $permission_name, $is_global = true, $copy_from = '') +function _add_permission($permission_name, $is_global = true, $copy_from = '') { + global $db, $auth_admin; // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) { @@ -2920,8 +2921,8 @@ function change_database_data(&$no_updates, $version) include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - _add_permission($auth_admin, 'u_chgprofileinfo', true, 'u_sig'); - _add_permission($auth_admin, 'a_extensions', true, 'a_styles'); + _add_permission('u_chgprofileinfo', true, 'u_sig'); + _add_permission('a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " From a5783211c90e226a9d1a2b3636f63f1a80aced19 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:19:06 -0500 Subject: [PATCH 14/14] [ticket/11088] Pass required objects in as arguments PHPBB3-11088 --- phpBB/install/database_update.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fb762c6137..7aa346b817 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -822,14 +822,14 @@ function _add_modules($modules_to_install) * 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($permission_name, $is_global = true, $copy_from = '') +function _add_permission(auth_admin $auth_admin, dbal $db, $permission_name, $is_global = true, $copy_from = '') { - global $db, $auth_admin; // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) { @@ -2921,8 +2921,8 @@ function change_database_data(&$no_updates, $version) include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - _add_permission('u_chgprofileinfo', true, 'u_sig'); - _add_permission('a_extensions', true, 'a_styles'); + _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 . "