- size select fix

- introduced function for building group options (acp)
- fixed acl_getf if negated option needs to be retrieved
- only using one function for updating post informations
- fixing module display if module is disabled
- if user is having a non-existent style do not print out error message, instead fix the users value and load the default style


git-svn-id: file:///svn/phpbb/trunk@5486 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-01-22 13:06:13 +00:00
parent 0650bd4d0d
commit ec959d0001
13 changed files with 424 additions and 198 deletions

View file

@ -46,15 +46,15 @@
</dl>
<dl>
<dt><label for="attach_quota">{L_ATTACH_QUOTA}:</label><br /><span>{L_ATTACH_QUOTA_EXPLAIN}</span></dt>
<dd><input type="text" id="attach_quota" size="8" maxlength="15" name="attachment_quota" value="{ATTACHMENT_QUOTA}" /> {S_QUOTA_SELECT}</dd>
<dd><input type="text" id="attach_quota" size="8" maxlength="15" name="attachment_quota" value="{ATTACHMENT_QUOTA}" /> <select name="quota_size">{S_QUOTA_SIZE_OPTIONS}</select></dd>
</dl>
<dl>
<dt><label for="max_filesize">{L_ATTACH_MAX_FILESIZE}:</label><br /><span>{L_ATTACH_MAX_FILESIZE_EXPLAIN}</span></dt>
<dd><input type="text" id="max_filesize" size="8" maxlength="15" name="max_filesize" value="{MAX_FILESIZE}" /> {S_MAX_FILESIZE_SELECT}</dd>
<dd><input type="text" id="max_filesize" size="8" maxlength="15" name="max_filesize" value="{MAX_FILESIZE}" /> <select name="size">{S_MAX_FILESIZE_OPTIONS}</select></dd>
</dl>
<dl>
<dt><label for="max_pm_filesize">{L_ATTACH_MAX_PM_FILESIZE}:</label><br /><span>{L_ATTACH_MAX_PM_FILESIZE_EXPLAIN}</span></dt>
<dd><input type="text" id="max_pm_filesize" size="8" maxlength="15" name="max_filesize_pm" value="{MAX_PM_FILESIZE}" /> {S_MAX_PM_FILESIZE_SELECT}</dd>
<dd><input type="text" id="max_pm_filesize" size="8" maxlength="15" name="max_filesize_pm" value="{MAX_PM_FILESIZE}" /> <select name="pm_size">{S_MAX_PM_FILESIZE_OPTIONS}</select></dd>
</dl>
<dl>
<dt><label for="max_attachments">{L_MAX_ATTACHMENTS}:</label></dt>
@ -245,7 +245,7 @@
</dl>
<dl>
<dt><label for="extgroup_filesize">{L_MAX_EXTGROUP_FILESIZE}:</label></dt>
<dd><input type="text" id="extgroup_filesize" size="3" maxlength="15" name="max_filesize" value="{EXTGROUP_FILESIZE}" /> {S_EXT_GROUP_SIZE}</dd>
<dd><input type="text" id="extgroup_filesize" size="3" maxlength="15" name="max_filesize" value="{EXTGROUP_FILESIZE}" /> <select name="size_select">{S_EXT_GROUP_SIZE_OPTIONS}</select></dd>
</dl>
<dl>
<dt><label for="assigned_extensions">{L_ASSIGNED_EXTENSIONS}:</label></dt>

View file

