MyBB Community Forums
How to select only guest visible threads? - Printable Version

+- MyBB Community Forums (
+-- Forum: Extensions (
+--- Forum: Plugins (
+---- Forum: Plugin Development (
+---- Thread: How to select only guest visible threads? (/thread-139506.html)

How to select only guest visible threads? - blogantinom - 05-17-2013

I am creating a plugin to show the top threads on the index page, and now instead of running the query by each user, I will do it on a task and cache it to be shown by the index hook.

I was using the query below, but I would like to show only threads that are visible to guests, so that I can keep one single version of the topposts.

How can I achieve this?

Quote:$query = $db->query ("
SELECT t.subject,t.username,t.uid,t.tid,t.fid,t.lastpost,t.lastposter,t.lastposteruid,t.replies, t.views,tr.uid AS truid,tr.dateline, ,
TRUNCATE(t.totalratings/t.numratings*2+t.numratings/8+tyl_tnumtyls+t.replies+t.views/15,2) ranking
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='".$mybb->user['uid']."')
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid = t.fid)
WHERE t.visible='1'
AND t.closed NOT LIKE 'moved|%'
AND t.dateline >=UNIX_TIMESTAMP()-(86400*".$days.") ORDER BY ranking DESC
LIMIT 0,".$NumOfRows);