1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-11 19:24:01 +02:00

- fixed dotted topics on some occassions being wrong

- fixed post author change
- fixed moving topics (they should not count into read tracking now) - think about having only one column for shadow topics/similar to forum links
- moved a function from functions.php to functions_display.php (this function is only used by viewtopic and viewforum which already include this file)
- some rather tiny fixes for mssql


git-svn-id: file:///svn/phpbb/trunk@5933 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2006-05-19 21:08:48 +00:00
parent c0e3a86ebb
commit 8e800e333c
9 changed files with 354 additions and 211 deletions

View File

@@ -424,115 +424,6 @@ function tz_select($default = '')
// Functions handling topic/post tracking/marking
/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
{
global $template, $db, $user, $phpEx, $SID, $start, $phpbb_root_path;
$table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
$where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
$match_id = ($mode == 'forum') ? $forum_id : $topic_id;
$u_url = ($mode == 'forum') ? 'f' : 'f=' . $forum_id . '&t';
// Is user watching this thread?
if ($user_id != ANONYMOUS)
{
$can_watch = true;
if ($notify_status == 'unset')
{
$sql = "SELECT notify_status
FROM $table_sql
WHERE $where_sql = $match_id
AND user_id = $user_id";
$result = $db->sql_query($sql);
$notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
$db->sql_freeresult($result);
}
if (!is_null($notify_status))
{
if (isset($_GET['unwatch']))
{
if ($_GET['unwatch'] == $mode)
{
$is_watching = 0;
$sql = 'DELETE FROM ' . $table_sql . "
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
meta_refresh(3, "view$mode.$phpEx$SID&$u_url=$match_id&start=$start");
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;start=$start" . '">', '</a>');
trigger_error($message);
}
else
{
$is_watching = true;
if ($notify_status)
{
$sql = 'UPDATE ' . $table_sql . "
SET notify_status = 0
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
}
}
else
{
if (isset($_GET['watch']))
{
if ($_GET['watch'] == $mode)
{
$is_watching = true;
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
VALUES ($user_id, $match_id, 0)";
$db->sql_query($sql);
}
meta_refresh(3, "view$mode.$phpEx$SID&amp;$u_url=$match_id&amp;start=$start");
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;start=$start" . '">', '</a>');
trigger_error($message);
}
else
{
$is_watching = 0;
}
}
}
else
{
if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
{
login_box();
}
else
{
$can_watch = 0;
$is_watching = 0;
}
}
if ($can_watch)
{
$s_watching['link'] = "{$phpbb_root_path}view$mode.$phpEx$SID&amp;$u_url=$match_id&amp;" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&amp;start=$start";
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
}
return;
}
/**
* Marks a topic/forum as read
* Marks a topic as posted to

View File

@@ -367,12 +367,21 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true)
{
global $db;
$forum_ids = array($forum_id);
$sql_where = (is_array($topic_ids)) ? 'IN (' . implode(', ', $topic_ids) . ')' : '= ' . $topic_ids;
if (empty($topic_ids))
{
return;
}
$sql = 'DELETE FROM ' . TOPICS_TABLE . "
WHERE topic_moved_id $sql_where
AND forum_id = " . $forum_id;
$forum_ids = array($forum_id);
if (!is_array($topic_ids))
{
$topic_ids = array($topic_ids);
}
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE topic_moved_id IN (' . implode(', ', $topic_ids) . ')
AND forum_id = ' . $forum_id;
$db->sql_query($sql);
if ($auto_sync)
@@ -388,13 +397,16 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true)
}
$db->sql_freeresult($result);
}
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE);
/**
* @todo watch for undesired results on marked topics for moving topics, maybe handle it seperatly to cover cookie tracking
*/
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
foreach ($table_ary as $table)
{
$sql = "UPDATE $table
SET forum_id = $forum_id
WHERE topic_id " . $sql_where;
WHERE topic_id IN (" . implode(', ', $topic_ids) . ')';
$db->sql_query($sql);
}
unset($table_ary);
@@ -418,54 +430,54 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
$post_ids = array($post_ids);
}
if ($auto_sync)
$forum_ids = array();
$topic_ids = array($topic_id);
$sql = 'SELECT DISTINCT topic_id, forum_id
FROM ' . POSTS_TABLE . '
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$forum_ids = array();
$topic_ids = array($topic_id);
$sql = 'SELECT DISTINCT topic_id, forum_id
FROM ' . POSTS_TABLE . '
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
$topic_ids[] = $row['topic_id'];
}
$db->sql_freeresult($result);
$forum_ids[] = $row['forum_id'];
$topic_ids[] = $row['topic_id'];
}
$db->sql_freeresult($result);
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
$forum_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row = $db->sql_fetchrow($result))
if (!$forum_row)
{
trigger_error('NO_TOPIC');
}
$db->sql_freeresult($result);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = ' . $row['forum_id'] . ", topic_id = $topic_id
SET forum_id = ' . $forum_row['forum_id'] . ", topic_id = $topic_id
WHERE post_id IN (" . implode(', ', $post_ids) . ')';
$db->sql_query($sql);
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
SET topic_id = $topic_id
AND in_message = 0
SET topic_id = $topic_id, in_message = 0
WHERE post_msg_id IN (" . implode(', ', $post_ids) . ')';
$db->sql_query($sql);
if ($auto_sync)
{
$forum_ids[] = $row['forum_id'];
$forum_ids[] = $forum_row['forum_id'];
sync('topic_reported', 'topic_id', $topic_ids);
sync('topic', 'topic_id', $topic_ids, true);
sync('forum', 'forum_id', $forum_ids, true);
}
// Update posted informations
update_posted_info($topic_ids);
}
/**
@@ -864,6 +876,76 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true)
}
}
/**
* Update/Sync posted informations for topics
*/
function update_posted_info($topic_ids)
{
global $db;
if (empty($topic_ids))
{
return;
}
// First of all, let us remove any posted information for these topics
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE topic_id IN (' . implode(', ', $topic_ids) . ')';
$db->sql_query($sql);
// Now, let us collect the user/topic combos for rebuilding the information
$sql = 'SELECT topic_id, poster_id
FROM ' . POSTS_TABLE . '
WHERE topic_id IN (' . implode(', ', $topic_ids) . ')';
$result = $db->sql_query($sql);
$posted = array();
while ($row = $db->sql_fetchrow($result))
{
if (empty($posted[$row['topic_id']]))
{
$posted[$row['topic_id']] = array();
}
// Add as key to make them unique (grouping by) and circumvent empty keys on array_unique
$posted[$row['topic_id']][$row['poster_id']] = 1;
}
$db->sql_freeresult($result);
// Now add the information...
$sql_ary = array();
foreach ($posted as $topic_id => $poster_row)
{
foreach ($poster_row as $user_id => $null)
{
$sql_ary[] = array(
'user_id' => $user_id,
'topic_id' => $topic_id,
'topic_posted' => 1,
);
}
}
if (sizeof($sql_ary))
{
switch (SQL_LAYER)
{
case 'mysql':
case 'mysql4':
case 'mysqli':
$db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
break;
default:
foreach ($sql_ary as $ary)
{
$db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
}
break;
}
}
}
/**
* Delete File
*/
@@ -1365,8 +1447,19 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// NOTE: 't.post_approved' in the GROUP BY is causing a major slowdown.
$sql = 'SELECT t.topic_id, t.post_approved, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id
FROM ' . POSTS_TABLE . " t
$where_sql
GROUP BY t.topic_id"; //, t.post_approved";
$where_sql";
switch (SQL_LAYER)
{
case 'mssql':
case 'mssql-odbc':
$sql .= 'GROUP BY t.topic_id, t.post_approved';
break;
default:
$sql .= 'GROUP BY t.topic_id';
break;
}
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -1485,7 +1578,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
$where_sql_and p.topic_id = t.topic_id
AND p.post_reported = 1
GROUP BY t.topic_id";
GROUP BY t.topic_id, p.post_id";
$result = $db->sql_query($sql);
$fieldnames[] = 'reported';
@@ -1501,7 +1594,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p
$where_sql_and p.topic_id = t.topic_id
AND p.post_attachment = 1
GROUP BY t.topic_id";
GROUP BY t.topic_id, p.post_id";
$result = $db->sql_query($sql);
$fieldnames[] = 'attachment';

View File

@@ -1075,4 +1075,113 @@ function display_user_activity(&$userdata)
);
}
/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
{
global $template, $db, $user, $phpEx, $SID, $start, $phpbb_root_path;
$table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
$where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
$match_id = ($mode == 'forum') ? $forum_id : $topic_id;
$u_url = ($mode == 'forum') ? 'f' : 'f=' . $forum_id . '&amp;t';
// Is user watching this thread?
if ($user_id != ANONYMOUS)
{
$can_watch = true;
if ($notify_status == 'unset')
{
$sql = "SELECT notify_status
FROM $table_sql
WHERE $where_sql = $match_id
AND user_id = $user_id";
$result = $db->sql_query($sql);
$notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
$db->sql_freeresult($result);
}
if (!is_null($notify_status))
{
if (isset($_GET['unwatch']))
{
if ($_GET['unwatch'] == $mode)
{
$is_watching = 0;
$sql = 'DELETE FROM ' . $table_sql . "
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
meta_refresh(3, "view$mode.$phpEx$SID&amp;$u_url=$match_id&amp;start=$start");
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;start=$start" . '">', '</a>');
trigger_error($message);
}
else
{
$is_watching = true;
if ($notify_status)
{
$sql = 'UPDATE ' . $table_sql . "
SET notify_status = 0
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
}
}
}
else
{
if (isset($_GET['watch']))
{
if ($_GET['watch'] == $mode)
{
$is_watching = true;
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
VALUES ($user_id, $match_id, 0)";
$db->sql_query($sql);
}
meta_refresh(3, "view$mode.$phpEx$SID&amp;$u_url=$match_id&amp;start=$start");
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&amp;" . $u_url . "=$match_id&amp;start=$start" . '">', '</a>');
trigger_error($message);
}
else
{
$is_watching = 0;
}
}
}
else
{
if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
{
login_box();
}
else
{
$can_watch = 0;
$is_watching = 0;
}
}
if ($can_watch)
{
$s_watching['link'] = "{$phpbb_root_path}view$mode.$phpEx$SID&amp;$u_url=$match_id&amp;" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&amp;start=$start";
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
}
return;
}
?>

View File

@@ -469,10 +469,6 @@ function mcp_move_topic($topic_ids)
);
$db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow));
// $next_id = $db->sql_nextid();
// Mark Shadow topic read
// markread('topic', $row['forum_id'], $next_id);
}
}
unset($topic_data);

