|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
* @version $Id: acp_permissions.php 8710 2008-07-29 13:35:49Z acydburn $
|
|
|
4c79b5 |
* @copyright (c) 2005 phpBB Group
|
|
|
4c79b5 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @ignore
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
if (!defined('IN_PHPBB'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
exit;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
class acp_permissions
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
var $u_action;
|
|
|
4c79b5 |
var $permission_dropdown;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function main($id, $mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $user, $auth, $template, $cache;
|
|
|
4c79b5 |
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
4c79b5 |
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$auth_admin = new auth_admin();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user->add_lang('acp/permissions');
|
|
|
4c79b5 |
add_permission_language();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->tpl_name = 'acp_permissions';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Trace has other vars
|
|
|
4c79b5 |
if ($mode == 'trace')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_id = request_var('u', 0);
|
|
|
4c79b5 |
$forum_id = request_var('f', 0);
|
|
|
4c79b5 |
$permission = request_var('auth', '');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->tpl_name = 'permission_trace';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $user->lang['acl_' . $permission]['lang']);
|
|
|
4c79b5 |
$this->permission_trace($user_id, $forum_id, $permission);
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
trigger_error('NO_MODE', E_USER_ERROR);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Set some vars
|
|
|
4c79b5 |
$action = request_var('action', array('' => 0));
|
|
|
4c79b5 |
$action = key($action);
|
|
|
4c79b5 |
$action = (isset($_POST['psubmit'])) ? 'apply_permissions' : $action;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$all_forums = request_var('all_forums', 0);
|
|
|
4c79b5 |
$subforum_id = request_var('subforum_id', 0);
|
|
|
4c79b5 |
$forum_id = request_var('forum_id', array(0));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$username = request_var('username', array(''), true);
|
|
|
4c79b5 |
$usernames = request_var('usernames', '', true);
|
|
|
4c79b5 |
$user_id = request_var('user_id', array(0));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$group_id = request_var('group_id', array(0));
|
|
|
4c79b5 |
$select_all_groups = request_var('select_all_groups', 0);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$form_name = 'acp_permissions';
|
|
|
4c79b5 |
add_form_key($form_name);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen)
|
|
|
4c79b5 |
if ($select_all_groups)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Add default groups to selection
|
|
|
4c79b5 |
$sql_and = (!$config['coppa_enable']) ? " AND group_name <> 'REGISTERED_COPPA'" : '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT group_id
|
|
|
4c79b5 |
FROM ' . GROUPS_TABLE . '
|
|
|
4c79b5 |
WHERE group_type = ' . GROUP_SPECIAL . "
|
|
|
4c79b5 |
$sql_and";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$group_id[] = $row['group_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Map usernames to ids and vice versa
|
|
|
4c79b5 |
if ($usernames)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$username = explode("\n", $usernames);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
unset($usernames);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($username) && !sizeof($user_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_get_id_name($user_id, $username);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!sizeof($user_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
unset($username);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Build forum ids (of all forums are checked or subforum listing used)
|
|
|
4c79b5 |
if ($all_forums)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT forum_id
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
ORDER BY left_id';
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_id = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id[] = (int) $row['forum_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($subforum_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id = array();
|
|
|
4c79b5 |
foreach (get_forum_branch($subforum_id, 'children') as $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id[] = (int) $row['forum_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Define some common variables for every mode
|
|
|
4c79b5 |
$error = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$permission_scope = (strpos($mode, '_global') !== false) ? 'global' : 'local';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Showing introductionary page?
|
|
|
4c79b5 |
if ($mode == 'intro')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->page_title = 'ACP_PERMISSIONS';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_INTRO' => true)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'setting_user_global':
|
|
|
4c79b5 |
case 'setting_group_global':
|
|
|
4c79b5 |
$this->permission_dropdown = array('u_', 'm_', 'a_');
|
|
|
4c79b5 |
$permission_victim = ($mode == 'setting_user_global') ? array('user') : array('group');
|
|
|
4c79b5 |
$this->page_title = ($mode == 'setting_user_global') ? 'ACP_USERS_PERMISSIONS' : 'ACP_GROUPS_PERMISSIONS';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'setting_user_local':
|
|
|
4c79b5 |
case 'setting_group_local':
|
|
|
4c79b5 |
$this->permission_dropdown = array('f_', 'm_');
|
|
|
4c79b5 |
$permission_victim = ($mode == 'setting_user_local') ? array('user', 'forums') : array('group', 'forums');
|
|
|
4c79b5 |
$this->page_title = ($mode == 'setting_user_local') ? 'ACP_USERS_FORUM_PERMISSIONS' : 'ACP_GROUPS_FORUM_PERMISSIONS';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'setting_admin_global':
|
|
|
4c79b5 |
case 'setting_mod_global':
|
|
|
4c79b5 |
$this->permission_dropdown = (strpos($mode, '_admin_') !== false) ? array('a_') : array('m_');
|
|
|
4c79b5 |
$permission_victim = array('usergroup');
|
|
|
4c79b5 |
$this->page_title = ($mode == 'setting_admin_global') ? 'ACP_ADMINISTRATORS' : 'ACP_GLOBAL_MODERATORS';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'setting_mod_local':
|
|
|
4c79b5 |
case 'setting_forum_local':
|
|
|
4c79b5 |
$this->permission_dropdown = ($mode == 'setting_mod_local') ? array('m_') : array('f_');
|
|
|
4c79b5 |
$permission_victim = array('forums', 'usergroup');
|
|
|
4c79b5 |
$this->page_title = ($mode == 'setting_mod_local') ? 'ACP_FORUM_MODERATORS' : 'ACP_FORUM_PERMISSIONS';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'view_admin_global':
|
|
|
4c79b5 |
case 'view_user_global':
|
|
|
4c79b5 |
case 'view_mod_global':
|
|
|
4c79b5 |
$this->permission_dropdown = ($mode == 'view_admin_global') ? array('a_') : (($mode == 'view_user_global') ? array('u_') : array('m_'));
|
|
|
4c79b5 |
$permission_victim = array('usergroup_view');
|
|
|
4c79b5 |
$this->page_title = ($mode == 'view_admin_global') ? 'ACP_VIEW_ADMIN_PERMISSIONS' : (($mode == 'view_user_global') ? 'ACP_VIEW_USER_PERMISSIONS' : 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS');
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'view_mod_local':
|
|
|
4c79b5 |
case 'view_forum_local':
|
|
|
4c79b5 |
$this->permission_dropdown = ($mode == 'view_mod_local') ? array('m_') : array('f_');
|
|
|
4c79b5 |
$permission_victim = array('forums', 'usergroup_view');
|
|
|
4c79b5 |
$this->page_title = ($mode == 'view_mod_local') ? 'ACP_VIEW_FORUM_MOD_PERMISSIONS' : 'ACP_VIEW_FORUM_PERMISSIONS';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
default:
|
|
|
4c79b5 |
trigger_error('NO_MODE', E_USER_ERROR);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'L_TITLE' => $user->lang[$this->page_title],
|
|
|
4c79b5 |
'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'])
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Get permission type
|
|
|
4c79b5 |
$permission_type = request_var('type', $this->permission_dropdown[0]);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!in_array($permission_type, $this->permission_dropdown))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['WRONG_PERMISSION_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Handle actions
|
|
|
4c79b5 |
if (strpos($mode, 'setting_') === 0 && $action)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($action)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'delete':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!check_form_key($form_name))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
// All users/groups selected?
|
|
|
4c79b5 |
$all_users = (isset($_POST['all_users'])) ? true : false;
|
|
|
4c79b5 |
$all_groups = (isset($_POST['all_groups'])) ? true : false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($all_users || $all_groups)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($all_users && sizeof($items['user_ids']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_id = $items['user_ids'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($all_groups && sizeof($items['group_ids']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$group_id = $items['group_ids'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($user_id) || sizeof($group_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'apply_permissions':
|
|
|
4c79b5 |
if (!isset($_POST['setting']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if (!check_form_key($form_name))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->set_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'apply_all_permissions':
|
|
|
4c79b5 |
if (!isset($_POST['setting']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if (!check_form_key($form_name))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->set_all_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Setting permissions screen
|
|
|
4c79b5 |
$s_hidden_fields = build_hidden_fields(array(
|
|
|
4c79b5 |
'user_id' => $user_id,
|
|
|
4c79b5 |
'group_id' => $group_id,
|
|
|
4c79b5 |
'forum_id' => $forum_id,
|
|
|
4c79b5 |
'type' => $permission_type)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Go through the screens/options needed and present them in correct order
|
|
|
4c79b5 |
foreach ($permission_victim as $victim)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($victim)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'forum_dropdown':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($forum_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->check_existence('forum', $forum_id);
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_SELECT_FORUM' => true,
|
|
|
4c79b5 |
'S_FORUM_OPTIONS' => make_forum_select(false, false, true, false, false))
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'forums':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($forum_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->check_existence('forum', $forum_id);
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_list = make_forum_select(false, false, true, false, false, false, true);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Build forum options
|
|
|
4c79b5 |
$s_forum_options = '';
|
|
|
4c79b5 |
foreach ($forum_list as $f_id => $f_row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Build subforum options
|
|
|
4c79b5 |
$s_subforum_options = $this->build_subforum_options($forum_list);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_SELECT_FORUM' => true,
|
|
|
4c79b5 |
'S_FORUM_OPTIONS' => $s_forum_options,
|
|
|
4c79b5 |
'S_SUBFORUM_OPTIONS' => $s_subforum_options,
|
|
|
4c79b5 |
'S_FORUM_ALL' => true,
|
|
|
4c79b5 |
'S_FORUM_MULTIPLE' => true)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'user':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($user_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->check_existence('user', $user_id);
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_SELECT_USER' => true,
|
|
|
4c79b5 |
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_victim&field=username&select_single=true'),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'group':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($group_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->check_existence('group', $group_id);
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_SELECT_GROUP' => true,
|
|
|
4c79b5 |
'S_GROUP_OPTIONS' => group_select_options(false, false, false), // Show all groups
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'usergroup':
|
|
|
4c79b5 |
case 'usergroup_view':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$all_users = (isset($_POST['all_users'])) ? true : false;
|
|
|
4c79b5 |
$all_groups = (isset($_POST['all_groups'])) ? true : false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ((sizeof($user_id) && !$all_users) || (sizeof($group_id) && !$all_groups))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (sizeof($user_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->check_existence('user', $user_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($group_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->check_existence('group', $group_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Now we check the users... because the "all"-selection is different here (all defined users/groups)
|
|
|
4c79b5 |
$items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($all_users && sizeof($items['user_ids']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_id = $items['user_ids'];
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($all_groups && sizeof($items['group_ids']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$group_id = $items['group_ids'];
|
|
|
4c79b5 |
continue 2;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_SELECT_USERGROUP' => ($victim == 'usergroup') ? true : false,
|
|
|
4c79b5 |
'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false,
|
|
|
4c79b5 |
'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'],
|
|
|
4c79b5 |
'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'],
|
|
|
4c79b5 |
'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], false), // Show all groups
|
|
|
4c79b5 |
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=add_user&field=username&select_single=true'),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// The S_ALLOW_SELECT parameter below is a measure to lower memory usage.
|
|
|
4c79b5 |
// If there are more than 5 forums selected the admin is not able to select all users/groups too.
|
|
|
4c79b5 |
// We need to see if the number of forums can be increased or need to be decreased.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action,
|
|
|
4c79b5 |
'ANONYMOUS_USER_ID' => ANONYMOUS,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_SELECT_VICTIM' => true,
|
|
|
4c79b5 |
'S_ALLOW_ALL_SELECT' => (sizeof($forum_id) > 5) ? false : true,
|
|
|
4c79b5 |
'S_CAN_SELECT_USER' => ($auth->acl_get('a_authusers')) ? true : false,
|
|
|
4c79b5 |
'S_CAN_SELECT_GROUP' => ($auth->acl_get('a_authgroups')) ? true : false,
|
|
|
4c79b5 |
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Let the forum names being displayed
|
|
|
4c79b5 |
if (sizeof($forum_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT forum_name
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('forum_id', $forum_id) . '
|
|
|
4c79b5 |
ORDER BY left_id ASC';
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_names = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_names[] = $row['forum_name'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false,
|
|
|
4c79b5 |
'FORUM_NAMES' => implode(', ', $forum_names))
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do not allow forum_ids being set and no other setting defined (will bog down the server too much)
|
|
|
4c79b5 |
if (sizeof($forum_id) && !sizeof($user_id) && !sizeof($group_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false,
|
|
|
4c79b5 |
'L_PERMISSION_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)],
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action,
|
|
|
4c79b5 |
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (strpos($mode, 'setting_') === 0)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_SETTING_PERMISSIONS' => true)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$hold_ary = $auth_admin->get_mask('set', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO);
|
|
|
4c79b5 |
$auth_admin->display_mask('set', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_VIEWING_PERMISSIONS' => true)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$hold_ary = $auth_admin->get_mask('view', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER);
|
|
|
4c79b5 |
$auth_admin->display_mask('view', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Build +subforum options
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function build_subforum_options($forum_list)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_options = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_list = array_merge($forum_list);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($forum_list as $key => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($row['disabled'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_options .= '<option value="' . $row['forum_id'] . '"' . (($row['selected']) ? ' selected="selected"' : '') . '>' . $row['padding'] . $row['forum_name'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We check if a branch is there...
|
|
|
4c79b5 |
$branch_there = false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach (array_slice($forum_list, $key + 1) as $temp_row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$branch_there = true;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($branch_there)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_options .= ' [' . $user->lang['PLUS_SUBFORUMS'] . ']';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_options .= '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $s_options;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Build dropdown field for changing permission types
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function build_permission_dropdown($options, $default_option, $permission_scope)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $auth;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_dropdown_options = '';
|
|
|
4c79b5 |
foreach ($options as $setting)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!$auth->acl_get('a_' . str_replace('_', '', $setting) . 'auth'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$selected = ($setting == $default_option) ? ' selected="selected"' : '';
|
|
|
4c79b5 |
$l_setting = (isset($user->lang['permission_type'][$permission_scope][$setting])) ? $user->lang['permission_type'][$permission_scope][$setting] : $user->lang['permission_type'][$setting];
|
|
|
4c79b5 |
$s_dropdown_options .= '<option value="' . $setting . '"' . $selected . '>' . $l_setting . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $s_dropdown_options;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Check if selected items exist. Remove not found ids and if empty return error.
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function check_existence($mode, &$ids)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'user':
|
|
|
4c79b5 |
$table = USERS_TABLE;
|
|
|
4c79b5 |
$sql_id = 'user_id';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'group':
|
|
|
4c79b5 |
$table = GROUPS_TABLE;
|
|
|
4c79b5 |
$sql_id = 'group_id';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'forum':
|
|
|
4c79b5 |
$table = FORUMS_TABLE;
|
|
|
4c79b5 |
$sql_id = 'forum_id';
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = "SELECT $sql_id
|
|
|
4c79b5 |
FROM $table
|
|
|
4c79b5 |
WHERE " . $db->sql_in_set($sql_id, $ids);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$ids = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$ids[] = (int) $row[$sql_id];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!sizeof($ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['SELECTED_' . strtoupper($mode) . '_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Apply permissions
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $auth;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$psubmit = request_var('psubmit', array(0 => array(0 => 0)));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// User or group to be set?
|
|
|
4c79b5 |
$ug_type = (sizeof($user_id)) ? 'user' : 'group';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Check the permission setting again
|
|
|
4c79b5 |
if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$ug_id = $forum_id = 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We loop through the auth settings defined in our submit
|
|
|
4c79b5 |
list($ug_id, ) = each($psubmit);
|
|
|
4c79b5 |
list($forum_id, ) = each($psubmit[$ug_id]);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (empty($_POST['setting']) || empty($_POST['setting'][$ug_id]) || empty($_POST['setting'][$ug_id][$forum_id]) || !is_array($_POST['setting'][$ug_id][$forum_id]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error('WRONG_PERMISSION_SETTING_FORMAT', E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We obtain and check $_POST['setting'][$ug_id][$forum_id] directly and not using request_var() because request_var()
|
|
|
4c79b5 |
// currently does not support the amount of dimensions required. ;)
|
|
|
4c79b5 |
// $auth_settings = request_var('setting', array(0 => array(0 => array('' => 0))));
|
|
|
4c79b5 |
$auth_settings = array_map('intval', $_POST['setting'][$ug_id][$forum_id]);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do we have a role we want to set?
|
|
|
4c79b5 |
$assigned_role = (isset($_POST['role'][$ug_id][$forum_id])) ? (int) $_POST['role'][$ug_id][$forum_id] : 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do the admin want to set these permissions to other items too?
|
|
|
4c79b5 |
$inherit = request_var('inherit', array(0 => array(0)));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$ug_id = array($ug_id);
|
|
|
4c79b5 |
$forum_id = array($forum_id);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($inherit))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($inherit as $_ug_id => $forum_id_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Inherit users/groups?
|
|
|
4c79b5 |
if (!in_array($_ug_id, $ug_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$ug_id[] = $_ug_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Inherit forums?
|
|
|
4c79b5 |
$forum_id = array_merge($forum_id, array_keys($forum_id_ary));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_id = array_unique($forum_id);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If the auth settings differ from the assigned role, then do not set a role...
|
|
|
4c79b5 |
if ($assigned_role)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!$this->check_assigned_role($assigned_role, $auth_settings))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$assigned_role = 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Update the permission set...
|
|
|
4c79b5 |
$auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_settings, $assigned_role);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do we need to recache the moderator lists?
|
|
|
4c79b5 |
if ($permission_type == 'm_')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
cache_moderators();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Remove users who are now moderators or admins from everyones foes list
|
|
|
4c79b5 |
if ($permission_type == 'm_' || $permission_type == 'a_')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
update_foes($group_id, $user_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Apply all permissions
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $auth;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// User or group to be set?
|
|
|
4c79b5 |
$ug_type = (sizeof($user_id)) ? 'user' : 'group';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Check the permission setting again
|
|
|
4c79b5 |
if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$auth_settings = (isset($_POST['setting'])) ? $_POST['setting'] : array();
|
|
|
4c79b5 |
$auth_roles = (isset($_POST['role'])) ? $_POST['role'] : array();
|
|
|
4c79b5 |
$ug_ids = $forum_ids = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We need to go through the auth settings
|
|
|
4c79b5 |
foreach ($auth_settings as $ug_id => $forum_auth_row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$ug_id = (int) $ug_id;
|
|
|
4c79b5 |
$ug_ids[] = $ug_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($forum_auth_row as $forum_id => $auth_options)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id = (int) $forum_id;
|
|
|
4c79b5 |
$forum_ids[] = $forum_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Check role...
|
|
|
4c79b5 |
$assigned_role = (isset($auth_roles[$ug_id][$forum_id])) ? (int) $auth_roles[$ug_id][$forum_id] : 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If the auth settings differ from the assigned role, then do not set a role...
|
|
|
4c79b5 |
if ($assigned_role)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!$this->check_assigned_role($assigned_role, $auth_options))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$assigned_role = 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Update the permission set...
|
|
|
4c79b5 |
$auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_options, $assigned_role, false);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$auth_admin->acl_clear_prefetch();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do we need to recache the moderator lists?
|
|
|
4c79b5 |
if ($permission_type == 'm_')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
cache_moderators();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Remove users who are now moderators or admins from everyones foes list
|
|
|
4c79b5 |
if ($permission_type == 'm_' || $permission_type == 'a_')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
update_foes($group_id, $user_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Compare auth settings with auth settings from role
|
|
|
4c79b5 |
* returns false if they differ, true if they are equal
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function check_assigned_role($role_id, &$auth_settings)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT o.auth_option, r.auth_setting
|
|
|
4c79b5 |
FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r
|
|
|
4c79b5 |
WHERE o.auth_option_id = r.auth_option_id
|
|
|
4c79b5 |
AND r.role_id = ' . $role_id;
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$test_auth_settings = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$test_auth_settings[$row['auth_option']] = $row['auth_setting'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// We need to add any ACL_NO setting from auth_settings to compare correctly
|
|
|
4c79b5 |
foreach ($auth_settings as $option => $setting)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($setting == ACL_NO)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$test_auth_settings[$option] = $setting;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof(array_diff_assoc($auth_settings, $test_auth_settings)))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Remove permissions
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function remove_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id, &$forum_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $db, $auth;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// User or group to be set?
|
|
|
4c79b5 |
$ug_type = (sizeof($user_id)) ? 'user' : 'group';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Check the permission setting again
|
|
|
4c79b5 |
if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$auth_admin->acl_delete($ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : false), $permission_type);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do we need to recache the moderator lists?
|
|
|
4c79b5 |
if ($permission_type == 'm_')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
cache_moderators();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0)));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Log permission changes
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function log_action($mode, $action, $permission_type, $ug_type, $ug_id, $forum_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!is_array($ug_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$ug_id = array($ug_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!is_array($forum_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id = array($forum_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Logging ... first grab user or groupnames ...
|
|
|
4c79b5 |
$sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE ';
|
|
|
4c79b5 |
$sql .= $db->sql_in_set(($ug_type == 'group') ? 'group_id' : 'user_id', array_map('intval', $ug_id));
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$l_ug_list = '';
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '' . $user->lang['G_' . $row['name']] . '' : $row['name']);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$mode = str_replace('setting_', '', $mode);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($forum_id[0] == 0)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
add_log('admin', 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), $l_ug_list);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Grab the forum details if non-zero forum_id
|
|
|
4c79b5 |
$sql = 'SELECT forum_name
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('forum_id', $forum_id);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$l_forum_list = '';
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
add_log('admin', 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), $l_forum_list, $l_ug_list);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Display a complete trace tree for the selected permission to determine where settings are set/unset
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function permission_trace($user_id, $forum_id, $permission)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $template, $user, $auth;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($user_id != $user->data['user_id'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT user_id, username, user_permissions, user_type
|
|
|
4c79b5 |
FROM ' . USERS_TABLE . '
|
|
|
4c79b5 |
WHERE user_id = ' . $user_id;
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
$userdata = $db->sql_fetchrow($result);
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$userdata = $user->data;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!$userdata)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error('NO_USERS', E_USER_ERROR);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_name = false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($forum_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT forum_name
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . "
|
|
|
4c79b5 |
WHERE forum_id = $forum_id";
|
|
|
4c79b5 |
$result = $db->sql_query($sql, 3600);
|
|
|
4c79b5 |
$forum_name = $db->sql_fetchfield('forum_name');
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$back = request_var('back', 0);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'PERMISSION' => $user->lang['acl_' . $permission]['lang'],
|
|
|
4c79b5 |
'PERMISSION_USERNAME' => $userdata['username'],
|
|
|
4c79b5 |
'FORUM_NAME' => $forum_name,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_GLOBAL_TRACE' => ($forum_id) ? false : true,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'U_BACK' => ($back) ? build_url(array('f', 'back')) . "&f=$back" : '')
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_block_vars('trace', array(
|
|
|
4c79b5 |
'WHO' => $user->lang['DEFAULT'],
|
|
|
4c79b5 |
'INFORMATION' => $user->lang['TRACE_DEFAULT'],
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_SETTING_NO' => true,
|
|
|
4c79b5 |
'S_TOTAL_NO' => true)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT DISTINCT g.group_name, g.group_id, g.group_type
|
|
|
4c79b5 |
FROM ' . GROUPS_TABLE . ' g
|
|
|
4c79b5 |
LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id)
|
|
|
4c79b5 |
WHERE ug.user_id = ' . $user_id . '
|
|
|
4c79b5 |
AND ug.user_pending = 0
|
|
|
4c79b5 |
ORDER BY g.group_type DESC, g.group_id DESC';
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$groups = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$groups[$row['group_id']] = array(
|
|
|
4c79b5 |
'auth_setting' => ACL_NO,
|
|
|
4c79b5 |
'group_name' => ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$total = ACL_NO;
|
|
|
4c79b5 |
$add_key = (($forum_id) ? '_LOCAL' : '');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($groups))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Get group auth settings
|
|
|
4c79b5 |
$hold_ary = $auth->acl_group_raw_data(array_keys($groups), $permission, $forum_id);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($hold_ary as $group_id => $forum_ary)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$groups[$group_id]['auth_setting'] = $hold_ary[$group_id][$forum_id][$permission];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
unset($hold_ary);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($groups as $id => $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
switch ($row['auth_setting'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case ACL_NO:
|
|
|
4c79b5 |
$information = $user->lang['TRACE_GROUP_NO' . $add_key];
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case ACL_YES:
|
|
|
4c79b5 |
$information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]);
|
|
|
4c79b5 |
$total = ($total == ACL_NO) ? ACL_YES : $total;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case ACL_NEVER:
|
|
|
4c79b5 |
$information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]);
|
|
|
4c79b5 |
$total = ACL_NEVER;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_block_vars('trace', array(
|
|
|
4c79b5 |
'WHO' => $row['group_name'],
|
|
|
4c79b5 |
'INFORMATION' => $information,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_SETTING_NO' => ($row['auth_setting'] == ACL_NO) ? true : false,
|
|
|
4c79b5 |
'S_SETTING_YES' => ($row['auth_setting'] == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_SETTING_NEVER' => ($row['auth_setting'] == ACL_NEVER) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_NO' => ($total == ACL_NO) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_YES' => ($total == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Get user specific permission... globally or for this forum
|
|
|
4c79b5 |
$hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id);
|
|
|
4c79b5 |
$auth_setting = (!sizeof($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($auth_setting)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case ACL_NO:
|
|
|
4c79b5 |
$information = ($total == ACL_NO) ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key];
|
|
|
4c79b5 |
$total = ($total == ACL_NO) ? ACL_NEVER : $total;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case ACL_YES:
|
|
|
4c79b5 |
$information = ($total == ACL_YES) ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]);
|
|
|
4c79b5 |
$total = ($total == ACL_NO) ? ACL_YES : $total;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case ACL_NEVER:
|
|
|
4c79b5 |
$information = ($total == ACL_YES) ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]);
|
|
|
4c79b5 |
$total = ACL_NEVER;
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_block_vars('trace', array(
|
|
|
4c79b5 |
'WHO' => $userdata['username'],
|
|
|
4c79b5 |
'INFORMATION' => $information,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false,
|
|
|
4c79b5 |
'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_NO' => false,
|
|
|
4c79b5 |
'S_TOTAL_YES' => ($total == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($forum_id != 0 && isset($auth->acl_options['global'][$permission]))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($user_id != $user->data['user_id'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth2 = new auth();
|
|
|
4c79b5 |
$auth2->acl($userdata);
|
|
|
4c79b5 |
$auth_setting = $auth2->acl_get($permission);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$auth_setting = $auth->acl_get($permission);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($auth_setting)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$information = ($total == ACL_YES) ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER'];
|
|
|
4c79b5 |
$total = ACL_YES;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$information = $user->lang['TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If there is no auth information we do not need to worry the user by showing non-relevant data.
|
|
|
4c79b5 |
if ($auth_setting)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('trace', array(
|
|
|
4c79b5 |
'WHO' => sprintf($user->lang['TRACE_GLOBAL_SETTING'], $userdata['username']),
|
|
|
4c79b5 |
'INFORMATION' => sprintf($information, '", ''),
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_SETTING_NO' => false,
|
|
|
4c79b5 |
'S_SETTING_YES' => $auth_setting,
|
|
|
4c79b5 |
'S_SETTING_NEVER' => !$auth_setting,
|
|
|
4c79b5 |
'S_TOTAL_NO' => false,
|
|
|
4c79b5 |
'S_TOTAL_YES' => ($total == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Take founder status into account, overwriting the default values
|
|
|
4c79b5 |
if ($userdata['user_type'] == USER_FOUNDER && strpos($permission, 'a_') === 0)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('trace', array(
|
|
|
4c79b5 |
'WHO' => $userdata['username'],
|
|
|
4c79b5 |
'INFORMATION' => $user->lang['TRACE_USER_FOUNDER'],
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false,
|
|
|
4c79b5 |
'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false,
|
|
|
4c79b5 |
'S_TOTAL_NO' => false,
|
|
|
4c79b5 |
'S_TOTAL_YES' => true,
|
|
|
4c79b5 |
'S_TOTAL_NEVER' => false)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$total = ACL_YES;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Total value...
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_RESULT_NO' => ($total == ACL_NO) ? true : false,
|
|
|
4c79b5 |
'S_RESULT_YES' => ($total == ACL_YES) ? true : false,
|
|
|
4c79b5 |
'S_RESULT_NEVER' => ($total == ACL_NEVER) ? true : false,
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Get already assigned users/groups
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $user;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((sizeof($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles
|
|
|
4c79b5 |
$option_ids = $role_ids = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT auth_option_id
|
|
|
4c79b5 |
FROM ' . ACL_OPTIONS_TABLE . '
|
|
|
4c79b5 |
WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->any_char);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$option_ids[] = (int) $row['auth_option_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($option_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT DISTINCT role_id
|
|
|
4c79b5 |
FROM ' . ACL_ROLES_DATA_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('auth_option_id', $option_ids);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$role_ids[] = (int) $row['role_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($option_ids) && sizeof($role_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Not ideal, due to the filesort, non-use of indexes, etc.
|
|
|
4c79b5 |
$sql = 'SELECT DISTINCT u.user_id, u.username, u.username_clean, u.user_regdate
|
|
|
4c79b5 |
FROM ' . USERS_TABLE . ' u, ' . ACL_USERS_TABLE . " a
|
|
|
4c79b5 |
WHERE u.user_id = a.user_id
|
|
|
4c79b5 |
$sql_forum_id
|
|
|
4c79b5 |
$sql_where
|
|
|
4c79b5 |
ORDER BY u.username_clean, u.user_regdate ASC";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_defined_user_options = '';
|
|
|
4c79b5 |
$defined_user_ids = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>';
|
|
|
4c79b5 |
$defined_user_ids[] = $row['user_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id
|
|
|
4c79b5 |
FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a
|
|
|
4c79b5 |
WHERE g.group_id = a.group_id
|
|
|
4c79b5 |
$sql_forum_id
|
|
|
4c79b5 |
$sql_where
|
|
|
4c79b5 |
ORDER BY g.group_type DESC, g.group_name ASC";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_defined_group_options = '';
|
|
|
4c79b5 |
$defined_group_ids = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_defined_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
|
|
|
4c79b5 |
$defined_group_ids[] = $row['group_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return array(
|
|
|
4c79b5 |
'group_ids' => $defined_group_ids,
|
|
|
4c79b5 |
'group_ids_options' => $s_defined_group_options,
|
|
|
4c79b5 |
'user_ids' => $defined_user_ids,
|
|
|
4c79b5 |
'user_ids_options' => $s_defined_user_options
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|