aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewtopic.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r--phpBB/viewtopic.php62
1 files changed, 42 insertions, 20 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 9d2a6b61c0..f24eebd1a7 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -116,34 +116,43 @@ if ($view && !$post_id)
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
- $sql = 'SELECT topic_id, forum_id
- FROM ' . TOPICS_TABLE . '
- WHERE forum_id = ' . $row['forum_id'] . "
- AND topic_moved_id = 0
- AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
- " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
- ORDER BY topic_last_post_time $sql_ordering";
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
if (!$row)
{
$user->setup('viewtopic');
+ // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
}
else
{
- $topic_id = $row['topic_id'];
+ $sql = 'SELECT topic_id, forum_id
+ FROM ' . TOPICS_TABLE . '
+ WHERE forum_id = ' . $row['forum_id'] . "
+ AND topic_moved_id = 0
+ AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
+ " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
+ ORDER BY topic_last_post_time $sql_ordering";
+ $result = $db->sql_query_limit($sql, 1);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
- // Check for global announcement correctness?
- if (!$row['forum_id'] && !$forum_id)
+ if (!$row)
{
- trigger_error('NO_TOPIC');
+ $user->setup('viewtopic');
+ trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
}
- else if ($row['forum_id'])
+ else
{
- $forum_id = $row['forum_id'];
+ $topic_id = $row['topic_id'];
+
+ // Check for global announcement correctness?
+ if (!$row['forum_id'] && !$forum_id)
+ {
+ trigger_error('NO_TOPIC');
+ }
+ else if ($row['forum_id'])
+ {
+ $forum_id = $row['forum_id'];
+ }
}
}
}
@@ -572,6 +581,7 @@ $template->assign_vars(array(
'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action">' . $topic_mod . '</select>' : '',
'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),
+ 'S_VIEWTOPIC' => true,
'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 't=' . $topic_id),
@@ -653,13 +663,25 @@ if (!empty($topic_data['poll_start']))
if ($update && $s_can_vote)
{
- if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'])
+
+ if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
{
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
meta_refresh(5, $redirect_url);
-
- $message = (!sizeof($voted_id)) ? 'NO_VOTE_OPTION' : 'TOO_MANY_VOTE_OPTIONS';
+ if (!sizeof($voted_id))
+ {
+ $message = 'NO_VOTE_OPTION';
+ }
+ else if (sizeof($voted_id) > $topic_data['poll_max_options'])
+ {
+ $message = 'TOO_MANY_VOTE_OPTIONS';
+ }
+ else
+ {
+ $message = 'VOTE_CONVERTED';
+ }
+
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
trigger_error($message);
}