@ -139,9 +139,9 @@ class acp_attachments
// We strip eventually manual added convert program, we only want the patch
$new['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $new['img_imagick']);
$select_size_mode = size_select('size', $size);
$select_quota_size_mode = size_select('quota_size', $quota_size);
$select_pm_size_mode = size_select('pm_size', $pm_size);
$s_size_options = size_select_options($size);
$s_quota_size_options = size_select_options($quota_size);
$s_pm_size_options = size_select_options($pm_size);
$sql = 'SELECT group_name, cat_id
FROM ' . EXTENSION_GROUPS_TABLE . '
@ -187,9 +187,9 @@ class acp_attachments
'U_SEARCH_IMAGICK' => $u_action . '&amp;action=imgmagick',
'S_QUOTA_SELECT' => $select_quota_size_mode,
'S_MAX_FILESIZE_SELECT' => $select_size_mode,
'S_MAX_PM_FILESIZE_SELECT' => $select_pm_size_mode,
'S_QUOTA_SIZE_OPTIONS' => $s_quota_size_options,
'S_MAX_FILESIZE_OPTIONS' => $s_size_options,
'S_MAX_PM_FILESIZE_OPTIONS' => $s_pm_size_options,
'S_THUMBNAIL_SUPPORT' => (!$new['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) ? false : true,
)
);
@ -655,7 +655,7 @@ class acp_attachments
'S_CATEGORY_SELECT' => $this->category_select('special_category', $group_id, 'category'),
'S_DOWNLOAD_SELECT' => $this->download_select('download_mode', $group_id, 'download_mode'),
'S_EXT_GROUP_SIZE' => size_select('size_select', $size_format),
'S_EXT_GROUP_SIZE_OPTIONS' => size_select_options($size_format),
'S_EXTENSION_OPTIONS' => $s_extension_options,
'S_FILENAME_LIST' => $filename_list,
'S_EDIT_GROUP' => true,

View file

@ -197,12 +197,7 @@ class acp_email
$result = $db->sql_query($sql);
$select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($group_id == $row['group_id']) ? ' selected="selected"' : '';
$select_list .= '<option value = "' . $row['group_id'] . '"' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
$select_list .= group_select_options($group_id);
$s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
$s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';

View file

@ -65,13 +65,13 @@ class auth
{
$i = 0;
while ($subseq = substr($seq, $i, 6))
{
if (!isset($this->acl[$f]))
{
$this->acl[$f] = '';
}
while ($subseq = substr($seq, $i, 6))
{
// We put the original bitstring into the acl array
$this->acl[$f] .= str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT);
$i += 6;
@ -157,6 +157,32 @@ class auth
$opt = substr($opt, 1);
}
// If we retrieve a list of forums not having permissions in, we need to get every forum_id
if ($negate)
{
static $acl_forum_ids;
if (!isset($acl_forum_ids))
{
global $db;
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
if (sizeof($this->acl))
{
$sql .= ' WHERE forum_id NOT IN (' . implode(', ', array_keys($this->acl)) . ')';
}
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$acl_forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
}
}
if (isset($this->acl_options['local'][$opt]))
{
foreach ($this->acl as $f => $bitstring)
@ -183,6 +209,15 @@ class auth
}
}
// If we get forum_ids not having this permission, we need to fill the remaining parts
if ($negate && sizeof($acl_forum_ids))
{
foreach ($acl_forum_ids as $f)
{
$acl_f[$f][$opt] = 1;
}
}
return $acl_f;
}
@ -542,13 +577,13 @@ class auth_admin extends auth
* @param mixed $forum_id forum_ids to search for. Defining a forum id also means getting local settings (required for the modes forum and mod_local)
* @param string $auth_option if mode is 'custom' the auth_option defines the permission setting to look after
* @param local|global $scope if mode is 'custom' the scope defines the permission scope. If local, a forum_id is additionally required
* @param ACL_NO|ACL_UNSET|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with
*/
function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false)
function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NO)
{
global $db;
$hold_ary = array();
$auth_option = '';
switch ($mode)
{
@ -566,7 +601,7 @@ class auth_admin extends auth
}
else
{
$hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%') : $this->acl_raw_data($user_id, $auth_option . '%');
$hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', ($scope == 'global') ? 0 : false) : $this->acl_raw_data($user_id, $auth_option . '%', ($scope == 'global') ? 0 : false);
}
break;
@ -624,7 +659,7 @@ class auth_admin extends auth
return array();
}
$hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, 'm_%') : $this->acl_raw_data($user_id, 'm_%');
$hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, 'm_%', 0) : $this->acl_raw_data($user_id, 'm_%', 0);
$auth_option = 'm_';
$scope = 'global';
@ -675,11 +710,11 @@ class auth_admin extends auth
// Now switch back to keys
if (sizeof($compare_options))
{
$compare_options = array_combine($compare_options, array_fill(1, sizeof($compare_options), 0));
$compare_options = array_combine($compare_options, array_fill(1, sizeof($compare_options), $acl_fill));
}
// Defining the user-function here to save some memory
$return_zero = create_function('$value', 'return 0;');
$return_acl_fill = create_function('$value', 'return ' . $acl_fill . ';');
// Actually fill the gaps
if (sizeof($hold_ary))
@ -693,7 +728,7 @@ class auth_admin extends auth
// The differences get merged into $hold_ary (all permissions having ACL_NO set)
$hold_ary[$ug_id][$id] = array_merge($options,
array_map($return_zero,
array_map($return_acl_fill,
array_flip(
array_diff(
array_keys($compare_options), array_keys($options)
@ -819,6 +854,187 @@ class auth_admin extends auth
return true;
}
/**
* Set a user or group ACL record
*/
function acl_set($ug_type, &$forum_id, &$ug_id, &$auth)
{
global $db;
// One or more forums
if (!is_array($forum_id))
{
$forum_id = array($forum_id);
}
// Set any flags as required
foreach ($auth as $auth_option => $setting)
{
$flag = substr($auth_option, 0, strpos($auth_option, '_') + 1);
if (!isset($auth[$flag]) || !$auth[$flag])
{
$auth[$flag] = $setting;
}
}
$sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$option_ids[$row['auth_option']] = $row['auth_option_id'];
}
$db->sql_freeresult($result);
$sql_forum = 'AND a.forum_id IN (' . implode(', ', array_map('intval', $forum_id)) . ')';
if ($ug_type == 'user')
{
$sql = 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting
FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o
WHERE a.auth_option_id = o.auth_option_id
$sql_forum
AND a.user_id = $ug_id";
}
else
{
$sql = 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting
FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o
WHERE a.auth_option_id = o.auth_option_id
$sql_forum
AND a.group_id = $ug_id";
}
$result = $db->sql_query($sql);
$cur_auth = array();
while ($row = $db->sql_fetchrow($result))
{
$cur_auth[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting'];
}
$db->sql_freeresult($result);
$table = ($ug_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE;
$id_field = $ug_type . '_id';
$sql_ary = array();
foreach ($forum_id as $forum)
{
foreach ($auth as $auth_option => $setting)
{
$auth_option_id = $option_ids[$auth_option];
switch ($setting)
{
case ACL_UNSET:
if (isset($cur_auth[$forum][$auth_option_id]))
{
$sql_ary['delete'][] = "DELETE FROM $table
WHERE forum_id = $forum
AND auth_option_id = $auth_option_id
AND $id_field = $ug_id";
}
break;
default:
if (!isset($cur_auth[$forum][$auth_option_id]))
{
$sql_ary['insert'][] = "$ug_id, $forum, $auth_option_id, $setting";
}
else if ($cur_auth[$forum][$auth_option_id] != $setting)
{
$sql_ary['update'][] = "UPDATE " . $table . "
SET auth_setting = $setting
WHERE $id_field = $ug_id
AND forum_id = $forum
AND auth_option_id = $auth_option_id";
}
}
}
}
unset($cur_auth);
$sql = '';
foreach ($sql_ary as $sql_type => $sql_subary)
{
switch ($sql_type)
{
case 'insert':
switch (SQL_LAYER)
{
case 'mysql':
$sql = 'VALUES ' . implode(', ', preg_replace('#^(.*?)$#', '(\1)', $sql_subary));
break;
case 'mysql4':
case 'mysqli':
case 'mssql':
case 'mssql_odbc':
case 'sqlite':
$sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary));
break;
default:
foreach ($sql_subary as $sql)
{
$sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) VALUES ($sql)";
$db->sql_query($sql);
$sql = '';
}
}
if ($sql != '')
{
$sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) $sql";
$db->sql_query($sql);
}
break;
case 'update':
case 'delete':
foreach ($sql_subary as $sql)
{
$db->sql_query($sql);
}
break;
}
unset($sql_ary[$sql_type]);
}
unset($sql_ary);
$this->acl_clear_prefetch();
}
/**
* Remove local permission
*/
function acl_delete($mode, &$forum_id, &$ug_id, $auth_ids = false)
{
global $db;
// One or more forums
if (!is_array($forum_id))
{
$forum_id = array($forum_id);
}
$auth_sql = ($auth_ids) ? ' AND auth_option_id IN (' . implode(', ', array_map('intval', $auth_ids)) . ')' : '';
$table = ($mode == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE;
$id_field = $mode . '_id';
foreach ($forum_id as $forum)
{
$sql = "DELETE FROM $table
WHERE $id_field = $ug_id
AND forum_id = $forum
$auth_sql";
$db->sql_query($sql);
}
$this->acl_clear_prefetch();
}
}
?>

View file

@ -286,8 +286,8 @@ class dbal_mysql extends dbal
function _sql_error()
{
return array(
'message' => @mysql_error(),
'code' => @mysql_errno()
'message' => @mysql_error($this->db_connect_id),
'code' => @mysql_errno($this->db_connect_id)
);
}

View file

@ -289,8 +289,8 @@ class dbal_mysql4 extends dbal
function _sql_error()
{
return array(
'message' => @mysql_error(),
'code' => @mysql_errno()
'message' => @mysql_error($this->db_connect_id),
'code' => @mysql_errno($this->db_connect_id)
);
}

View file

@ -2073,7 +2073,7 @@ function page_footer()
}
else if (time() - $config['search_last_gc'] > $config['search_gc'])
{
// Tidy the cache
// Tidy the search
$cron_type = 'tidy_search';
}
/**

View file

@ -178,24 +178,45 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
/**
* Generate size select form
*/
function size_select($select_name, $size_compare)
function size_select_options($size_compare)
{
global $user;
$size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']);
$size_types = array('b', 'kb', 'mb');
$select_field = '<select name="' . $select_name . '">';
$s_size_options = '';
for ($i = 0, $size = sizeof($size_types_text); $i < $size; $i++)
{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
$s_size_options .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
}
$select_field .= '</select>';
return $s_size_options;
}
return ($select_field);
/**
* Generate list of groups
*/
function group_select_options($group_id)
{
global $db, $user;
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . '
ORDER BY group_type DESC, group_name ASC';
$result = $db->sql_query($sql);
$s_group_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($row['group_id'] == $group_id) ? ' selected="selected"' : '';
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
return $s_group_options;
}
/**
@ -2060,88 +2081,6 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limi
return;
}
/**
* Update Post Informations (First/Last Post in topic/forum)
* Should be used instead of sync() if only the last post informations are out of sync... faster
*/
function update_post_information($type, $ids)
{
global $db;
if (!is_array($ids))
{
$ids = array($ids);
}
$update_sql = $empty_forums = array();
$sql = 'SELECT ' . $type . '_id, MAX(post_id) as last_post_id
FROM ' . POSTS_TABLE . "
WHERE post_approved = 1
AND {$type}_id IN (" . implode(', ', $ids) . ")
GROUP BY {$type}_id";
$result = $db->sql_query($sql);
$last_post_ids = array();
while ($row = $db->sql_fetchrow($result))
{
if ($type == 'forum')
{
$empty_forums[] = $row['forum_id'];
}
$last_post_ids[] = $row['last_post_id'];
}
$db->sql_freeresult($result);
if ($type == 'forum')
{
$empty_forums = array_diff($ids, $empty_forums);
foreach ($empty_forums as $void => $forum_id)
{
$update_sql[$forum_id][] = 'forum_last_post_id = 0';
$update_sql[$forum_id][] = 'forum_last_post_time = 0';
$update_sql[$forum_id][] = 'forum_last_poster_id = 0';
$update_sql[$forum_id][] = "forum_last_poster_name = ''";
}
}
if (sizeof($last_post_ids))
{
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_time, p.poster_id, p.post_username, u.user_id, u.username
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id
AND p.post_id IN (' . implode(', ', $last_post_ids) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
}
$db->sql_freeresult($result);
}
unset($empty_forums, $ids, $last_post_ids);
if (!sizeof($update_sql))
{
return;
}
$table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE;
foreach ($update_sql as $update_id => $update_sql_ary)
{
$sql = "UPDATE $table
SET " . implode(', ', $update_sql_ary) . "
WHERE {$type}_id = $update_id";
$db->sql_query($sql);
}
}
/**
* Get database size
* Currently only mysql and mssql are supported

View file

@ -146,7 +146,7 @@ class p_master
}
// Module there
if ($temp_row['module_name'])
if ($temp_row['module_name'] && $temp_row['module_enabled'])
{
$empty_category = false;
break;

View file

@ -90,48 +90,85 @@ function generate_smilies($mode, $forum_id)
}
/**
* Update Last Post Informations
* Update Post Informations (First/Last Post in topic/forum)
* Should be used instead of sync() if only the last post informations are out of sync... faster
*/
function update_last_post_information($type, $id)
function update_post_information($type, $ids)
{
global $db;
$update_sql = array();
$sql = 'SELECT MAX(p.post_id) as last_post_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE p.topic_id = t.topic_id
AND p.post_approved = 1
AND t.topic_approved = 1
AND p.{$type}_id = $id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if ((int) $row['last_post_id'])
if (!is_array($ids))
{
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id
AND p.post_id = ' . $row['last_post_id'];
$ids = array($ids);
}
$update_sql = $empty_forums = array();
$sql = 'SELECT ' . $type . '_id, MAX(post_id) as last_post_id
FROM ' . POSTS_TABLE . "
WHERE post_approved = 1
AND {$type}_id IN (" . implode(', ', $ids) . ")
GROUP BY {$type}_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$last_post_ids = array();
while ($row = $db->sql_fetchrow($result))
{
if ($type == 'forum')
{
$empty_forums[] = $row['forum_id'];
}
$last_post_ids[] = $row['last_post_id'];
}
$db->sql_freeresult($result);
$update_sql[] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[] = $type . '_last_post_time = ' . (int) $row['post_time'];
$update_sql[] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
$update_sql[] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
}
else if ($type == 'forum')
if ($type == 'forum')
{
$update_sql[] = 'forum_last_post_id = 0';
$update_sql[] = 'forum_last_post_time = 0';
$update_sql[] = 'forum_last_poster_id = 0';
$update_sql[] = "forum_last_poster_name = ''";
$empty_forums = array_diff($ids, $empty_forums);
foreach ($empty_forums as $void => $forum_id)
{
$update_sql[$forum_id][] = 'forum_last_post_id = 0';
$update_sql[$forum_id][] = 'forum_last_post_time = 0';
$update_sql[$forum_id][] = 'forum_last_poster_id = 0';
$update_sql[$forum_id][] = "forum_last_poster_name = ''";
}
}
return $update_sql;
if (sizeof($last_post_ids))
{
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_time, p.poster_id, p.post_username, u.user_id, u.username
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.poster_id = u.user_id
AND p.post_id IN (' . implode(', ', $last_post_ids) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];
$update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
}
$db->sql_freeresult($result);
}
unset($empty_forums, $ids, $last_post_ids);
if (!sizeof($update_sql))
{
return array();
}
$table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE;
foreach ($update_sql as $update_id => $update_sql_ary)
{
$sql = "UPDATE $table
SET " . implode(', ', $update_sql_ary) . "
WHERE {$type}_id = $update_id";
$db->sql_query($sql);
}
}
/**

View file

@ -28,6 +28,8 @@ class mcp_queue
global $auth, $db, $user, $template;
global $config, $phpbb_root_path, $phpEx, $SID;
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$forum_id = request_var('f', 0);
$start = request_var('start', 0);
@ -36,7 +38,6 @@ class mcp_queue
case 'approve':
case 'disapprove':
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$post_id_list = request_var('post_id_list', array(0));
@ -59,7 +60,6 @@ class mcp_queue
case 'approve_details':
$user->add_lang('posting');
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);

View file

@ -789,6 +789,27 @@ class user extends session
$this->theme = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// User has wrong style
if (!$this->theme && $style == $this->data['user_style'])
{
$style = $this->data['user_style'] = $config['default_style'];
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_style = $style
WHERE user_id = {$this->data['user_id']}";
$db->sql_query($sql);
$sql = 'SELECT s.style_id, t.*, c.*, i.*
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . " i
WHERE s.style_id = $style
AND t.template_id = s.template_id
AND c.theme_id = s.theme_id
AND i.imageset_id = s.imageset_id";
$result = $db->sql_query($sql);
$this->theme = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
if (!$this->theme)
{
trigger_error('Could not get style data', E_USER_ERROR);

View file

@ -417,9 +417,7 @@ if ($mode == 'bump' && ($bump_time = bump_topic_allowed($forum_id, $topic_bumped
topic_bumper = " . $user->data['user_id'] . "
WHERE topic_id = $topic_id");
$db->sql_query('UPDATE ' . FORUMS_TABLE . '
SET ' . implode(', ', update_last_post_information('forum', $forum_id)) . "
WHERE forum_id = $forum_id");
update_post_information('forum', $forum_id);
$db->sql_query('UPDATE ' . USERS_TABLE . "
SET user_lastpost_time = $current_time
@ -719,9 +717,11 @@ if ($submit || $preview || $refresh)
case POST_ANNOUNCE:
$auth_option = 'f_announce';
break;
case POST_STICKY:
$auth_option = 'f_sticky';
break;
default:
$auth_option = '';
}
@ -1213,8 +1213,13 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, &$data)
$sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_topics = forum_topics - 1' : '';
}
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql))
{
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', update_last_post_information('forum', $forum_id));
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
$sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
break;
@ -1246,15 +1251,20 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, &$data)
$sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
}
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql))
{
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', update_last_post_information('forum', $forum_id));
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
$sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
$update = update_last_post_information('topic', $topic_id);
if (sizeof($update))
$update_sql = update_post_information('topic', $topic_id, true);
if (sizeof($update_sql))
{
$sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update);
$next_post_id = (int) str_replace('topic_last_post_id = ', '', $update[0]);
$sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]);
$next_post_id = (int) str_replace('topic_last_post_id = ', '', $update[$topic_id][0]);
}
else
{
@ -1753,27 +1763,35 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{
if ($topic_type != POST_GLOBAL)
{
$sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id']));
$update_sql = update_post_information('forum', $data['forum_id'], true);
if (sizeof($update_sql))
{
$sql_data[FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]);
}
}
$update = update_last_post_information('topic', $data['topic_id']);
$update_sql = update_post_information('topic', $data['topic_id'], true);
if (sizeof($update))
{
$sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update);
$sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]);
}
}
if ($make_global)
{
$sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id']));
$update_sql = update_post_information('forum', $data['forum_id'], true);
if (sizeof($update_sql))
{
$sql_data[FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$forum_id]);
}
}
if ($post_mode == 'edit_topic')
{
$update = update_last_post_information('topic', $data['topic_id']);
if (sizeof($update))
$update_sql = update_post_information('topic', $data['topic_id'], true);
if (sizeof($update_sql))
{
$sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update);
$sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]);
}
}