diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-02-24 17:33:42 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-02-24 17:33:42 +0000 |
commit | 724b37ae9706c24b23833da67565dc20d7d78045 (patch) | |
tree | eea320ac39a6498362441f819b9ea53381524de5 /phpBB/includes | |
parent | 37e0e0a4da489125f825ad9f2ba9ea1763e82452 (diff) | |
download | forums-724b37ae9706c24b23833da67565dc20d7d78045.tar forums-724b37ae9706c24b23833da67565dc20d7d78045.tar.gz forums-724b37ae9706c24b23833da67565dc20d7d78045.tar.bz2 forums-724b37ae9706c24b23833da67565dc20d7d78045.tar.xz forums-724b37ae9706c24b23833da67565dc20d7d78045.zip |
- blabla, additional bugfixing permissions...
git-svn-id: file:///svn/phpbb/trunk@5580 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_permission_roles.php | 102 | ||||
-rw-r--r-- | phpBB/includes/acp/auth.php | 42 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 5 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 5 |
5 files changed, 100 insertions, 56 deletions
diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 2bf32093f4..250b4db3bf 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -111,7 +111,7 @@ class acp_permission_roles if (confirm_box(true)) { - $this->remove_role($role_id); + $this->remove_role($role_id, $permission_type); add_log('admin', 'LOG_' . strtoupper($permission_type) . 'ROLE_REMOVED', $role_row['role_name']); trigger_error($user->lang['ROLE_DELETED'] . adm_back_link($this->u_action)); @@ -189,9 +189,12 @@ class acp_permission_roles if (!$row['negate'] && !isset($row['name'])) { - foreach ($groups[$row['type']] as $group_id => $group_name) + if (isset($groups[$row['type']])) { - $role_group_ids[] = $group_id; + foreach ($groups[$row['type']] as $group_id => $group_name) + { + $role_group_ids[] = $group_id; + } } } else if ($row['negate'] && !isset($row['name'])) @@ -201,6 +204,11 @@ class acp_permission_roles foreach ($group_types as $type) { + if (!isset($groups[$type])) + { + continue; + } + foreach ($groups[$type] as $group_id => $group_name) { $role_group_ids[] = $group_id; @@ -223,6 +231,11 @@ class acp_permission_roles foreach ($group_types as $type) { + if (!isset($groups[$type])) + { + continue; + } + foreach ($groups[$type] as $group_id => $group_name) { if ($type != $row['type']) @@ -421,7 +434,11 @@ class acp_permission_roles if (sizeof($hold_ary)) { - $template->assign_var('S_DISPLAY_ROLE_MASK', true); + $template->assign_var(array( + 'S_DISPLAY_ROLE_MASK' => true, + 'L_ROLE_ASSIGNED_TO' => sprintf($user->lang['ROLE_ASSIGNED_TO'], $role_row['role_name'])) + ); + $auth_admin->display_role_mask($hold_ary); } } @@ -466,6 +483,9 @@ class acp_permission_roles $db->sql_freeresult($result); } + // Display assigned items? + $display_item = request_var('display_item', 0); + $s_role_options = ''; foreach ($roles as $row) { @@ -476,7 +496,7 @@ class acp_permission_roles 'U_EDIT' => $this->u_action . '&action=edit&role_id=' . $row['role_id'], 'U_REMOVE' => $this->u_action . '&action=remove&role_id=' . $row['role_id'], - 'U_DISPLAY_ITEMS' => $this->u_action . '&display_item=' . $row['role_id'] . '#assigned_to') + 'U_DISPLAY_ITEMS' => ($row['role_id'] == $display_item) ? '' : $this->u_action . '&display_item=' . $row['role_id'] . '#assigned_to') ); if (isset($groups[$row['role_id']]) && sizeof($groups[$row['role_id']])) @@ -492,18 +512,24 @@ class acp_permission_roles } $s_role_options .= '<option value="' . $row['role_id'] . '">' . $row['role_name'] . '</option>'; + + if ($display_item == $row['role_id']) + { + $template->assign_vars(array( + 'L_ROLE_ASSIGNED_TO' => sprintf($user->lang['ROLE_ASSIGNED_TO'], $row['role_name'])) + ); + } } $template->assign_vars(array( 'S_ROLE_OPTIONS' => $s_role_options) ); - // Display assigned items? - $display_item = request_var('display_item', 0); - if ($display_item) { - $template->assign_var('S_DISPLAY_ROLE_MASK', true); + $template->assign_vars(array( + 'S_DISPLAY_ROLE_MASK' => true) + ); $hold_ary = $auth_admin->get_role_mask($display_item); $auth_admin->display_role_mask($hold_ary); @@ -661,12 +687,20 @@ class acp_permission_roles } } } - - foreach ($group_types as $type) + + if ($s_selected) { - if (!isset($selected_groups[$type]) || sizeof($selected_groups[$type]) != sizeof($groups[$type])) + foreach ($group_types as $type) { - $s_selected = false; + if (!isset($groups[$type])) + { + continue; + } + + if (!isset($selected_groups[$type]) || sizeof($selected_groups[$type]) != sizeof($groups[$type])) + { + $s_selected = false; + } } } } @@ -687,20 +721,32 @@ class acp_permission_roles /** * Remove role */ - function remove_role($role_id) + function remove_role($role_id, $permission_type) { global $db; $auth_admin = new auth_admin(); - // First of all, get the role auth settings we need to re-set... + // Get complete auth array + $sql = 'SELECT auth_option, auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option LIKE '" . $db->sql_escape($permission_type) . "%'"; + $result = $db->sql_query($sql); + + $auth_settings = array(); + while ($row = $db->sql_fetchrow($result)) + { + $auth_settings[$row['auth_option']] = ACL_UNSET; + } + $db->sql_freeresult($result); + + // Get the role auth settings we need to re-set... $sql = 'SELECT o.auth_option, r.auth_setting FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o WHERE o.auth_option_id = r.auth_option_id AND r.role_id = ' . $role_id; $result = $db->sql_query($sql); - $auth_settings = array(); while ($row = $db->sql_fetchrow($result)) { $auth_settings[$row['auth_option']] = $row['auth_setting']; @@ -709,30 +755,30 @@ class acp_permission_roles // Get role assignments $hold_ary = $auth_admin->get_role_mask($role_id); - - // Remove role from users and groups - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE auth_role_id = ' . $role_id; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE auth_role_id = ' . $role_id; - $db->sql_query($sql); // Re-assign permisisons foreach ($hold_ary as $forum_id => $forum_ary) { if (isset($forum_ary['users'])) { - $auth_admin->acl_set('user', $forum_id, $forum_ary['users'], $auth_settings); + $auth_admin->acl_set('user', $forum_id, $forum_ary['users'], $auth_settings, 0, false); } if (isset($forum_ary['groups'])) { - $auth_admin->acl_set('group', $forum_id, $forum_ary['users'], $auth_settings); + $auth_admin->acl_set('group', $forum_id, $forum_ary['groups'], $auth_settings, 0, false); } } + // Remove role from users and groups just to be sure (happens through acl_set) + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' + WHERE auth_role_id = ' . $role_id; + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE auth_role_id = ' . $role_id; + $db->sql_query($sql); + // Remove role data and role $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE role_id = ' . $role_id; @@ -741,6 +787,8 @@ class acp_permission_roles $sql = 'DELETE FROM ' . ACL_ROLES_TABLE . ' WHERE role_id = ' . $role_id; $db->sql_query($sql); + + $auth_admin->acl_clear_prefetch(); } } diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 932d990aae..8f47a6dc71 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -47,6 +47,20 @@ class auth_admin extends auth $cache->put('acl_options', $this->acl_options); } + + if (!sizeof($this->option_ids)) + { + $sql = 'SELECT auth_option_id, auth_option + FROM ' . ACL_OPTIONS_TABLE; + $result = $db->sql_query($sql); + + $this->option_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $this->option_ids[$row['auth_option']] = $row['auth_option_id']; + } + $db->sql_freeresult($result); + } } /** @@ -662,20 +676,6 @@ class auth_admin extends auth $ug_id = array($ug_id); } - if (!sizeof($this->option_ids)) - { - $sql = 'SELECT auth_option_id, auth_option - FROM ' . ACL_OPTIONS_TABLE; - $result = $db->sql_query($sql); - - $this->option_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $this->option_ids[$row['auth_option']] = $row['auth_option_id']; - } - $db->sql_freeresult($result); - } - $ug_id_sql = 'IN (' . implode(', ', array_map('intval', $ug_id)) . ')'; $forum_sql = 'IN (' . implode(', ', array_map('intval', $forum_id)) . ') '; @@ -781,20 +781,6 @@ class auth_admin extends auth { global $db; - if (!sizeof($this->option_ids)) - { - $sql = 'SELECT auth_option_id, auth_option - FROM ' . ACL_OPTIONS_TABLE; - $result = $db->sql_query($sql); - - $this->option_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $this->option_ids[$row['auth_option']] = $row['auth_option_id']; - } - $db->sql_freeresult($result); - } - // Remove current auth options... $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE role_id = ' . $role_id; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 5f1fdff5e5..28f8acd57c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -130,7 +130,7 @@ function user_delete($mode, $user_id) if (!function_exists('delete_posts')) { global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + include_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); } $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 8862cf31dd..06c06cd98a 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -602,6 +602,11 @@ function mcp_delete_post($post_ids) if (confirm_box(true)) { + if (!function_exists('delete_posts')) + { + include_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + } + // Count the number of topics that are affected // I did not use COUNT(DISTINCT ...) because I remember having problems // with it on older versions of MySQL -- Ashe diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index aa649df8d4..1ec6101b5a 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -613,6 +613,11 @@ function disapprove_post($post_id_list) if (sizeof($post_disapprove_sql)) { + if (!function_exists('delete_posts')) + { + include_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + } + // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts delete_posts('post_id', $post_disapprove_sql); } |