Просмотр исходного кода

Merge pull request #210 from emanuele45/disregard

Disregard
emanuele45 11 лет назад
Родитель
Сommit
ea6aa67f3b

+ 7 - 2
Sources/Display.php

@@ -162,6 +162,7 @@ function Display()
 			' . ($user_info['is_guest'] ? 't.id_last_msg + 1' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from
 			' . (!empty($modSettings['recycle_board']) && $modSettings['recycle_board'] == $board ? ', id_previous_board, id_previous_topic' : '') . '
 			' . (!empty($topic_selects) ? implode(',', $topic_selects) : '') . '
+			' . (!$user_info['is_guest'] ? ', IFNULL(lt.disregarded, 0) as disregarded' : '') . '
 		FROM {db_prefix}topics AS t
 			INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)' . ($user_info['is_guest'] ? '' : '
 			LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = {int:current_topic} AND lt.id_member = {int:current_member})
@@ -171,6 +172,7 @@ function Display()
 		LIMIT 1',
 			$topic_parameters
 	);
+
 	if ($smcFunc['db_num_rows']($request) == 0)
 		fatal_lang_error('not_a_topic', false);
 	$topicinfo = $smcFunc['db_fetch_assoc']($request);
@@ -183,6 +185,7 @@ function Display()
 	$context['real_num_replies'] = $context['num_replies'] = $topicinfo['num_replies'];
 	$context['topic_first_message'] = $topicinfo['id_first_msg'];
 	$context['topic_last_message'] = $topicinfo['id_last_msg'];
+	$context['topic_disregarded'] = isset($topicinfo['disregarded']) ? $topicinfo['disregarded'] : 0;
 
 	// Add up unapproved replies to get real number of replies...
 	if ($modSettings['postmod_active'] && allowedTo('approve_posts'))
@@ -832,10 +835,10 @@ function Display()
 			$smcFunc['db_insert']($topicinfo['new_from'] == 0 ? 'ignore' : 'replace',
 				'{db_prefix}log_topics',
 				array(
-					'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int',
+					'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'disregarded' => 'int',
 				),
 				array(
-					$user_info['id'], $topic, $mark_at_msg,
+					$user_info['id'], $topic, $mark_at_msg, $topicinfo['disregarded'],
 				),
 				array('id_member', 'id_topic')
 			);
