aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-07-06 13:37:59 +0200
committerJoas Schilling <nickvergessen@gmx.de>2013-07-14 11:51:36 -0400
commit9c653341e4d747302bdde1273fd71199ca3b40ef (patch)
tree474bf58d3d6c4c54e2fccaa9270167f9c8217081
parentce0a182c7fcd0c67020a44109440cd807bee2e82 (diff)
downloadforums-9c653341e4d747302bdde1273fd71199ca3b40ef.tar
forums-9c653341e4d747302bdde1273fd71199ca3b40ef.tar.gz
forums-9c653341e4d747302bdde1273fd71199ca3b40ef.tar.bz2
forums-9c653341e4d747302bdde1273fd71199ca3b40ef.tar.xz
forums-9c653341e4d747302bdde1273fd71199ca3b40ef.zip
[ticket/11582] Use new methods and remove duplicated entries
PHPBB3-11582
-rw-r--r--phpBB/includes/acp/acp_permission_roles.php12
-rw-r--r--phpBB/includes/acp/acp_permissions.php9
-rw-r--r--phpBB/includes/acp/auth.php13
-rw-r--r--phpBB/includes/permissions.php44
-rw-r--r--phpBB/language/en/acp/permissions_phpbb.php8
5 files changed, 54 insertions, 32 deletions
diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php
index 2a00301543..f7c0494a0b 100644
--- a/phpBB/includes/acp/acp_permission_roles.php
+++ b/phpBB/includes/acp/acp_permission_roles.php
@@ -306,6 +306,9 @@ class acp_permission_roles
trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
+ global $phpbb_container;
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
+
$template->assign_vars(array(
'S_EDIT' => true,
@@ -314,9 +317,8 @@ class acp_permission_roles
'ROLE_NAME' => $role_row['role_name'],
'ROLE_DESCRIPTION' => $role_row['role_description'],
- 'L_ACL_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)],
- )
- );
+ 'L_ACL_TYPE' => $phpbb_permissions->get_type_lang($permission_type),
+ ));
// We need to fill the auth options array with ACL_NO options ;)
$sql = 'SELECT auth_option_id, auth_option
@@ -458,7 +460,7 @@ class acp_permission_roles
{
global $template, $user, $phpbb_container;
- $permissions = $phpbb_container->get('acl.permissions');
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
$content_array = $categories = array();
$key_sort_array = array(0);
@@ -475,7 +477,7 @@ class acp_permission_roles
foreach ($content_array as $cat => $cat_array)
{
$template->assign_block_vars('auth', array(
- 'CAT_NAME' => $permissions->get_lang_category($cat),
+ 'CAT_NAME' => $phpbb_permissions->get_category_lang($cat),
'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false,
'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false,
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index 13e0f1c535..17c6561b65 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -510,9 +510,12 @@ class acp_permissions
trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
+ global $phpbb_container;
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
+
$template->assign_vars(array(
'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false,
- 'L_PERMISSION_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)],
+ 'L_PERMISSION_TYPE' => $phpbb_permissions->get_type_lang($permission_type),
'U_ACTION' => $this->u_action,
'S_HIDDEN_FIELDS' => $s_hidden_fields)
@@ -589,7 +592,7 @@ class acp_permissions
{
global $auth, $phpbb_container;
- $permissions = $phpbb_container->get('acl.permissions');
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
$s_dropdown_options = '';
foreach ($options as $setting)
@@ -600,7 +603,7 @@ class acp_permissions
}
$selected = ($setting == $default_option) ? ' selected="selected"' : '';
- $l_setting = $permissions->get_lang_type($setting, $permission_scope);
+ $l_setting = $phpbb_permissions->get_type_lang($setting, $permission_scope);
$s_dropdown_options .= '<option value="' . $setting . '"' . $selected . '>' . $l_setting . '</option>';
}
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index 7a7ccc0c50..630deb991e 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -261,7 +261,8 @@ class auth_admin extends phpbb_auth
*/
function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true)
{
- global $template, $user, $db, $phpbb_root_path, $phpEx;
+ global $template, $user, $db, $phpbb_root_path, $phpEx, $phpbb_container;
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
// Define names for template loops, might be able to be set
$tpl_pmask = 'p_mask';
@@ -269,7 +270,7 @@ class auth_admin extends phpbb_auth
$tpl_category = 'category';
$tpl_mask = 'mask';
- $l_acl_type = (isset($user->lang['ACL_TYPE_' . (($local) ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type)])) ? $user->lang['ACL_TYPE_' . (($local) ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type)] : 'ACL_TYPE_' . (($local) ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type);
+ $l_acl_type = $phpbb_permissions->get_type_lang($permission_type, (($local) ? 'local' : 'global'));
// Allow trace for viewing permissions and in user mode
$show_trace = ($mode == 'view' && $user_mode == 'user') ? true : false;
@@ -1102,7 +1103,7 @@ class auth_admin extends phpbb_auth
{
global $template, $user, $phpbb_admin_path, $phpEx, $phpbb_container;
- $permissions = $phpbb_container->get('acl.permissions');
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
@reset($category_array);
while (list($cat, $cat_array) = each($category_array))
@@ -1112,7 +1113,7 @@ class auth_admin extends phpbb_auth
'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false,
'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false,
- 'CAT_NAME' => $permissions->get_lang_category($cat),
+ 'CAT_NAME' => $phpbb_permissions->get_category_lang($cat),
));
/* Sort permissions by name (more naturaly and user friendly than sorting by a primary key)
@@ -1180,7 +1181,7 @@ class auth_admin extends phpbb_auth
{
global $user, $phpbb_container;
- $permissions = $phpbb_container->get('acl.permissions');
+ $phpbb_permissions = $phpbb_container->get('acl.permissions');
foreach ($key_sort_array as $forum_id)
{
@@ -1208,7 +1209,7 @@ class auth_admin extends phpbb_auth
// Build our categories array
if (!isset($categories[$cat]))
{
- $categories[$cat] = $permissions->get_lang_category($cat);
+ $categories[$cat] = $phpbb_permissions->get_category_lang($cat);
}
// Build our content array
diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php
index f3b2ab5da0..368fd7bc5f 100644
--- a/phpBB/includes/permissions.php
+++ b/phpBB/includes/permissions.php
@@ -86,9 +86,9 @@ class phpbb_permissions
/**
* Returns the language string of a permission category
*
- * @return array Language string
+ * @return string Language string
*/
- public function get_lang_category($category)
+ public function get_category_lang($category)
{
return $this->user->lang($this->categories[$category]);
}
@@ -106,18 +106,22 @@ class phpbb_permissions
/**
* Returns the language string of a permission type
*
- * @return array Language string
+ * @return string Language string
*/
- public function get_lang_type($type, $scope = false)
+ public function get_type_lang($type, $scope = false)
{
if ($scope && isset($this->types[$scope][$type]))
{
$lang_key = $this->types[$scope][$type];
}
- else
+ else if (isset($this->types[$type]))
{
$lang_key = $this->types[$type];
}
+ else
+ {
+ $lang_key = 'ACL_TYPE_' . strtoupper(($scope) ? $scope . '_' . $type : $type);
+ }
return $this->user->lang($lang_key);
}
@@ -144,13 +148,33 @@ class phpbb_permissions
return $this->permissions;
}
+ /**
+ * Returns the category of a permission
+ *
+ * @return string
+ */
+ public function get_permission_category($permission)
+ {
+ return (isset($this->permissions[$permission]['cat'])) ? $this->permissions[$permission]['cat'] : 'misc';
+ }
+
+ /**
+ * Returns the language string of a permission
+ *
+ * @return string Language string
+ */
+ public function get_permission_lang($permission)
+ {
+ return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission));
+ }
+
protected $types = array(
- 'u_' => 'ACL_TYPE_USER',
- 'a_' => 'ACL_TYPE_ADMIN',
- 'm_' => 'ACL_TYPE_MODERATOR',
- 'f_' => 'ACL_TYPE_FORUM',
+ 'u_' => 'ACL_TYPE_U_',
+ 'a_' => 'ACL_TYPE_A_',
+ 'm_' => 'ACL_TYPE_M_',
+ 'f_' => 'ACL_TYPE_F_',
'global' => array(
- 'm_' => 'ACL_TYPE_GLOBAL_MODERATOR',
+ 'm_' => 'ACL_TYPE_GLOBAL_M_',
),
);
diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php
index 0a669a4b8d..4f2c9067d2 100644
--- a/phpBB/language/en/acp/permissions_phpbb.php
+++ b/phpBB/language/en/acp/permissions_phpbb.php
@@ -63,7 +63,6 @@ if (empty($lang) || !is_array($lang))
* </code>
*/
-// Define categories and permission types
$lang = array_merge($lang, array(
'ACL_CAT_ACTIONS' => 'Actions',
'ACL_CAT_CONTENT' => 'Content',
@@ -79,13 +78,6 @@ $lang = array_merge($lang, array(
'ACL_CAT_SETTINGS' => 'Settings',
'ACL_CAT_TOPIC_ACTIONS' => 'Topic actions',
'ACL_CAT_USER_GROUP' => 'Users &amp; Groups',
-
-
- 'ACL_TYPE_USER' => 'User permissions',
- 'ACL_TYPE_ADMIN' => 'Admin permissions',
- 'ACL_TYPE_MODERATOR' => 'Moderator permissions',
- 'ACL_TYPE_FORUM' => 'Forum permissions',
- 'ACL_TYPE_GLOBAL_MODERATOR' => 'Global moderator permissions',
));
// User Permissions