From 4b80d45e8ed50d5fe5f6f0eaebc20ef8897d2e57 Mon Sep 17 00:00:00 2001
From: "Paul S. Owen" <psotfx@users.sourceforge.net>
Date: Tue, 12 Feb 2002 17:04:11 +0000
Subject: Minor update to topic notification which should put an end to a rare
 bug

git-svn-id: file:///svn/phpbb/trunk@2110 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/viewtopic.php | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

(limited to 'phpBB/viewtopic.php')

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" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
 			);
 
-			$message = $lang['No_longer_watching']. "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . "\">", "</a>");
+			$message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
 			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" => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
 			);
 
-			$message = $lang['You_are_watching']. "<br /><br />" . sprintf($lang['Click_return_topic'], "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . "\">", "</a>");
+			$message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
 			message_die(GENERAL_MESSAGE, $message);
 		}
 		else
@@ -362,13 +358,13 @@ else
 	$post_days = 0;
 }
 
-$select_post_days = "<select name=\"postdays\">";
+$select_post_days = '<select name="postdays">';
 for($i = 0; $i < count($previous_days); $i++)
 {
 	$selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
-	$select_post_days .= "<option value=\"" . $previous_days[$i] . "\"$selected>" . $previous_days_text[$i] . "</option>";
+	$select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
 }
-$select_post_days .= "</select>";
+$select_post_days .= '</select>';
 
 //
 // Decide how to order the post display
@@ -384,16 +380,16 @@ else
 	$post_time_order = "ASC";
 }
 
-$select_post_order = "<select name=\"postorder\">";
+$select_post_order = '<select name="postorder">';
 if($post_time_order == "ASC")
 {
-	$select_post_order .= "<option value=\"asc\" selected=\"selected\">" . $lang['Oldest_First'] . "</option><option value=\"desc\">" . $lang['Newest_First'] . "</option>";
+	$select_post_order .= '<option value="asc" selected="selected">' . $lang['Oldest_First'] . '</option><option value="desc">' . $lang['Newest_First'] . '</option>';
 }
 else
 {
-	$select_post_order .= "<option value=\"asc\">" . $lang['Oldest_First'] . "</option><option value=\"desc\" selected=\"selected\">" . $lang['Newest_First'] . "</option>";
+	$select_post_order .= '<option value="asc">' . $lang['Oldest_First'] . '</option><option value="desc" selected="selected">' . $lang['Newest_First'] . '</option>';
 }
-$select_post_order .= "</select>";
+$select_post_order .= '</select>';
 
 //
 // Go ahead and pull all data for this topic
-- 
cgit v1.2.1