@@ -1070,6 +1073,7 @@ function Display()
 	$context['can_reply'] |= $context['can_reply_unapproved'];
 	$context['can_quote'] = $context['can_reply'] && (empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC'])));
 	$context['can_mark_unread'] = !$user_info['is_guest'] && $settings['show_mark_read'];
+	$context['can_disregard'] = !$user_info['is_guest'] && $modSettings['enable_disregard'];
 
 	$context['can_send_topic'] = (!$modSettings['postmod_active'] || $topicinfo['approved']) && allowedTo('send_topic');
 	$context['can_print'] = empty($modSettings['disable_print_topic']);
@@ -1140,6 +1144,7 @@ function Display()
 		'add_poll' => array('test' => 'can_add_poll', 'text' => 'add_poll', 'image' => 'add_poll.png', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']),
 		'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : '') . 'notify.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
 		'mark_unread' => array('test' => 'can_mark_unread', 'text' => 'mark_unread', 'image' => 'markunread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		'disregard' => array('test' => 'can_disregard', 'text' => ($context['topic_disregarded'] ? 'un' : '') . 'disregard', 'image' => ($context['topic_disregarded'] ? 'un' : '') . 'disregard.png', 'lang' => true, 'url' => $scripturl . '?action=disregardtopic;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['topic_disregarded'] ? 'off' : 'on') . ';' . $context['session_var'] . '=' . $context['session_id']),
 		'send' => array('test' => 'can_send_topic', 'text' => 'send_topic', 'image' => 'sendtopic.png', 'lang' => true, 'url' => $scripturl . '?action=emailuser;sa=sendtopic;topic=' . $context['current_topic'] . '.0'),
 		'print' => array('test' => 'can_print', 'text' => 'print', 'image' => 'print.png', 'lang' => true, 'custom' => 'rel="new_win nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
 	);

+ 1 - 0
Sources/ManageSettings.php

@@ -498,6 +498,7 @@ function ModifyBasicSettings($return_config = false)
 			// Basic stuff, titles, flash, permissions...
 			array('check', 'allow_guestAccess'),
 			array('check', 'enable_buddylist'),
+			array('check', 'enable_disregard'),
 			array('check', 'allow_editDisplayName'),
 			array('check', 'allow_hideOnline'),
 			array('check', 'titlesEnable'),

+ 17 - 2
Sources/MessageIndex.php

@@ -1163,13 +1163,28 @@ function QuickModeration()
 
 	if (!empty($markCache))
 	{
+		$smcFunc['db_query']('', '
+			SELECT id_topic, disregarded
+			FROM {db_prefix}log_topics
+			WHERE id_topic IN ({array_int:selected_topics}
+				AND id_member = {int:current_user}',
+			array(
+				'selected_topics' => $markCache,
+				'current_user' => $user_info['id'],
+			)
+		);
+		$logged_topics = array();
+		while ($row = $smcFunc['db_fetch_assoc']($request))
+			$logged_topics[$row['id_topic']] = $row['disregarded'];
+		$smcFunc['db_free_result']($request);
+
 		$markArray = array();
 		foreach ($markCache as $topic)
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic);
+			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
 
 		$smcFunc['db_insert']('replace',
 			'{db_prefix}log_topics',
-			array('id_msg' => 'int', 'id_member' => 'int', 'id_topic' => 'int'),
+			array('id_msg' => 'int', 'id_member' => 'int', 'id_topic' => 'int', 'disregarded' => 'int'),
 			$markArray,
 			array('id_member', 'id_topic')
 		);

+ 4 - 4
Sources/MoveTopic.php

@@ -456,7 +456,7 @@ function moveTopics($topics, $toBoard)
 	// Move over the mark_read data. (because it may be read and now not by some!)
 	$SaveAServer = max(0, $modSettings['maxMsgID'] - 50000);
 	$request = $smcFunc['db_query']('', '
-		SELECT lmr.id_member, lmr.id_msg, t.id_topic
+		SELECT lmr.id_member, lmr.id_msg, t.id_topic, lt.disregarded
 		FROM {db_prefix}topics AS t
 			INNER JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board
 				AND lmr.id_msg > t.id_first_msg AND lmr.id_msg > {int:protect_lmr_msg})
@@ -471,14 +471,14 @@ function moveTopics($topics, $toBoard)
 	$log_topics = array();
 	while ($row = $smcFunc['db_fetch_assoc']($request))
 	{
-		$log_topics[] = array($row['id_topic'], $row['id_member'], $row['id_msg']);
+		$log_topics[] = array($row['id_topic'], $row['id_member'], $row['id_msg'], $row['disregarded']);
 
 		// Prevent queries from getting too big. Taking some steam off.
 		if (count($log_topics) > 500)
 		{
 			$smcFunc['db_insert']('replace',
 				'{db_prefix}log_topics',
-				array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'),
+				array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'disregarded' => 'int'),
 				$log_topics,
 				array('id_topic', 'id_member')
 			);
@@ -494,7 +494,7 @@ function moveTopics($topics, $toBoard)
 		// Insert that information into the database!
 		$smcFunc['db_insert']('replace',
 			'{db_prefix}log_topics',
-			array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'),
+			array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'disregarded' => 'int'),
 			$log_topics,
 			array('id_topic', 'id_member')
 		);

+ 62 - 0
Sources/Notify.php

@@ -184,4 +184,66 @@ function BoardNotify()
 	redirectexit('board=' . $board . '.' . $_REQUEST['start']);
 }
 
+/**
+ * Turn off/on unread replies subscription for a topic
+ * Must be called with a topic specified in the URL.
+ * The sub-action can be 'on', 'off', or nothing for what to do.
+ * Requires the mark_any_notify permission.
+ * Upon successful completion of action will direct user back to topic.
+ * Accessed via ?action=disregardtopic.
+ */
+function TopicDisregard()
+{
+	global $smcFunc, $user_info, $topic, $modSettings;
+
+	// Let's do something only if the function is enabled
+	if (!$user_info['is_guest'] && $modSettings['enable_disregard'])
+	{
+		checkSession('get');
+
+		if (isset($_GET['sa']))
+		{
+			$request = $smcFunc['db_query']('', '
+				SELECT id_member, id_topic, id_msg, disregarded
+				FROM {db_prefix}log_topics
+				WHERE id_member = {int:current_user}
+					AND id_topic = {int:current_topic}',
+				array(
+					'current_user' => $user_info['id'],
+					'current_topic' => $topic,
+				)
+			);
+			$log = $smcFunc['db_fetch_assoc']($request);
+			$smcFunc['db_free_result']($request);
+			if (empty($log))
+			{
+				$insert = true;
+				$log['disregarded'] = $_GET['sa'] == 'on' ? 1 : 0;
+			}
+			else
+			{
+				$insert = false;
+				$log = array(
+					'id_member' => $user_info['id'],
+					'id_topic' => $topic,
+					'id_msg' => 0,
+					'disregarded' => $_GET['sa'] == 'on' ? 1 : 0,
+				);
+			}
+
+			$smcFunc['db_insert']($insert ? 'insert' : 'replace',
+				'{db_prefix}log_topics',
+				array(
+					'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'disregarded' => 'int',
+				),
+				$log,
+				array('id_member', 'id_topic')
+			);
+		}
+	}
+
+	// Back to the topic.
+	redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
+}
+
 ?>

+ 209 - 2
Sources/Profile-View.php

@@ -206,6 +206,8 @@ function showPosts($memID)
 			),
 			'topics' => array(
 			),
