Browse Source

Merge pull request #504 from Oldiesmann/release-2.1

Redirection topics should be marked as read when clicked
Michael Eshom 11 years ago
parent
commit
b754fed22e
1 changed files with 16 additions and 0 deletions
  1. 16 0
      Sources/Display.php

+ 16 - 0
Sources/Display.php

@@ -180,7 +180,23 @@ function Display()
 
 	// Is this a moved topic that we are redirecting to?
 	if (!empty($topicinfo['id_redirect_topic']))
+	{
+		if ($topicinfo['new_from'] === 0 && !$user_info['is_guest'])
+		{
+			// Mark this as read first
+			$smcFunc['db_insert']($topicinfo['new_from'] == 0 ? 'ignore' : 'replace',
+				'{db_prefix}log_topics',
+				array(
+					'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'disregarded' => 'int',
+				),
+				array(
+					$user_info['id'], $topicinfo['id'], $topicinfo['id_first_msg'], $topicinfo['disregarded'],
+				),
+				array('id_member', 'id_topic')
+			);
+		}
 		redirectexit('topic=' . $topicinfo['id_redirect_topic'] . '.0');
+	}
 
 	$context['real_num_replies'] = $context['num_replies'] = $topicinfo['num_replies'];
 	$context['topic_first_message'] = $topicinfo['id_first_msg'];