Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enhancement Increment Thread Counter on Registered member view only
#1
INSERT INTO `mybb_settings` (`sid`, `name`, `title`, `description`, `optionscode`, `value`, `disporder`, `gid`, `isdefault`) VALUES (NULL, 'registeredthreadviews', 'Registered Members Thread View Only', 'If this setting is enabled, thread view counters are incremented for registered users only. Excludes views made by the topic starter.', 'onoff', '0', '15', '8', '1');

showthread.php

Find:

if($mybb->settings['delayedthreadviews'] == 1)
{
$db->shutdown_query("INSERT INTO ".TABLE_PREFIX."threadviews (tid) VALUES('{$tid}')");
}
else
{
$db->shutdown_query("UPDATE ".TABLE_PREFIX."threads SET views=views+1 WHERE tid='{$tid}'");
}
++$thread['views'];

Replace with:

if ($mybb->settings['registeredthreadviews'] == 1)
{
	if ( ($mybb->user['uid'] != 0) && ($mybb->user['uid'] != $thread['uid']) )
	{			
		if($mybb->settings['delayedthreadviews'] == 1)
		{
			$db->shutdown_query("INSERT INTO ".TABLE_PREFIX."threadviews (tid) VALUES('{$tid}')");
		}
		else
		{
			$db->shutdown_query("UPDATE ".TABLE_PREFIX."threads SET views=views+1 WHERE tid='{$tid}'");
		}
		++$thread['views'];
	}
}
else
{
	if($mybb->settings['delayedthreadviews'] == 1)
	{
		$db->shutdown_query("INSERT INTO ".TABLE_PREFIX."threadviews (tid) VALUES('{$tid}')");
	}
	else
	{
		$db->shutdown_query("UPDATE ".TABLE_PREFIX."threads SET views=views+1 WHERE tid='{$tid}'");
	}
	++$thread['views'];
}

[Image: registeredviewsonly.png]
What goes around comes around
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)