+			'disregardedtopics' => array(
+			),
 			'attach' => array(
 			),
 		),
@@ -221,6 +223,9 @@ function showPosts($memID)
 	// If we're specifically dealing with attachments use that function!
 	if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
 		return showAttachments($memID);
+	// Instead, if we're dealing with disregarded topics (and the feature is enabled) use that other function.
+	elseif (isset($_GET['sa']) && $_GET['sa'] == 'disregardedtopics' && $modSettings['enable_disregard'])
+		return showDisregarded($memID);
 
 	// Are we just viewing topics?
 	$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
@@ -527,13 +532,13 @@ function showAttachments($memID)
 
 	require_once($sourcedir . '/Subs-List.php');
 
-	// This is all the information required for a group listing.
+	// This is all the information required to list attachments.
 	$listOptions = array(
 		'id' => 'attachments',
 		'width' => '100%',
 		'items_per_page' => $modSettings['defaultMaxMessages'],
 		'no_items_label' => $txt['show_attachments_none'],
-		'base_href' => $scripturl . '?action=profile;area=showposts;sa=attach;sort=filename;u=' . $memID,
+		'base_href' => $scripturl . '?action=profile;area=showposts;sa=attach;u=' . $memID,
 		'default_sort_col' => 'filename',
 		'get_items' => array(
 			'function' => 'list_getAttachments',
@@ -718,6 +723,208 @@ function list_getNumAttachments($boardsAllowed, $memID)
 	return $attachCount;
 }
 
+/**
+ * Show all the disregarded topics.
+ *
+ * @param int $memID id_member
+ */
+function showDisregarded($memID)
+{
+	global $txt, $user_info, $scripturl, $modSettings, $board, $context, $sourcedir, $smcFunc;
+
+	// Only the owner can see the list (if the function is enabled of course)
+	if ($user_info['id'] != $memID || !$modSettings['enable_disregard'])
+		return;
+
+	require_once($sourcedir . '/Subs-List.php');
+
+	// And here they are: the topics you don't like
+	$listOptions = array(
+		'id' => 'disregarded_topics',
+		'width' => '100%',
+		'items_per_page' => $modSettings['defaultMaxMessages'],
+		'no_items_label' => $txt['disregarded_topics_none'],
+		'base_href' => $scripturl . '?action=profile;area=showposts;sa=disregardedtopics;u=' . $memID,
+		'default_sort_col' => 'started_on',
+		'get_items' => array(
+			'function' => 'list_getDisregarded',
+			'params' => array(
+				$memID,
+			),
+		),
+		'get_count' => array(
+			'function' => 'list_getNumDisregarded',
+			'params' => array(
+				$memID,
+			),
+		),
+		'columns' => array(
+			'subject' => array(
+				'header' => array(
+					'value' => $txt['subject'],
+					'class' => 'lefttext',
+					'style' => 'width: 30%;',
+				),
+				'data' => array(
+					'sprintf' => array(
+						'format' => '<a href="' . $scripturl . '?topic=%1$d.0">%2$s</a>',
+						'params' => array(
+							'id_topic' => false,
+							'subject' => false,
+						),
+					),
+				),
+				'sort' => array(
+					'default' => 'm.subject',
+					'reverse' => 'm.subject DESC',
+				),
+			),
+			'started_by' => array(
+				'header' => array(
+					'value' => $txt['started_by'],
+					'style' => 'width: 15%;',
+				),
+				'data' => array(
+					'db' => 'started_by',
+				),
+				'sort' => array(
+					'default' => 'mem.real_name',
+					'reverse' => 'mem.real_name DESC',
+				),
+			),
+			'started_on' => array(
+				'header' => array(
+					'value' => $txt['on'],
+					'class' => 'lefttext',
+					'style' => 'width: 20%;',
+				),
+				'data' => array(
+					'db' => 'started_on',
+					'timeformat' => true,
+				),
+				'sort' => array(
+					'default' => 'm.poster_time',
+					'reverse' => 'm.poster_time DESC',
+				),
+			),
+			'last_post_by' => array(
+				'header' => array(
+					'value' => $txt['last_post'],
+					'style' => 'width: 15%;',
+				),
+				'data' => array(
+					'db' => 'last_post_by',
+				),
+				'sort' => array(
+					'default' => 'mem.real_name',
+					'reverse' => 'mem.real_name DESC',
+				),
+			),
+			'last_post_on' => array(
+				'header' => array(
+					'value' => $txt['on'],
+					'class' => 'lefttext',
+					'style' => 'width: 20%;',
+				),
+				'data' => array(
+					'db' => 'last_post_on',
+					'timeformat' => true,
+				),
+				'sort' => array(
+					'default' => 'm.poster_time',
+					'reverse' => 'm.poster_time DESC',
+				),
+			),
+		),
+	);
+
+	// Create the request list.
+	createList($listOptions);
+
+	$context['sub_template'] = 'show_list';
+	$context['default_list'] = 'disregarded_topics';
+}
+
+/**
+ * Get the relevant topics in the disregarded list
+ */
+function list_getDisregarded($start, $items_per_page, $sort, $memID)
+{
+	global $smcFunc, $board, $modSettings, $context;
+
+	// Get the list of topics we can see
+	$request = $smcFunc['db_query']('', '
+		SELECT lt.id_topic
+		FROM {db_prefix}log_topics as lt
+			LEFT JOIN {db_prefix}topics as t ON (lt.id_topic = t.id_topic)
+			LEFT JOIN {db_prefix}boards as b ON (t.id_board = b.id_board)
+			LEFT JOIN {db_prefix}messages as m ON (t.id_first_msg = m.id_msg)' . (in_array($sort, array('mem.real_name', 'mem.real_name DESC', 'mem.poster_time', 'mem.poster_time DESC')) ? '
+			LEFT JOIN {db_prefix}members as mem ON (m.id_member = mem.id_member)' : '') . '
+		WHERE lt.id_member = {int:current_member}
+			AND disregarded = 1
+			AND {query_see_board}
+		ORDER BY {raw:sort}
+		LIMIT {int:offset}, {int:limit}',
+		array(
+			'current_member' => $memID,
+			'sort' => $sort,
+			'offset' => $start,
+			'limit' => $items_per_page,
+		)
+	);
+
+	$topics = array();
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+		$topics[] = $row['id_topic'];
+
+	$smcFunc['db_free_result']($request);
+
+	$request = $smcFunc['db_query']('', '
+		SELECT mf.subject, mf.poster_time as started_on, IFNULL(memf.real_name, mf.poster_name) as started_by, ml.poster_time as last_post_on, IFNULL(meml.real_name, ml.poster_name) as last_post_by, t.id_topic
+		FROM {db_prefix}topics AS t
+			INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
+			INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
+			LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)
+			LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)
+		WHERE t.id_topic IN ({array_int:topics})',
+		array(
+			'topics' => $topics,
+		)
+	);
+	$topicsInfo = array();
+	while ($row = $smcFunc['db_fetch_assoc']($request))
+		$topicsInfo[] = $row;
+	$smcFunc['db_free_result']($request);
+
+	return $topicsInfo;
+}
+
+/**
+ * Count the topics in the disregarded list
+ */
+function list_getNumDisregarded($memID)
+{
+	global $smcFunc, $user_info;
+
+	// Get the total number of attachments they have posted.
+	$request = $smcFunc['db_query']('', '
+		SELECT COUNT(*)
+		FROM {db_prefix}log_topics as lt
+		LEFT JOIN {db_prefix}topics as t ON (lt.id_topic = t.id_topic)
+		LEFT JOIN {db_prefix}boards as b ON (t.id_board = b.id_board)
+		WHERE id_member = {int:current_member}
+			AND disregarded = 1
+			AND {query_see_board}',
+		array(
+			'current_member' => $memID,
+		)
+	);
+	list ($disregardedCount) = $smcFunc['db_fetch_row']($request);
+	$smcFunc['db_free_result']($request);
+
+	return $disregardedCount;
+}
+
 /**
  * Gets the user stats for display
  *

+ 1 - 0
Sources/Profile.php

@@ -109,6 +109,7 @@ function ModifyProfile($post_errors = array())
 					'subsections' => array(
 						'messages' => array($txt['showMessages'], array('profile_view_own', 'profile_view_any')),
 						'topics' => array($txt['showTopics'], array('profile_view_own', 'profile_view_any')),
+						'disregardedtopics' => array($txt['showDisregarded'], array('profile_view_own', 'profile_view_any'), 'enabled' => $modSettings['enable_disregard'] && $context['user']['is_owner']),
 						'attach' => array($txt['showAttachments'], array('profile_view_own', 'profile_view_any')),
 					),
 					'permission' => array(

+ 16 - 8
Sources/Recent.php

@@ -758,7 +758,8 @@ function UnreadTopics()
 			WHERE lt.id_member = {int:current_member}
 				AND t.' . $query_this_board . (empty($earliest_msg) ? '' : '
 				AND t.id_last_msg > {int:earliest_msg}') . ($modSettings['postmod_active'] ? '
-				AND t.approved = {int:is_approved}' : ''),
+				AND t.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+				AND lt.disregarded != 1' : ''),
 			array_merge($query_parameters, array(
 				'current_member' => $user_info['id'],
 				'earliest_msg' => !empty($earliest_msg) ? $earliest_msg : 0,
@@ -780,7 +781,8 @@ function UnreadTopics()
 			WHERE t.' . $query_this_board . (!empty($earliest_msg) ? '
 				AND t.id_last_msg > {int:earliest_msg}' : '') . '
 				AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg' . ($modSettings['postmod_active'] ? '
-				AND t.approved = {int:is_approved}' : ''),
+				AND t.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+				AND lt.disregarded != 1' : ''),
 			array_merge($query_parameters, array(
 				'current_member' => $user_info['id'],
 				'earliest_msg' => !empty($earliest_msg) ? $earliest_msg : 0,
@@ -835,7 +837,8 @@ function UnreadTopics()
 			WHERE b.' . $query_this_board . '
 				AND t.id_last_msg >= {int:min_message}
 				AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg' . ($modSettings['postmod_active'] ? '
-				AND ms.approved = {int:is_approved}' : '') . '
+				AND ms.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+				AND lt.disregarded != 1' : '') . '
 			ORDER BY {raw:sort}
 			LIMIT {int:offset}, {int:limit}',
 			array_merge($query_parameters, array(
@@ -860,7 +863,8 @@ function UnreadTopics()
 				AND t.id_last_msg > {int:earliest_msg}' : (!$context['showing_all_topics'] && empty($_SESSION['first_login']) ? '
 				AND t.id_last_msg > {int:id_msg_last_visit}' : '')) . '
 				AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg' . ($modSettings['postmod_active'] ? '
-				AND t.approved = {int:is_approved}' : ''),
+				AND t.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+				AND lt.disregarded != 1' : ''),
 			array_merge($query_parameters, array(
 				'current_member' => $user_info['id'],
 				'earliest_msg' => !empty($earliest_msg) ? $earliest_msg : 0,
@@ -921,7 +925,8 @@ function UnreadTopics()
 			WHERE t.' . $query_this_board . '
 				AND t.id_last_msg >= {int:min_message}
 				AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < ml.id_msg' . ($modSettings['postmod_active'] ? '
-				AND ms.approved = {int:is_approved}' : '') . '
+				AND ms.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+				AND lt.disregarded != 1' : '') . '
 			ORDER BY {raw:order}
 			LIMIT {int:offset}, {int:limit}',
 			array_merge($query_parameters, array(
@@ -973,7 +978,8 @@ function UnreadTopics()
 					LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})' . (isset($sortKey_joins[$_REQUEST['sort']]) ? $sortKey_joins[$_REQUEST['sort']] : '') . '
 				WHERE m.id_member = {int:current_member}' . (!empty($board) ? '
 					AND t.id_board = {int:current_board}' : '') . ($modSettings['postmod_active'] ? '
-					AND t.approved = {int:is_approved}' : '') . '
+					AND t.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+				AND lt.disregarded != 1' : '') . '
 				GROUP BY m.id_topic',
 				array(
 					'current_board' => $board,
@@ -1026,7 +1032,8 @@ function UnreadTopics()
 				WHERE t.' . $query_this_board . '
 					AND m.id_member = {int:current_member}
 					AND IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) < t.id_last_msg' . ($modSettings['postmod_active'] ? '
-					AND t.approved = {int:is_approved}' : ''),
+					AND t.approved = {int:is_approved}' : '') . ($modSettings['enable_disregard'] ? '
+					AND lt.disregarded != 1' : ''),
 				array_merge($query_parameters, array(
 					'current_member' => $user_info['id'],
 					'is_approved' => 1,
@@ -1089,7 +1096,8 @@ function UnreadTopics()
 				WHERE t.' . $query_this_board . '
 					AND t.id_last_msg >= {int:min_message}
 					AND (IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0))) < t.id_last_msg
-					AND t.approved = {int:is_approved}
+					AND t.approved = {int:is_approved}' . ($modSettings['enable_disregard'] ? '
+					AND lt.disregarded != 1' : '') . '
 				ORDER BY {raw:order}
 				LIMIT {int:offset}, {int:limit}',
 				array_merge($query_parameters, array(

+ 2 - 2
Sources/RemoveTopic.php

@@ -858,8 +858,8 @@ function removeMessage($message, $decreasePostCount = true)
 			if (!$user_info['is_guest'])
 				$smcFunc['db_insert']('replace',
 					'{db_prefix}log_topics',
-					array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'),
-					array($topicID, $user_info['id'], $modSettings['maxMsgID']),
+					array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'disregarded' => 'int'),
+					array($topicID, $user_info['id'], $modSettings['maxMsgID'], 0),
 					array('id_topic', 'id_member')
 				);
 

+ 7 - 6
Sources/SplitTopics.php

@@ -753,7 +753,7 @@ function splitTopic($split1_ID_TOPIC, $splitMessages, $new_subject)
 	// Copy log topic entries.
 	// @todo This should really be chunked.
 	$request = $smcFunc['db_query']('', '
-		SELECT id_member, id_msg
+		SELECT id_member, id_msg, disregarded
 		FROM {db_prefix}log_topics
 		WHERE id_topic = {int:id_topic}',
 		array(
@@ -764,11 +764,11 @@ function splitTopic($split1_ID_TOPIC, $splitMessages, $new_subject)
 	{
 		$replaceEntries = array();
 		while ($row = $smcFunc['db_fetch_assoc']($request))
-			$replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg']);
+			$replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['disregarded']);
 
 		$smcFunc['db_insert']('ignore',
 			'{db_prefix}log_topics',
-			array('id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int'),
+			array('id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'disregarded' => 'int'),
 			$replaceEntries,
 			array('id_member', 'id_topic')
 		);
@@ -1432,8 +1432,9 @@ function MergeExecute($topics = array())
 	);
 
 	// Merge log topic entries.
+	// The disregard setting comes from the oldest topic
 	$request = $smcFunc['db_query']('', '
-		SELECT id_member, MIN(id_msg) AS new_id_msg
+		SELECT id_member, MIN(id_msg) AS new_id_msg, disregarded
 		FROM {db_prefix}log_topics
 		WHERE id_topic IN ({array_int:topics})
 		GROUP BY id_member',
@@ -1445,11 +1446,11 @@ function MergeExecute($topics = array())
 	{
 		$replaceEntries = array();
 		while ($row = $smcFunc['db_fetch_assoc']($request))
-			$replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg']);
+			$replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['disregarded']);
 
 		$smcFunc['db_insert']('replace',
 			'{db_prefix}log_topics',
-			array('id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int'),
+			array('id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'disregarded' => 'int'),
 			$replaceEntries,
 			array('id_member', 'id_topic')
 		);

+ 29 - 10
Sources/Subs-Boards.php

@@ -109,7 +109,8 @@ function markBoardsRead($boards, $unread = false)
 			INNER JOIN {db_prefix}topics AS t /*!40000 USE INDEX (PRIMARY) */ ON (t.id_topic = lt.id_topic
 				AND t.id_board IN ({array_int:board_list}))
 		WHERE lt.id_member = {int:current_member}
