mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 08:47:45 +02:00
- fixing some bugs
- shortening some db columns to meet the requirements - correctly increase/decrease user post counts - fix the topic title length bug(s) git-svn-id: file:///svn/phpbb/trunk@6224 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -165,7 +165,7 @@ class acp_groups
|
||||
case 'delete':
|
||||
if (!$auth->acl_get('a_groupdel'))
|
||||
{
|
||||
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
|
||||
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action));
|
||||
}
|
||||
|
||||
$error = group_delete($group_id, $group_row['group_name']);
|
||||
@@ -176,13 +176,15 @@ class acp_groups
|
||||
break;
|
||||
}
|
||||
|
||||
$back_link = ($action == 'delete') ? $this->u_action : $this->u_action . '&action=list&g=' . $group_id;
|
||||
|
||||
if ($error)
|
||||
{
|
||||
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
|
||||
trigger_error($user->lang[$error] . adm_back_link($back_link));
|
||||
}
|
||||
|
||||
$message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
|
||||
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
|
||||
trigger_error($user->lang[$message] . adm_back_link($back_link));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -209,37 +209,17 @@ class acp_main
|
||||
trigger_error($user->lang['NO_ADMIN']);
|
||||
}
|
||||
|
||||
$post_count_ary = $auth->acl_getf('f_postcount');
|
||||
$forum_read_ary = $auth->acl_getf('f_read');
|
||||
|
||||
$forum_ary = array();
|
||||
foreach ($post_count_ary as $forum_id => $allowed)
|
||||
{
|
||||
if ($allowed['f_postcount'] && $forum_read_ary[$forum_id]['f_read'])
|
||||
{
|
||||
$forum_ary[] = $forum_id;
|
||||
}
|
||||
}
|
||||
$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE post_postcount = 1
|
||||
GROUP BY poster_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!sizeof($forum_ary))
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
|
||||
FROM ' . POSTS_TABLE . '
|
||||
WHERE poster_id <> ' . ANONYMOUS . '
|
||||
AND forum_id IN (' . implode(', ', $forum_ary) . ')
|
||||
GROUP BY poster_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}");
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$db->sql_query('UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['poster_id']}");
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
|
||||
|
||||
|
@@ -89,7 +89,7 @@ parse_css_file = {PARSE_CSS_FILE}
|
||||
pagination_sep = \'{PAGINATION_SEP}\'
|
||||
';
|
||||
|
||||
$this->imageset_keys = 'site_logo, btn_post, btn_post_pm, btn_reply, btn_reply_pm, btn_locked, btn_profile, btn_pm, btn_delete, btn_info, btn_quote, btn_search, btn_edit, btn_report, btn_warn, btn_email, btn_www, btn_icq, btn_aim, btn_yim, btn_msnm, btn_jabber, btn_online, btn_offline, btn_friend, btn_foe, icon_unapproved, icon_reported, icon_attach, icon_post, icon_post_new, icon_post_latest, icon_post_newest, forum, forum_new, forum_locked, forum_link, sub_forum, sub_forum_new, folder, folder_moved, folder_posted, folder_new, folder_new_posted, folder_hot, folder_hot_posted, folder_hot_new, folder_hot_new_posted, folder_locked, folder_locked_posted, folder_locked_new, folder_locked_new_posted, folder_locked_announce, folder_locked_announce_new, folder_locked_announce_posted, folder_locked_announce_new_posted, folder_locked_global, folder_locked_global_new, folder_locked_global_posted, folder_locked_global_new_posted, folder_locked_sticky, folder_locked_sticky_new, folder_locked_sticky_posted, folder_locked_sticky_new_posted, folder_sticky, folder_sticky_posted, folder_sticky_new, folder_sticky_new_posted, folder_announce, folder_announce_posted, folder_announce_new, folder_announce_new_posted, folder_global, folder_global_posted, folder_global_new, folder_global_new_posted, poll_left, poll_center, poll_right, attach_progress_bar, user_icon1, user_icon2, user_icon3, user_icon4, user_icon5, user_icon6, user_icon7, user_icon8, user_icon9, user_icon10';
|
||||
$this->imageset_keys = 'site_logo, btn_post, btn_post_pm, btn_reply, btn_reply_pm, btn_locked, btn_profile, btn_pm, btn_delete, btn_info, btn_quote, btn_search, btn_edit, btn_report, btn_warn, btn_email, btn_www, btn_icq, btn_aim, btn_yim, btn_msnm, btn_jabber, btn_online, btn_offline, btn_friend, btn_foe, icon_unapproved, icon_reported, icon_attach, icon_post, icon_post_new, icon_post_latest, icon_post_newest, forum, forum_new, forum_locked, forum_link, sub_forum, sub_forum_new, folder, folder_moved, folder_post, folder_new, folder_new_post, folder_hot, folder_hot_post, folder_hot_new, folder_hot_new_post, folder_lock, folder_lock_post, folder_lock_new, folder_lock_new_post, folder_lock_announce, folder_lock_announce_new, folder_lock_announce_post, folder_lock_announce_new_post, folder_lock_global, folder_lock_global_new, folder_lock_global_post, folder_lock_global_new_post, folder_lock_sticky, folder_lock_sticky_new, folder_lock_sticky_post, folder_lock_sticky_new_post, folder_sticky, folder_sticky_post, folder_sticky_new, folder_sticky_new_post, folder_announce, folder_announce_post, folder_announce_new, folder_announce_new_post, folder_global, folder_global_post, folder_global_new, folder_global_new_post, poll_left, poll_center, poll_right, attach_progress_bar, user_icon1, user_icon2, user_icon3, user_icon4, user_icon5, user_icon6, user_icon7, user_icon8, user_icon9, user_icon10';
|
||||
|
||||
// Execute overall actions
|
||||
switch ($action)
|
||||
@@ -1286,7 +1286,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
||||
'forum', 'forum_new', 'forum_locked', 'forum_link', 'sub_forum', 'sub_forum_new',
|
||||
),
|
||||
'folders' => array(
|
||||
'folder', 'folder_moved', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_locked_announce', 'folder_locked_announce_new', 'folder_locked_announce_posted', 'folder_locked_announce_new_posted', 'folder_locked_global', 'folder_locked_global_new', 'folder_locked_global_posted', 'folder_locked_global_new_posted', 'folder_locked_sticky', 'folder_locked_sticky_new', 'folder_locked_sticky_posted', 'folder_locked_sticky_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted', 'folder_global', 'folder_global_posted', 'folder_global_new', 'folder_global_new_posted',
|
||||
'folder', 'folder_moved', 'folder_post', 'folder_new', 'folder_new_post', 'folder_hot', 'folder_hot_post', 'folder_hot_new', 'folder_hot_new_post', 'folder_lock', 'folder_lock_post', 'folder_lock_new', 'folder_lock_new_post', 'folder_lock_announce', 'folder_lock_announce_new', 'folder_lock_announce_post', 'folder_lock_announce_new_post', 'folder_lock_global', 'folder_lock_global_new', 'folder_lock_global_post', 'folder_lock_global_new_post', 'folder_lock_sticky', 'folder_lock_sticky_new', 'folder_lock_sticky_post', 'folder_lock_sticky_new_post', 'folder_sticky', 'folder_sticky_post', 'folder_sticky_new', 'folder_sticky_new_post', 'folder_announce', 'folder_announce_post', 'folder_announce_new', 'folder_announce_new_post', 'folder_global', 'folder_global_post', 'folder_global_new', 'folder_global_new_post',
|
||||
),
|
||||
'polls' => array(
|
||||
'poll_left', 'poll_center', 'poll_right',
|
||||
|
@@ -2276,6 +2276,41 @@ function get_preg_expression($mode)
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates string while retaining special characters if going over the max length
|
||||
* The default max length is 60 at the moment
|
||||
*/
|
||||
function truncate_string($string, $max_length = 60)
|
||||
{
|
||||
$chars = array();
|
||||
|
||||
// split the multibyte characters first
|
||||
$string_ary = preg_split('#(&\#[0-9]+;)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
// Now go through the array and split the other characters
|
||||
foreach ($string_ary as $key => $value)
|
||||
{
|
||||
if (strpos($value, '&#') === 0)
|
||||
{
|
||||
$chars[] = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
// decode html entities and put them back later
|
||||
$_chars = str_split(html_entity_decode($value));
|
||||
$chars = array_merge($chars, array_map('htmlspecialchars', $_chars));
|
||||
}
|
||||
|
||||
// Now check the length ;)
|
||||
if (sizeof($chars) <= $max_length)
|
||||
{
|
||||
return $string;
|
||||
}
|
||||
|
||||
// Cut off the last elements from the array
|
||||
return implode('', array_slice($chars, 0, $max_length));
|
||||
}
|
||||
|
||||
// Handler, header and footer
|
||||
|
||||
/**
|
||||
@@ -2863,6 +2898,8 @@ function garbage_collection()
|
||||
$db->sql_close();
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
class bitfield
|
||||
{
|
||||
var $data;
|
||||
@@ -2872,26 +2909,22 @@ class bitfield
|
||||
$this->data = $bitfield;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
function get($n)
|
||||
{
|
||||
/**
|
||||
* Get the ($n / 8)th char
|
||||
*/
|
||||
// Get the ($n / 8)th char
|
||||
$byte = $n >> 3;
|
||||
|
||||
if (!isset($this->data[$byte]))
|
||||
{
|
||||
/**
|
||||
* Of course, if it doesn't exist then the result if FALSE
|
||||
*/
|
||||
return FALSE;
|
||||
// Of course, if it doesn't exist then the result if FALSE
|
||||
return false;
|
||||
}
|
||||
|
||||
$c = $this->data[$byte];
|
||||
|
||||
/**
|
||||
* Lookup the ($n % 8)th bit of the byte
|
||||
*/
|
||||
// Lookup the ($n % 8)th bit of the byte
|
||||
$bit = 7 - ($n & 7);
|
||||
return (bool) (ord($c) & (1 << $bit));
|
||||
}
|
||||
|
@@ -563,9 +563,9 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||
return false;
|
||||
}
|
||||
|
||||
$post_ids = $topic_ids = $forum_ids = array();
|
||||
$post_ids = $topic_ids = $forum_ids = $post_counts = array();
|
||||
|
||||
$sql = 'SELECT post_id, poster_id, topic_id, forum_id
|
||||
$sql = 'SELECT post_id, poster_id, post_postcount, topic_id, forum_id
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE $where_type " . ((!is_array($where_ids)) ? '= ' . (int) $where_ids : 'IN (' . implode(', ', array_map('intval', $where_ids)) . ')');
|
||||
$result = $db->sql_query($sql);
|
||||
@@ -576,6 +576,11 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||
$poster_ids[] = $row['poster_id'];
|
||||
$topic_ids[] = $row['topic_id'];
|
||||
$forum_ids[] = $row['forum_id'];
|
||||
|
||||
if ($row['post_postcount'])
|
||||
{
|
||||
$post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1;
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
@@ -598,6 +603,18 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||
}
|
||||
unset($table_ary);
|
||||
|
||||
// Adjust users post counts
|
||||
if (sizeof($post_counts))
|
||||
{
|
||||
foreach ($post_counts as $poster_id => $substract)
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_posts = user_posts - ' . $substract . '
|
||||
WHERE user_id = ' . $poster_id;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the message from the search index
|
||||
$search_type = basename($config['search_type']);
|
||||
|
||||
|
@@ -641,8 +641,8 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
||||
$folder = 'folder_locked_global';
|
||||
$folder_new = 'folder_locked_global_new';
|
||||
$folder = 'folder_lock_global';
|
||||
$folder_new = 'folder_lock_global_new';
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -654,8 +654,8 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
||||
$folder = 'folder_locked_announce';
|
||||
$folder_new = 'folder_locked_announce_new';
|
||||
$folder = 'folder_lock_announce';
|
||||
$folder_new = 'folder_lock_announce_new';
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -667,8 +667,8 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
||||
$folder = 'folder_locked_sticky';
|
||||
$folder_new = 'folder_locked_sticky_new';
|
||||
$folder = 'folder_lock_sticky';
|
||||
$folder_new = 'folder_lock_sticky_new';
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -689,8 +689,8 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
||||
$folder = 'folder_locked';
|
||||
$folder_new = 'folder_locked_new';
|
||||
$folder = 'folder_lock';
|
||||
$folder_new = 'folder_lock_new';
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -701,7 +701,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
// Posted image?
|
||||
if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
|
||||
{
|
||||
$folder_img .= '_posted';
|
||||
$folder_img .= '_post';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1267,7 +1267,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
|
||||
break;
|
||||
}
|
||||
|
||||
$sql_data[USERS_TABLE] = ($auth->acl_get('f_postcount', $forum_id)) ? 'user_posts = user_posts - 1' : '';
|
||||
// $sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : '';
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
@@ -1346,6 +1346,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
$post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit'));
|
||||
}
|
||||
|
||||
// First of all make sure the subject and topic title are having the correct length.
|
||||
// To achive this without cutting off between special chars we convert to an array and then count the elements.
|
||||
$subject = truncate_string($subject);
|
||||
$data['topic_title'] = truncate_string($data['topic_title']);
|
||||
|
||||
// Collect some basic informations about which tables and which rows to update/insert
|
||||
$sql_data = array();
|
||||
$poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id'];
|
||||
@@ -1374,6 +1379,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0,
|
||||
'bbcode_bitfield' => $data['bbcode_bitfield'],
|
||||
'bbcode_uid' => $data['bbcode_uid'],
|
||||
'post_postcount' => ($auth->acl_get('f_postcount', $data['forum_id']) ? 1 : 0,
|
||||
'post_edit_locked' => $data['post_edit_locked']
|
||||
);
|
||||
break;
|
||||
|
@@ -343,24 +343,13 @@ function change_poster(&$post_info, $userdata)
|
||||
}
|
||||
|
||||
// Adjust post counts
|
||||
$auth_user_from = new auth();
|
||||
$auth_user_from->acl($post_info);
|
||||
|
||||
$auth_user_to = new auth();
|
||||
$auth_user_to->acl($userdata);
|
||||
|
||||
// Decrease post count by one for the old user
|
||||
if ($auth_user_from->acl_get('f_postcount', $post_info['forum_id']))
|
||||
if ($post_info['post_postcount'])
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_posts = user_posts - 1
|
||||
WHERE user_id = ' . $post_info['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Increase post count by one for the new user
|
||||
if ($auth_user_to->acl_get('f_postcount', $post_info['forum_id']))
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_posts = user_posts + 1
|
||||
WHERE user_id = ' . $userdata['user_id'];
|
||||
|
@@ -187,7 +187,7 @@ class template
|
||||
|
||||
$filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx;
|
||||
|
||||
$recompile = (($config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle])) || !file_exists($filename)) ? true : false;
|
||||
$recompile = (($config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle])) || !file_exists($filename) || @filesize($filename) === 0) ? true : false;
|
||||
|
||||
// Recompile page if the original template is newer, otherwise load the compiled version
|
||||
if (!$recompile)
|
||||
|
@@ -266,7 +266,7 @@ class ucp_main
|
||||
// Which folder should we display?
|
||||
if ($row['forum_status'] == ITEM_LOCKED)
|
||||
{
|
||||
$folder_image = ($unread_forum) ? 'folder_locked_new' : 'folder_locked';
|
||||
$folder_image = ($unread_forum) ? 'folder_lock_new' : 'folder_lock';
|
||||
$folder_alt = 'FORUM_LOCKED';
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user