1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-10 02:36:38 +02:00

- assign user rank

- only a few very tiny bugfixes


git-svn-id: file:///svn/phpbb/trunk@5451 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2006-01-14 14:34:46 +00:00
parent 5ae050ccd2
commit 0c03b4e45e
11 changed files with 221 additions and 210 deletions

View File

@@ -342,14 +342,11 @@ class acp_groups
$result = $db->sql_query($sql);
$rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
if ($row = $db->sql_fetchrow($result))
while ($row = $db->sql_fetchrow($result))
{
do
{
$selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
}
while ($row = $db->sql_fetchrow($result));
$selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
}
$db->sql_freeresult($result);

View File

@@ -389,7 +389,7 @@ class acp_modules
'S_MODULE_NAMES' => $s_name_options,
'S_MODULE_MODES' => $s_mode_options,
'U_BACK' => $u_action . '&amp;parent_id=' . $parent_id,
'U_EDIT_ACTION' => $u_action,
'U_EDIT_ACTION' => $u_action . '&amp;parent_id=' . $parent_id,
'L_TITLE' => $user->lang[strtoupper($action) . '_MODULE'],

View File

@@ -104,10 +104,17 @@ class acp_users
// Generate overall "header" for user admin
$s_form_options = '';
$forms_ary = array('overview', 'feedback', 'profile', 'prefs', 'avatar', 'sig', 'groups', 'perm', 'attach');
foreach ($forms_ary as $value)
$module_info = new acp_users_info();
$forms_ary = $module_info->module();
foreach ($forms_ary['modes'] as $value => $ary)
{
if (!$this->is_authed($ary['auth']))
{
continue;
}
$selected = ($mode == $value) ? ' selected="selected"' : '';
$s_form_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($value)] . '</option>';
}
@@ -1348,6 +1355,42 @@ class acp_users
break;
case 'rank':
if ($submit)
{
$rank_id = request_var('user_rank', 0);
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_rank = $rank_id
WHERE user_id = $user_id";
$db->sql_query($sql);
trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($u_action));
}
$sql = 'SELECT *
FROM ' . RANKS_TABLE . '
WHERE rank_special = 1
ORDER BY rank_title';
$result = $db->sql_query($sql);
$s_rank_options = '<option value="0"' . ((!$user_row['user_rank']) ? ' selected="selected"' : '') . '>' . $user->lang['NO_SPECIAL_RANK'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank']) ? ' selected="selected"' : '';
$s_rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_RANK' => true,
'S_RANK_OPTIONS' => $s_rank_options)
);
break;
case 'sig':
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
@@ -1707,6 +1750,9 @@ class acp_users
);
}
/**
* Optionset replacement for this module based on $user->optionset
*/
function optionset(&$user_row, $key, $value, $data = false)
{
global $user;
@@ -1737,6 +1783,9 @@ class acp_users
}
}
/**
* Optionget replacement for this module based on $user->optionget
*/
function optionget(&$user_row, $key, $data = false)
{
global $user;
@@ -1744,6 +1793,26 @@ class acp_users
$var = ($data) ? $data : $user_row['user_options'];
return ($var & 1 << $user->keyoptions[$key]) ? true : false;
}
/**
* Check if user is allowed to call this user mode
*/
function is_authed($module_auth)
{
global $config, $auth;
$module_auth = trim($module_auth);
if (!$module_auth)
{
return true;
}
$is_auth = false;
eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z_]+)(,\$id)?#', '#\$id#', '#cfg_([a-z_]+)#'), array('(int) $auth->acl_get("\\1"\\2)', 'true', '(int) $config["\\1"]'), trim($module_auth)) . ');');
return $is_auth;
}
}
/**
@@ -1763,8 +1832,9 @@ class acp_users_info
'profile' => array('title' => 'ACP_USER_PROFILE', 'auth' => 'acl_a_user', 'display' => false),
'prefs' => array('title' => 'ACP_USER_PREFS', 'auth' => 'acl_a_user', 'display' => false),
'avatar' => array('title' => 'ACP_USER_AVATAR', 'auth' => 'acl_a_user', 'display' => false),
'rank' => array('title' => 'ACP_USER_RANK', 'auth' => 'acl_a_user', 'display' => false),
'sig' => array('title' => 'ACP_USER_SIG', 'auth' => 'acl_a_user', 'display' => false),
'groups' => array('title' => 'ACP_USER_GROUPS', 'auth' => 'acl_a_user', 'display' => false),
'groups' => array('title' => 'ACP_USER_GROUPS', 'auth' => 'acl_a_user && acl_a_group', 'display' => false),
'perm' => array('title' => 'ACP_USER_PERM', 'auth' => 'acl_a_user', 'display' => false),
'attach' => array('title' => 'ACP_USER_ATTACH', 'auth' => 'acl_a_user', 'display' => false),
),

View File

@@ -589,7 +589,21 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0)
if (sizeof($sql_ary))
{
$db->sql_query('INSERT INTO ' . FORUMS_TRACK_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
switch (SQL_LAYER)
{
case 'mysql':
case 'mysql4':
case 'mysqli':
$db->sql_query('INSERT INTO ' . FORUMS_TRACK_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
break;
default:
foreach ($sql_ary as $ary)
{
$db->sql_query('INSERT INTO ' . FORUMS_TRACK_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
}
break;
}
}
}
}

View File

@@ -2059,12 +2059,9 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limi
return;
}
/*
if (class_exists('auth'))
{
/**
* @package phpBB3
* Extension of auth class for changing permissions
*/
class auth_admin extends auth
{
// Set a user or group ACL record
@@ -2228,112 +2225,8 @@ if (class_exists('auth'))
$this->acl_clear_prefetch();
}
// NOTE: this function is not in use atm
// Add a new option to the list ... $options is a hash of form ->
// $options = array(
// 'local' => array('option1', 'option2', ...),
// 'global' => array('optionA', 'optionB', ...)
//);
function acl_add_option($options)
{
global $db, $cache;
if (!is_array($options))
{
trigger_error('Incorrect parameter for acl_add_option', E_USER_ERROR);
}
$cur_options = array();
$sql = "SELECT auth_option, is_global, is_local
FROM " . ACL_OPTIONS_TABLE . "
ORDER BY auth_option_id";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!empty($row['is_global']))
{
$cur_options['global'][] = $row['auth_option'];
}
if (!empty($row['is_local']))
{
$cur_options['local'][] = $row['auth_option'];
}
}
$db->sql_freeresult($result);
// Here we need to insert new options ... this requires discovering whether
// an options is global, local or both and whether we need to add an option
// type flag (x_)
$new_options = array('local' => array(), 'global' => array());
foreach ($options as $type => $option_ary)
{
$option_ary = array_unique($option_ary);
foreach ($option_ary as $option_value)
{
if (!in_array($option_value, $cur_options[$type]))
{
$new_options[$type][] = $option_value;
}
$flag = substr($option_value, 0, strpos($option_value, '_') + 1);
if (!in_array($flag, $cur_options[$type]) && !in_array($flag, $new_options[$type]))
{
$new_options[$type][] = $flag;
}
}
}
unset($options);
$options = array();
$options['local'] = array_diff($new_options['local'], $new_options['global']);
$options['global'] = array_diff($new_options['global'], $new_options['local']);
$options['local_global'] = array_intersect($new_options['local'], $new_options['global']);
$type_sql = array('local' => '0, 1', 'global' => '1, 0', 'local_global' => '1, 1');
$sql = '';
foreach ($options as $type => $option_ary)
{
foreach ($option_ary as $option)
{
switch (SQL_LAYER)
{
case 'mysql':
$sql .= (($sql != '') ? ', ' : '') . "('$option', " . $type_sql[$type] . ")";
break;
case 'mysql4':
case 'mysqli':
case 'mssql':
case 'mssql_odbc':
case 'sqlite':
$sql .= (($sql != '') ? ' UNION ALL ' : '') . " SELECT '$option', " . $type_sql[$type];
break;
default:
$sql = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local)
VALUES ($option, " . $type_sql[$type] . ")";
$db->sql_query($sql);
$sql = '';
}
}
}
if ($sql != '')
{
$sql = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local)
VALUES $sql";
$db->sql_query($sql);
}
$cache->destroy('acl_options');
}
}
}
*/
/**
* Update Post Informations (First/Last Post in topic/forum)

View File

@@ -554,12 +554,24 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
'ban_give_reason' => $ban_give_reason,
);
}
$sql = $db->sql_build_array('MULTI_INSERT', $sql_ary);
if ($sql)
if (sizeof($sql_ary))
{
$sql = 'INSERT INTO ' . BANLIST_TABLE . ' ' . $sql;
$db->sql_query($sql);
switch (SQL_LAYER)
{
case 'mysql':
case 'mysql4':
case 'mysqli':
$db->sql_query('INSERT INTO ' . BANLIST_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
break;
default:
foreach ($sql_ary as $ary)
{
$db->sql_query('INSERT INTO ' . BANLIST_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
}
break;
}
}
// If we are banning we want to logout anyone matching the ban