diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 684dd01bd4..92c44ffa2d 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -215,12 +215,9 @@ if ( !empty($post_id) ) } // -// Is user watching this thread? This could potentially -// be combined into the above query but the LEFT JOIN causes -// a number of problems which will probably end up in this -// solution being practically as fast and certainly simpler! +// Is user watching this thread? // -if( $userdata['user_id'] != ANONYMOUS ) +if( $userdata['session_logged_in'] ) { $can_watch_topic = TRUE; @@ -228,11 +225,12 @@ if( $userdata['user_id'] != ANONYMOUS ) FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id AND user_id = " . $userdata['user_id']; - if( !$result = $db->sql_query($sql) ) + if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't obtain topic watch information", "", __LINE__, __FILE__, $sql); } - else if( $db->sql_numrows($result) ) + + if( $row = $db->sql_fetchrow($result) ) { if( isset($HTTP_GET_VARS['unwatch']) ) { @@ -254,16 +252,14 @@ if( $userdata['user_id'] != ANONYMOUS ) "META" => '') ); - $message = $lang['No_longer_watching']. "

" . sprintf($lang['Click_return_topic'], "", ""); + $message = $lang['No_longer_watching'] . '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } else { $is_watching_topic = TRUE; - $watch_data = $db->sql_fetchrow($result); - - if( $watch_data['notify_status'] ) + if( $row['notify_status'] ) { $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : ""; $sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . " @@ -298,7 +294,7 @@ if( $userdata['user_id'] != ANONYMOUS ) "META" => '') ); - $message = $lang['You_are_watching']. "

" . sprintf($lang['Click_return_topic'], "", ""); + $message = $lang['You_are_watching'] . '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } else @@ -362,13 +358,13 @@ else $post_days = 0; } -$select_post_days = "'; for($i = 0; $i < count($previous_days); $i++) { $selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : ''; - $select_post_days .= ""; + $select_post_days .= ''; } -$select_post_days .= ""; +$select_post_days .= ''; // // Decide how to order the post display @@ -384,16 +380,16 @@ else $post_time_order = "ASC"; } -$select_post_order = "'; if($post_time_order == "ASC") { - $select_post_order .= ""; + $select_post_order .= ''; } else { - $select_post_order .= ""; + $select_post_order .= ''; } -$select_post_order .= ""; +$select_post_order .= ''; // // Go ahead and pull all data for this topic