acl_get('a_auth')) ? $filename . $SID . '&mode=forums' : '';
$module['Forums']['MODERATORS'] = ($auth->acl_get('a_authmods')) ? $filename . $SID . '&mode=moderators' : '';
$module['Forums']['SUPER_MODERATORS'] = ($auth->acl_get('a_authmods')) ? $filename . $SID . '&mode=supermoderators' : '';
$module['General']['ADMINISTRATORS'] = ($auth->acl_get('a_authadmins')) ? $filename . $SID . '&mode=administrators' : '';
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx);
require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// Define some vars
if (isset($_REQUEST['f']))
{
$forum_id = intval($_REQUEST['f']);
$forum_sql = " WHERE forum_id = $forum_id";
}
else
{
$forum_id = 0;
$forum_sql = '';
}
$mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : '';
// Start program proper
switch ($mode)
{
case 'forums':
$l_title = $user->lang['PERMISSIONS'];
$l_title_explain = $user->lang['PERMISSIONS_EXPLAIN'];
$which_acl = 'a_auth';
$type_sql = 'f';
break;
case 'moderators':
$l_title = $user->lang['MODERATORS'];
$l_title_explain = $user->lang['MODERATORS_EXPLAIN'];
$which_acl = 'a_authmods';
$type_sql = 'm';
break;
case 'supermoderators':
$l_title = $user->lang['SUPER_MODERATORS'];
$l_title_explain = $user->lang['SUPER_MODERATORS_EXPLAIN'];
$which_acl = 'a_authmods';
$type_sql = 'm';
break;
case 'administrators':
$l_title = $user->lang['ADMINISTRATORS'];
$l_title_explain = $user->lang['ADMINISTRATORS_EXPLAIN'];
$which_acl = 'a_authadmins';
$type_sql = 'a';
break;
}
// Permission check
if (!$auth->acl_get($which_acl))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Call update or delete, both can take multiple user/group
// ids. Additionally inheritance is handled (by the auth API)
if (isset($_POST['update']))
{
$auth_admin = new auth_admin();
// Admin wants subforums to inherit permissions ... so handle this
if (!empty($_POST['inherit']))
{
array_push($_POST['inherit'], $forum_id);
$forum_id = $_POST['inherit'];
}
foreach ($_POST['entries'] as $id)
{
$auth_admin->acl_set($_POST['type'], $forum_id, $id, $_POST['option']);
}
cache_moderators();
trigger_error('Permissions updated successfully');
}
else if (isset($_POST['delete']))
{
$auth_admin = new auth_admin();
$option_ids = false;
if (!empty($_POST['option']))
{
$sql = "SELECT auth_option_id
FROM " . ACL_OPTIONS_TABLE . "
WHERE auth_value LIKE '" . $_POST['option'] . "_%'";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$option_ids = array();
do
{
$option_ids[] = $row['auth_option_id'];
}
while($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
}
foreach ($_POST['entries'] as $id)
{
$auth_admin->acl_delete($_POST['type'], $forum_id, $id, $option_ids);
}
cache_moderators();
trigger_error('Permissions updated successfully');
}
else if (isset($_POST['presetsave']))
{
$holding_ary = array();
foreach ($_POST['option'] as $acl_option => $allow_deny)
{
switch ($allow_deny)
{
case ACL_ALLOW:
$holding_ary['allow'][] = $acl_option;
break;
case ACL_DENY:
$holding_ary['deny'][] = $acl_option;
break;
case ACL_INHERIT:
$holding_ary['inherit'][] = $acl_option;
break;
}
}
$sql = array(
'preset_user_id' => $user->data['user_id'],
'preset_type' => $type_sql,
'preset_data' => $db->sql_escape(serialize($holding_ary))
);
if (!empty($_POST['presetname']))
{
$sql['preset_name'] = $db->sql_escape($_POST['presetname']);
}
if (!empty($_POST['presetname']) || $_POST['presetoption'] != -1)
{
$sql = ($_POST['presetoption'] == -1) ? 'INSERT INTO ' . ACL_PRESETS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql) : 'UPDATE ' . ACL_PRESETS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql) . ' WHERE preset_id =' . $_POST['presetoption'];
$db->sql_query($sql);
}
}
else if (isset($_POST['presetdel']))
{
if (!empty($_POST['presetoption']))
{
$sql = "DELETE FROM " . ACL_PRESETS_TABLE . "
WHERE preset_id = " . intval($_POST['presetoption']);
$db->sql_query($sql);
}
}
// Get required information, either all forums if no id was
// specified or just the requsted if it was
if (!empty($forum_id) || $mode == 'administrators' || $mode == 'supermoderators')
{
// Clear some vars, grab some info if relevant ...
$s_hidden_fields = '';
if (!empty($forum_id))
{
$sql = "SELECT forum_name, parent_id
FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
$result = $db->sql_query($sql);
$forum_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$l_title .= ' : ' . $forum_info['forum_name'] . '';
}
// Generate header
page_header($l_title);
?>
sql_query($sql);
$group_list = '';
while ($row = $db->sql_fetchrow($result))
{
$group_list .= '';
}
$db->sql_freeresult($result);
if (empty($_POST['advanced']) || empty($_POST['entries']))
{
?>
lang['Users']; ?> |
lang['Groups']; ?> |
|
|
|
|
1' : '';
$sql = "SELECT auth_option_id, auth_value
FROM " . ACL_OPTIONS_TABLE . "
WHERE auth_value LIKE '" . $type_sql . "_%'
AND auth_value <> '" . $type_sql . "_'
$founder_sql";
$result = $db->sql_query($sql);
$auth_options = array();
while ($row = $db->sql_fetchrow($result))
{
$auth_options[] = $row;
}
$db->sql_freeresult($result);
if ($_POST['type'] == 'user' && !empty($_POST['new']))
{
$_POST['entries'] = explode("\n", $_POST['entries']);
}
$where_sql = '';
foreach ($_POST['entries'] as $value)
{
$where_sql .= (($where_sql != '') ? ', ' : '') . (($_POST['type'] == 'user' && !empty($_POST['new'])) ? '\'' . $value . '\'' : intval($value));
}
switch ($_POST['type'])
{
case 'group':
$l_type = 'Group';
$sql = (empty($_POST['new'])) ? "SELECT g.group_id AS id, g.group_name AS name, o.auth_value, a.auth_allow_deny FROM " . GROUPS_TABLE . " g, " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id $forum_sql AND g.group_id = a.group_id AND g.group_id IN ($where_sql) ORDER BY g.group_name ASC" : "SELECT group_id AS id, group_name AS name FROM " . GROUPS_TABLE . " WHERE group_id IN ($where_sql) ORDER BY group_name ASC";
break;
case 'user':
$l_type = 'User';
$sql = (empty($_POST['new'])) ? "SELECT u.user_id AS id, u.username AS name, u.user_founder, o.auth_value, a.auth_allow_deny FROM " . USERS_TABLE . " u, " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id $forum_sql AND u.user_id = a.user_id AND u.user_id IN ($where_sql) ORDER BY u.username, u.user_regdate ASC" : "SELECT user_id AS id, username AS name, user_founder FROM " . USERS_TABLE . " WHERE username IN ($where_sql) ORDER BY username, user_regdate ASC";
break;
}
$result = $db->sql_query($sql);
$ug = '';;
$ug_hidden = '';
$auth = array();
while ($row = $db->sql_fetchrow($result))
{
$ug_test = (!empty($user->lang[$row['name']])) ? $user->lang[$row['name']] : $row['name'];
$ug .= (!strstr($ug, $ug_test)) ? $ug_test . "\n" : '';
$ug_test = '';
$ug_hidden .= (!strstr($ug_hidden, $ug_test)) ? $ug_test : '';
$auth[$row['auth_value']] = (isset($auth_group[$row['auth_value']])) ? min($auth_group[$row['auth_value']], $row['auth_allow_deny']) : $row['auth_allow_deny'];
}
$db->sql_freeresult($result);
// Now we'll build a list of preset options ...
$preset_options = $preset_js = $preset_update_options = '';
$holding = array();
// Do we have a parent forum? If so offer option
// to inherit from that
if ($forum_info['parent_id'] != 0)
{
switch ($_POST['type'])
{
case 'group':
$sql = "SELECT o.auth_value, a.auth_allow_deny FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id AND a.forum_id = " . $forum_info['parent_id'] . " AND a.group_id IN ($where_sql)";
break;
case 'user':
$sql = "SELECT o.auth_value, a.auth_allow_deny FROM " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " o WHERE o.auth_value LIKE '" . $type_sql . "_%' AND a.auth_option_id = o.auth_option_id AND a.forum_id = " . $forum_info['parent_id'] . " AND a.user_id IN ($where_sql)";
break;
}
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{
switch ($row['auth_allow_deny'])
{
case ACL_ALLOW:
$holding['allow'] .= $row['auth_value'] . ', ';
break;
case ACL_DENY:
$holding['deny'] .= $row['auth_value'] . ', ';
break;
case ACL_INHERIT:
$holding['inherit'] .= $row['auth_value'] . ', ';
break;
}
}
while ($row = $db->sql_fetchrow($result));
$preset_options .= '';
$preset_js .= "\tpresets['preset_0'] = new Array();" . "\n";
$preset_js .= "\tpresets['preset_0'] = new preset_obj('" . $holding['allow'] . "', '" . $holding['deny'] . "', '" . $holding['inherit'] . "');\n";
}
$db->sql_freeresult($result);
}
// Look for custom presets
$sql = "SELECT preset_id, preset_name, preset_data
FROM " . ACL_PRESETS_TABLE . "
WHERE preset_type = '$type_sql'
ORDER BY preset_id ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{
$preset_update_options .= '';
$preset_options .= '';
$preset_data = unserialize($row['preset_data']);
foreach ($preset_data as $preset_type => $preset_type_ary)
{
$holding[$preset_type] = '';
foreach ($preset_type_ary as $preset_option)
{
$holding[$preset_type] .= "$preset_option, ";
}
}
$preset_js .= "\tpresets['preset_" . $row['preset_id'] . "'] = new Array();" . "\n";
$preset_js .= "\tpresets['preset_" . $row['preset_id'] . "'] = new preset_obj('" . $holding['allow'] . "', '" . $holding['deny'] . "', '" . $holding['inherit'] . "');\n";
}
while ($row = $db->sql_fetchrow($result));
}
unset($holding);
?>
lang['ACL_EXPLAIN']; ?>