View File

@@ -49,7 +49,7 @@ class mcp_notes
case 'user_notes':
$user->add_lang('acp/common');
mcp_notes_user_view($id, $mode, $action);
$this->tpl_name = 'mcp_notes_user';
break;

View File

@@ -35,6 +35,7 @@ function mcp_post_details($id, $mode, $action)
switch ($action)
{
case 'whois':
$ip = request_var('ip', '');
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
@@ -47,48 +48,37 @@ function mcp_post_details($id, $mode, $action)
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], "<a href=\"{$phpbb_root_path}mcp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;p=$post_id\">", '</a>'),
'WHOIS' => trim($whois))
);
// We're done with the whois page so return
return;
case 'chgposter':
// We're done with the whois page so return
return;
$username = request_var('username', '', true);
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE username = \'' . $db->sql_escape($username) . '\'';
$result = $db->sql_query($sql);
if (!($row = $db->sql_fetchrow($result)))
{
trigger_error($user->lang['NO_USER']);
}
$new_user = $row['user_id'];
if ($auth->acl_get('m_', $post_info['forum_id']))
{
change_poster($post_info, $new_user);
}
break;
case 'chgposter':
case 'chgposter_ip':
$new_user = request_var('u', 0);
$username = request_var('username', '', true);
$new_user_id = request_var('u', 0);
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $new_user;
$sql_where = ($new_user_id) ? 'user_id = ' . $new_user_id : "username = '" . $db->sql_escape($username) . "'";
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE ' . $sql_where;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!($row = $db->sql_fetchrow($result)))
if (!$row)
{
trigger_error($user->lang['NO_USER']);
}
if ($auth->acl_get('m_', $post_info['forum_id']))
{
change_poster($post_info, $new_user);
change_poster($post_info, $row);
}
break;
}
@@ -101,11 +91,12 @@ function mcp_post_details($id, $mode, $action)
$message = $post_info['post_text'];
if ($post_info['bbcode_bitfield'])
{
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
$bbcode = new bbcode($post_info['bbcode_bitfield']);
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
}
$message = smiley_text($message);
$message = str_replace("\n", '<br />', $message);
$template->assign_vars(array(
'U_MCP_ACTION' => "$url&amp;i=main&amp;quickmod=1", // Use this for mode paramaters
@@ -117,15 +108,15 @@ function mcp_post_details($id, $mode, $action)
'S_CAN_LOCK_POST' => $auth->acl_get('m_lock', $post_info['forum_id']),
'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']),
'S_POST_REPORTED' => $post_info['post_reported'],
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
'S_POST_LOCKED' => $post_info['post_edit_locked'],
'S_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? true : false,
'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false,
'S_POST_UNAPPROVED' => (!$post_info['post_approved']) ? true : false,
'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false,
'S_USER_NOTES' => ($auth->acl_gets('m_', 'a_')) ? true : false,
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
'U_FIND_MEMBER' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=mcp_chgposter&amp;field=username",
'U_VIEW_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $post_info['user_id'],
'U_MCP_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&amp;i=notes&amp;mode=user_notes&amp;u=" . $post_info['user_id'] : '',
'U_MCP_USER_NOTES' => ($auth->acl_gets('m_', 'a_')) ? "{$phpbb_root_path}mcp.$phpEx$SID&amp;i=notes&amp;mode=user_notes&amp;u=" . $post_info['user_id'] : '',
'U_MCP_WARN_USER' => "{$phpbb_root_path}mcp.$phpEx$SID&amp;i=warn&amp;mode=warn_user&amp;u=" . $post_info['user_id'],
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&amp;mode=edit&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}" : '',
@@ -226,7 +217,7 @@ function mcp_post_details($id, $mode, $action)
$sql = 'SELECT u.user_id, u.username, COUNT(*) as postings
FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p
WHERE p.poster_id = u.user_id
AND p.poster_ip = '{$post_info['poster_ip']}'
AND p.poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'
AND p.poster_id <> {$post_info['user_id']}
GROUP BY u.user_id, u.username
ORDER BY COUNT(*) DESC";
@@ -236,7 +227,7 @@ function mcp_post_details($id, $mode, $action)
$sql = 'SELECT u.user_id, u.username, COUNT(*) as postings
FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p
WHERE p.poster_id = u.user_id
AND p.poster_ip = '{$post_info['poster_ip']}'
AND p.poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'
AND p.poster_id <> {$post_info['user_id']}
GROUP BY u.user_id, u.username
ORDER BY postings DESC";
@@ -306,6 +297,7 @@ function mcp_post_details($id, $mode, $action)
$user_select = '';
ksort($users_ary);
foreach ($users_ary as $row)
{
$user_select .= '<option value="' . $row['user_id'] . '">' . $row['username'] . "</option>\n";
@@ -316,37 +308,90 @@ function mcp_post_details($id, $mode, $action)
}
/**
* Changes a post's poster_id
* Change a post's poster
*/
function change_poster(&$post_info, $new_user)
function change_poster(&$post_info, $userdata)
{
global $auth, $db;
if ($new_user && $new_user != $post_info['user_id'])
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
{
$post_id = $post_info['post_id'];
$sql = 'UPDATE ' . POSTS_TABLE . "
SET poster_id = $new_user
WHERE post_id = " . $post_id;
$db->sql_query($sql);
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id)
{
sync('topic', 'topic_id', $post_info['topic_id'], false, false);
sync('forum', 'forum_id', $post_info['forum_id'], false, false);
}
// Renew post info
$post_info = get_post_data(array($post_id));
if (!sizeof($post_info))
{
trigger_error($user->lang['POST_NOT_EXIST']);
}
$post_info = $post_info[$post_id];
return;
}
$post_id = $post_info['post_id'];
$sql = 'UPDATE ' . POSTS_TABLE . "
SET poster_id = {$userdata['user_id']}
WHERE post_id = $post_id";
$db->sql_query($sql);
// Resync topic/forum if needed
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id)
{
sync('topic', 'topic_id', $post_info['topic_id'], false, false);
sync('forum', 'forum_id', $post_info['forum_id'], false, false);
}
// 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']))
{
$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'];
$db->sql_query($sql);
}
// Add posted to information for this topic for the new user
markread('post', $post_info['forum_id'], $post_info['topic_id'], time(), $userdata['user_id']);
// Remove the dotted topic option if the old user has no more posts within this topic
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $post_info['topic_id'] . '
AND poster_id = ' . $post_info['user_id'];
$result = $db->sql_query_limit($sql, 1);
$topic_id = (int) $db->sql_fetchfield('topic_id');
$db->sql_freeresult($result);
if (!$topic_id)
{
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE user_id = ' . $post_info['user_id'] . '
AND topic_id = ' . $post_info['topic_id'];
$db->sql_query($sql);
}
// Do not change the poster_id within the attachments table, since they were still posted by the original user
// Renew post info
$post_info = get_post_data(array($post_id));
if (!sizeof($post_info))
{
trigger_error($user->lang['POST_NOT_EXIST']);
}
$post_info = $post_info[$post_id];
// Now add log entry
add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_MCP_CHANGE_POSTER', $post_info['topic_title'], $post_info['username'], $userdata['username']);
}
?>