mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-13 20:44:43 +01:00
- blabla, additional bugfixing permissions...
git-svn-id: file:///svn/phpbb/trunk@5580 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
37e0e0a4da
commit
724b37ae97
@ -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>
|
||||
|
@ -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,8 +755,22 @@ class acp_permission_roles
|
||||
|
||||
// Get role assignments
|
||||
$hold_ary = $auth_admin->get_role_mask($role_id);
|
||||
|
||||
// Remove role from users and groups
|
||||
|
||||
// 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, 0, false);
|
||||
}
|
||||
|
||||
if (isset($forum_ary['groups']))
|
||||
{
|
||||
$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);
|
||||
@ -719,20 +779,6 @@ class acp_permission_roles
|
||||
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);
|
||||
}
|
||||
|
||||
if (isset($forum_ary['groups']))
|
||||
{
|
||||
$auth_admin->acl_set('group', $forum_id, $forum_ary['users'], $auth_settings);
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.',
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user