aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/acp_permission_roles.html4
-rw-r--r--phpBB/includes/acp/acp_permission_roles.php102
-rw-r--r--phpBB/includes/acp/auth.php42
-rw-r--r--phpBB/includes/functions_user.php2
-rw-r--r--phpBB/includes/mcp/mcp_main.php5
-rw-r--r--phpBB/includes/mcp/mcp_queue.php5
-rw-r--r--phpBB/language/en/acp/permissions.php2
-rw-r--r--phpBB/posting.php4
8 files changed, 106 insertions, 60 deletions
diff --git a/phpBB/adm/style/acp_permission_roles.html b/phpBB/adm/style/acp_permission_roles.html
index 21aa9d911f..972abe35a1 100644
--- a/phpBB/adm/style/acp_permission_roles.html
+++ b/phpBB/adm/style/acp_permission_roles.html
@@ -194,7 +194,7 @@
<!-- ENDIF -->
</td>
<td style="vertical-align: top; white-space: nowrap;"><a href="{roles.U_EDIT}">{L_EDIT_ROLE}</a></td>
- <td style="vertical-align: top; white-space: nowrap;"><a href="{roles.U_DISPLAY_ITEMS}">{L_VIEW_ASSIGNED_ITEMS}</a></td>
+ <td style="vertical-align: top; white-space: nowrap;"><!-- IF roles.U_DISPLAY_ITEMS --><a href="{roles.U_DISPLAY_ITEMS}">{L_VIEW_ASSIGNED_ITEMS}</a><!-- ELSE -->{L_VIEW_ASSIGNED_ITEMS}<!-- ENDIF --></td>
<td style="vertical-align: top; white-space: nowrap;"><a href="{roles.U_REMOVE}">{L_REMOVE_ROLE}</a></td>
</tr>
<!-- END roles -->
@@ -208,7 +208,7 @@
</form>
<!-- IF S_DISPLAY_ROLE_MASK -->
-
+
<a name="assigned_to"></a>
<h1>{L_ROLE_ASSIGNED_TO}</h1>
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 . '&amp;action=edit&amp;role_id=' . $row['role_id'],
'U_REMOVE' => $this->u_action . '&amp;action=remove&amp;role_id=' . $row['role_id'],
- 'U_DISPLAY_ITEMS' => $this->u_action . '&amp;display_item=' . $row['role_id'] . '#assigned_to')
+ 'U_DISPLAY_ITEMS' => ($row['role_id'] == $display_item) ? '' : $this->u_action . '&amp;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);
}
diff --git a/phpBB/language/en/acp/permissions.php b/phpBB/language/en/acp/permissions.php
index def1fa7c7e..9c67e3e8b5 100644
--- a/phpBB/language/en/acp/permissions.php
+++ b/phpBB/language/en/acp/permissions.php
@@ -129,7 +129,7 @@ $lang = array_merge($lang, array(
'REMOVE_ROLE' => 'Remove Role',
'ROLE' => 'Role',
'ROLE_ADD_SUCCESS' => 'Role successfully added.',
- 'ROLE_ASSIGNED_TO' => 'Role assigned to',
+ 'ROLE_ASSIGNED_TO' => 'Users/Groups assigned to %s',
'ROLE_DELETED' => 'Role successfully removed.',
'ROLE_DETAILS' => 'Role Details',
'ROLE_EDIT_SUCCESS' => 'Role successfully edited.',
diff --git a/phpBB/posting.php b/phpBB/posting.php
index b9a38e61f8..f1e47570bb 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1177,13 +1177,15 @@ page_footer();
*/
function delete_post($mode, $post_id, $topic_id, $forum_id, &$data)
{
- global $db, $user, $config, $auth, $phpEx, $SID;
+ global $db, $user, $config, $auth, $phpEx, $SID, $phpbb_root_path;
// Specify our post mode
$post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'delete_topic' : (($data['topic_first_post_id'] == $post_id) ? 'delete_first_post' : (($data['topic_last_post_id'] == $post_id) ? 'delete_last_post' : 'delete'));
$sql_data = array();
$next_post_id = 0;
+ include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+
$db->sql_transaction();
if (!delete_posts('post_id', array($post_id), false))