-			AND lt.id_topic >= {int:lowest_topic}',
+			AND lt.id_topic >= {int:lowest_topic}
+			AND lt.disregarded != 1',
 		array(
 			'current_member' => $user_info['id'],
 			'board_list' => $boards,
@@ -175,15 +176,30 @@ function MarkRead()
 	elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
 	{
 		// Make sure all the boards are integers!
-		$topics = explode('-', $_REQUEST['topics']);
+		$topics = array_map('intval', explode('-', $_REQUEST['topics']));
+
+		$smcFunc['db_query']('', '
+			SELECT id_topic, disregarded
+			FROM {db_prefix}log_topics
+			WHERE id_topic IN ({array_int:selected_topics}
+				AND id_member = {int:current_user}',
+			array(
+				'selected_topics' => $topics,
+				'current_user' => $user_info['id'],
+			)
+		);
+		$logged_topics = array();
+		while ($row = $smcFunc['db_fetch_assoc']($request))
+			$logged_topics[$row['id_topic']] = $row['disregarded'];
+		$smcFunc['db_free_result']($request);
 
 		$markRead = array();
 		foreach ($topics as $id_topic)
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], (int) $id_topic);
+			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
 
 		$smcFunc['db_insert']('replace',
 			'{db_prefix}log_topics',
-			array('id_msg' => 'int', 'id_member' => 'int', 'id_topic' => 'int'),
+			array('id_msg' => 'int', 'id_member' => 'int', 'id_topic' => 'int', 'disregarded' => 'int'),
 			$markRead,
 			array('id_member', 'id_topic')
 		);
@@ -199,11 +215,13 @@ function MarkRead()
 	{
 		// First, let's figure out what the latest message is.
 		$result = $smcFunc['db_query']('', '
-			SELECT id_first_msg, id_last_msg
-			FROM {db_prefix}topics
-			WHERE id_topic = {int:current_topic}',
+			SELECT t.id_first_msg, t.id_last_msg, IFNULL(lt.disregarded, 0) as disregarded
+			FROM {db_prefix}topics as t
+			LEFT JOIN {db_prefix}log_topics as lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
+			WHERE t.id_topic = {int:current_topic}',
 			array(
 				'current_topic' => $topic,
+				'current_member' => $user_info['id'],
 			)
 		);
 		$topicinfo = $smcFunc['db_fetch_assoc']($result);
@@ -246,9 +264,10 @@ function MarkRead()
 				FROM {db_prefix}messages
 				WHERE id_topic = {int:current_topic}
 				ORDER BY id_msg
-				LIMIT ' . (int) $_REQUEST['start'] . ', 1',
+				LIMIT {int:start}, 1',
 				array(
 					'current_topic' => $topic,
+					'start' => (int) $_REQUEST['start'],
 				)
 			);
 			list ($earlyMsg) = $smcFunc['db_fetch_row']($result);
@@ -260,8 +279,8 @@ function MarkRead()
 		// Blam, unread!
 		$smcFunc['db_insert']('replace',
 			'{db_prefix}log_topics',
-			array('id_msg' => 'int', 'id_member' => 'int', 'id_topic' => 'int'),
-			array($earlyMsg, $user_info['id'], $topic),
+			array('id_msg' => 'int', 'id_member' => 'int', 'id_topic' => 'int', 'disregarded' => 'int'),
+			array($earlyMsg, $user_info['id'], $topic, $topicinfo['disregarded']),
 			array('id_member', 'id_topic')
 		);
 

+ 1 - 0
Themes/default/languages/ManageSettings.english.php

@@ -20,6 +20,7 @@ $txt['allow_hideOnline'] = 'Allow non-administrators to hide their online status
 $txt['guest_hideContacts'] = 'Do not reveal contact details of members to guests';
 $txt['titlesEnable'] = 'Enable custom titles';
 $txt['enable_buddylist'] = 'Enable buddy/ignore lists';
+$txt['enable_disregard'] = 'Enable disregad topics';
 $txt['default_personal_text'] = 'Default personal text';
 $txt['default_personal_text_note'] = 'Personal text to assign to newly registered members.';
 $txt['time_format'] = 'Default time format';

+ 2 - 0
Themes/default/languages/Profile.english.php

@@ -153,6 +153,7 @@ $txt['showPosts'] = 'Show Posts';
 $txt['showPosts_help'] = 'This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.';
 $txt['showMessages'] = 'Messages';
 $txt['showTopics'] = 'Topics';
+$txt['showDisregarded'] = 'Disregarded topics';
 $txt['showAttachments'] = 'Attachments';
 $txt['viewWarning_help'] = 'This section allows you to view all warnings issued to this member.';
 $txt['statPanel'] = 'Show Stats';
@@ -311,6 +312,7 @@ $txt['show_member_topics'] = 'View Member Topics';
 $txt['show_member_attachments'] = 'View Member Attachments';
 $txt['show_posts_none'] = 'No posts have been posted yet.';
 $txt['show_topics_none'] = 'No topics have been posted yet.';
+$txt['disregarded_topics_none'] = 'You don\'t have any topic in the disregarded list.';
 $txt['show_attachments_none'] = 'No attachments have been posted yet.';
 $txt['show_attach_filename'] = 'Filename';
 $txt['show_attach_downloads'] = 'Downloads';

+ 2 - 0
Themes/default/languages/index.english.php

@@ -371,6 +371,8 @@ $txt['geek'] = 'I am a geek!!';
 $txt['info_center_title'] = '%1$s - Info Center';
 
 $txt['send_topic'] = 'Send this topic';
+$txt['disregard'] = 'Disregard';
+$txt['undisregard'] = 'Stop disregarding';
 
 $txt['sendtopic_title'] = 'Send the topic &quot;%1$s&quot; to a friend.';
 $txt['sendtopic_sender_name'] = 'Your name';

+ 1 - 0
index.php

@@ -273,6 +273,7 @@ function smf_main()
 		'coppa' => array('Register.php', 'CoppaForm'),
 		'credits' => array('Who.php', 'Credits'),
 		'deletemsg' => array('RemoveTopic.php', 'DeleteMessage'),
+		'disregardtopic' => array('Notify.php', 'TopicDisregard'),
 		'dlattach' => array('Display.php', 'Download'),
 		'editpoll' => array('Poll.php', 'EditPoll'),
 		'editpoll2' => array('Poll.php', 'EditPoll2'),

+ 3 - 1
other/install_2-1_mysql.sql

@@ -1159,6 +1159,7 @@ CREATE TABLE {$db_prefix}log_topics (
   id_member mediumint(8) unsigned NOT NULL default '0',
   id_topic mediumint(8) unsigned NOT NULL default '0',
   id_msg int(10) unsigned NOT NULL default '0',
+  disregarded tinyint(3) NOT NULL default '0',
   PRIMARY KEY (id_member, id_topic),
   KEY id_topic (id_topic)
 ) ENGINE=MyISAM;
@@ -1834,7 +1835,8 @@ VALUES ('smfVersion', '{$smf_version}'),
 	('attachment_image_paranoid', '0'),
 	('attachment_thumb_png', '1'),
 	('avatar_reencode', '1'),
-	('avatar_paranoid', '0');
+	('avatar_paranoid', '0'),
+	('enable_disregard', '0');
 # --------------------------------------------------------
 
 #

+ 2 - 0
other/install_2-1_postgresql.sql

@@ -1525,6 +1525,7 @@ CREATE TABLE {$db_prefix}log_topics (
   id_member int NOT NULL default '0',
   id_topic int NOT NULL default '0',
   id_msg int NOT NULL default '0',
+  disregarded int NOT NULL default '0',
   PRIMARY KEY (id_member, id_topic)
 );
 
@@ -2324,6 +2325,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_image_par
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_disregard', '0');
 # --------------------------------------------------------
 
 #

+ 2 - 0
other/install_2-1_sqlite.sql

@@ -1249,6 +1249,7 @@ CREATE TABLE {$db_prefix}log_topics (
   id_member int NOT NULL default '0',
   id_topic int NOT NULL default '0',
   id_msg int NOT NULL default '0',
+  disregarded int NOT NULL default '0',
   PRIMARY KEY (id_member, id_topic)
 );
 
@@ -1980,6 +1981,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_image_par
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_disregard', '0');
 COMMIT;
 
 # --------------------------------------------------------

+ 13 - 0
other/upgrade_2-1_mysql.sql

@@ -179,6 +179,19 @@ ALTER TABLE {$db_prefix}boards
 ADD COLUMN deny_member_groups varchar(255) NOT NULL DEFAULT '';
 ---#
 
+/******************************************************************************/
+--- Adding support for topic disregard
+/******************************************************************************/
+---# Adding new columns to boards...
+ALTER TABLE {$db_prefix}log_topics
+ADD COLUMN disregarded tinyint(3) NOT NULL DEFAULT '0';
+
+INSERT INTO {$db_prefix}settings
+	(variable, value)
+VALUES
+	('enable_disregard', 0);
+---#
+
 /******************************************************************************/
 --- Fixing mail queue for long messages
 /******************************************************************************/

+ 16 - 0
other/upgrade_2-1_postgresql.sql

@@ -236,6 +236,22 @@ upgrade_query("
 ---}
 ---#
 
+/******************************************************************************/
+--- Adding support for topic disregard
+/******************************************************************************/
+---# Adding new columns to log_topics...
+---{
+upgrade_query("
+	ALTER TABLE {$db_prefix}log_topics
+	ADD COLUMN disregarded int NOT NULL DEFAULT '0'");
+
+INSERT INTO {$db_prefix}settings
+	(variable, value)
+VALUES
+	('enable_disregard', 0);
+---}
+---#
+
 /******************************************************************************/
 --- Name changes
 /******************************************************************************/

+ 23 - 0
other/upgrade_2-1_sqlite.sql

@@ -212,6 +212,29 @@ $smcFunc['db_alter_table']('{db_prefix}boards', array(
 ---}
 ---#
 
+/******************************************************************************/
+--- Adding support for topic disregard
+/******************************************************************************/
+---# Adding new columns to log_topics...
+---{
+$smcFunc['db_alter_table']('{db_prefix}log_topics', array(
+	'add' => array(
+		'disregarded' => array(
+			'name' => 'disregarded',
+			'null' => false,
+			'default' => 0,
+			'type' => 'int',
+			'auto' => false,
+		),
+	)
+));
+INSERT INTO {$db_prefix}settings
+	(variable, value)
+VALUES
+	('enable_disregard', 0);
+---}
+---#
+
 /******************************************************************************/
 --- Name changes
 /******************************************************************************/