git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9983 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Henry Sudhof 2009-08-14 15:51:34 +00:00
parent b3eb3543bb
commit 84154098e7

View file

@ -86,6 +86,7 @@ if ($view && !$post_id)
WHERE topic_id = $topic_id WHERE topic_id = $topic_id
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
AND post_time > $topic_last_read AND post_time > $topic_last_read
AND forum_id = $forum_id
ORDER BY post_time ASC"; ORDER BY post_time ASC";
$result = $db->sql_query_limit($sql, 1); $result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
@ -188,6 +189,7 @@ $sql_array = array(
// The FROM-Order is quite important here, else t.* columns can not be correctly bound. // The FROM-Order is quite important here, else t.* columns can not be correctly bound.
if ($post_id) if ($post_id)
{ {
$sql_array['SELECT'] .= ', p.post_approved';
$sql_array['FROM'][POSTS_TABLE] = 'p'; $sql_array['FROM'][POSTS_TABLE] = 'p';
} }
@ -235,7 +237,7 @@ if (!$post_id)
} }
else else
{ {
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : ''); $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";
} }
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id'; $sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
@ -263,6 +265,7 @@ $result = $db->sql_query($sql);
$topic_data = $db->sql_fetchrow($result); $topic_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
// link to unapproved post or incorrect link
if (!$topic_data) if (!$topic_data)
{ {
// If post_id was submitted, we try at least to display the topic as a last resort... // If post_id was submitted, we try at least to display the topic as a last resort...
@ -274,9 +277,23 @@ if (!$topic_data)
trigger_error('NO_TOPIC'); trigger_error('NO_TOPIC');
} }
$forum_id = (int) $topic_data['forum_id'];
$topic_id = (int) $topic_data['topic_id'];
// This is for determining where we are (page) // This is for determining where we are (page)
if ($post_id) if ($post_id)
{ {
// are we where we are supposed to be?
if ($post_id && !$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id']))
{
// If post_id was submitted, we try at least to display the topic as a last resort...
if ($post_id && $topic_id)
{
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : '')));
}
trigger_error('NO_TOPIC');
}
if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id']) if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])
{ {
$check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a'; $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
@ -307,9 +324,6 @@ if ($post_id)
} }
} }
$forum_id = (int) $topic_data['forum_id'];
$topic_id = (int) $topic_data['topic_id'];
// //
$topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies']; $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];