MyBB Community Forums

Full Version: Plugin "Latest Posts on sidebar" showing Draft Posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Plugin: http://community.mybb.com/mods.php?action=view&pid=291
My suggestion: http://community.mybb.com/mods.php?actio...291&sid=67

I use the "Latest Posts on sidebar" plugin, but in the sidebar, I noticed that there are a couple posts that when clicked, it said no thread exisits.. so my developer and I did some research and couldn't find anything in the Mod Log that the post was deleted.. I checked the database and it was still there. So we were clueless for a moment but then I noticed that "visible" was set to -2. I honestly didn't know what -2 was, but my developer said it was a draft.. so this is how we fixed it:

I edited the plugin's query on line 229 of the plugin's php file located in /inc/plugins:

$query = $db->query("
	SELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, lp.usergroup AS lastusergroup, lp.displaygroup as lastdisplaygroup, p.visible
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
	LEFT JOIN ".TABLE_PREFIX."users lp ON (t.lastposteruid=lp.uid)
	LEFT JOIN ".TABLE_PREFIX."posts p ON (t.tid=p.tid AND replyto = 0)
	WHERE 1=1 {$where}
	ORDER BY t.lastpost DESC
	LIMIT $threadlimit
");

I added to the WHERE clause: 

AND p.visible = '1'

So the outcome would be this: 

$query = $db->query("
	SELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, lp.usergroup AS lastusergroup, lp.displaygroup as lastdisplaygroup, p.visible
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
	LEFT JOIN ".TABLE_PREFIX."users lp ON (t.lastposteruid=lp.uid)
	LEFT JOIN ".TABLE_PREFIX."posts p ON (t.tid=p.tid AND replyto = 0)
	WHERE 1=1 {$where} AND p.visible = '1'
	ORDER BY t.lastpost DESC
	LIMIT $threadlimit
");

Great plugin by the way!
Hope this helps!
Thanks for info, but please post this in the plugin release thread next time.
(2015-09-11, 10:54 PM)Destroy666 Wrote: [ -> ]Thanks for info, but please post this in the plugin release thread next time.

Oops.. sorry about that.