mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-05 15:16:16 +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:
parent
c0e3a86ebb
commit
8e800e333c
@ -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&" . $u_url . "=$match_id&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&$u_url=$match_id&start=$start");
|
||||
|
||||
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&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&$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&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
|
||||
|
@ -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';
|
||||
|
@ -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 . '&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&" . $u_url . "=$match_id&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&$u_url=$match_id&start=$start");
|
||||
|
||||
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . "view$mode.$phpEx$SID&" . $u_url . "=$match_id&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&$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start";
|
||||
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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&i=$id&mode=$mode&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&i=main&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&mode=searchuser&form=mcp_chgposter&field=username",
|
||||
'U_VIEW_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'],
|
||||
'U_MCP_USER_NOTES' => $auth->acl_gets('m_', 'a_') ? "{$phpbb_root_path}mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'] : '',
|
||||
'U_MCP_USER_NOTES' => ($auth->acl_gets('m_', 'a_')) ? "{$phpbb_root_path}mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'] : '',
|
||||
'U_MCP_WARN_USER' => "{$phpbb_root_path}mcp.$phpEx$SID&i=warn&mode=warn_user&u=" . $post_info['user_id'],
|
||||
'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&mode=edit&f={$post_info['forum_id']}&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']);
|
||||
}
|
||||
|
||||
?>
|
@ -562,6 +562,9 @@ INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, to
|
||||
# -- Demo Post
|
||||
INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, icon_id, post_time, post_username, poster_ip, post_subject, post_text, post_checksum, bbcode_uid) VALUES (1, 2, 2, 1, 972086460, NULL, '127.0.0.1', 'Welcome to phpBB 3', 'This is an example post in your phpBB 3.0 installation. You may delete this post, this topic and even this forum if you like since everything seems to be working!', '', '');
|
||||
|
||||
# -- Admin posted to the demo topic
|
||||
INSERT INTO phpbb_topics_posted (user_id, topic_id, topic_posted) VALUES (2, 1, 1);
|
||||
|
||||
# -- Smilies
|
||||
INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':D', 'icon_biggrin.gif', 'Very Happy', 15, 15, 1);
|
||||
INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':)', 'icon_smile.gif', 'Smile', 15, 15, 2);
|
||||
|
@ -482,6 +482,8 @@ $lang = array_merge($lang, array(
|
||||
|
||||
'LOG_MASS_EMAIL' => '<b>Sent mass email</b><br />» %s',
|
||||
|
||||
'LOG_MCP_CHANGE_POSTER' => '<b>Changed poster in topic "%s"</b><br />» from %s to %s',
|
||||
|
||||
'LOG_MODULE_DISABLE' => '<b>Module disabled</b>',
|
||||
'LOG_MODULE_ENABLE' => '<b>Module enabled</b>',
|
||||
'LOG_MODULE_MOVE_DOWN' => '<b>Module moved down</b><br />» %s',
|
||||
|
@ -386,8 +386,7 @@ if ($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & 16
|
||||
$row = &$rowset[$topic_id];
|
||||
|
||||
// This will allow the style designer to output a different header
|
||||
// or even seperate the list of announcements from sticky and normal
|
||||
// topics
|
||||
// or even seperate the list of announcements from sticky and normal topics
|
||||
$s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
|
||||
|
||||
// Replies
|
||||
@ -396,9 +395,12 @@ if ($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & 16
|
||||
if ($row['topic_status'] == ITEM_MOVED)
|
||||
{
|
||||
$topic_id = $row['topic_moved_id'];
|
||||
$unread_topic = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
}
|
||||
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
|
||||
// Get folder img, topic status/type related informations
|
||||
$folder_img = $folder_alt = $topic_type = '';
|
||||
@ -476,6 +478,7 @@ if ($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & 16
|
||||
LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.user_id = ' . $user->data['user_id'] . ' AND tt.topic_id = t.topic_id)
|
||||
WHERE t.forum_id = ' . $forum_id . '
|
||||
AND t.topic_last_post_time > ' . $mark_time_forum . '
|
||||
AND t.topic_moved_id = 0
|
||||
AND tt.topic_id IS NULL
|
||||
GROUP BY t.forum_id';
|
||||
$result = $db->sql_query($sql);
|
||||
@ -497,7 +500,8 @@ if ($forum_data['forum_type'] == FORUM_POST || (($forum_data['forum_flags'] & 16
|
||||
{
|
||||
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
|
||||
WHERE forum_id = ' . $forum_id . '
|
||||
AND topic_last_post_time > ' . $mark_time_forum;
|
||||
AND topic_last_post_time > ' . $mark_time_forum . '
|
||||
AND topic_moved_id = 0';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$check_forum = $tracking_topics['tf'][$forum_id];
|
||||
|
Loading…
x
Reference in New Issue
Block a user