MyBB Community Forums

Full Version: MyBB Advanced Sidebox - Only show latest threads from certain forums, if it's....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We have a sponsor's forum. Basically we don't want threads showing up in latest threads box from their forums unless it's a thread started by a sponsor.

Example logic: if FID==#,#,# and OP UID <> #,#,#, then don't show the thread in latest threads box.

Is this possible?

Now we have this to keep other certain forums totally out (Mod forums etc...), but it doesn't cover the above mentioned situation, as we still want threads started by the forum sponsor to show from their forums.

	// get forums user cannot view
	$unviewable = get_unviewable_forums(true);
        $unviewable .= "'0','70'";  
	if($unviewable)
	{
		$unviewwhere = " AND fid NOT IN ({$unviewable})";
	}
I believe your sponsors are in a different dedicated group.

I didn't see the function in the plugin but this can be done modifying the query using LEFT JOIN the users table, adding additional WHERE clause.
They're just normal users at this point. I hadn't found the need to separate them. So they could be put in their own group and the logic could be GID instead of UID.

Anyways "modifying the query using LEFT JOIN the users table, adding additional WHERE clause. ". That is beyond me. Can you be more specific the exact steps and code I'd need to use? Or is it a very complicated process?

I was hoping it could be added somehow into the php easily as it was with completely eliminating certain forums.

I realize it's quite a unique request.
Again, I'm not digging into the main plugin, here is an example of what I meant:

$target_forums = "12,35"; // Can be loaded from plugin settings
$group_filter = preg_replace('/[^\d,]+/', '', $mybb->settings['sponsor_groups']); // Example for loading from plugin settings, with cleanup
$limit = 10; // How many latest threads to show
$query = $db->query("
SELECT t.tid, t.uid, t.username, t.subject 
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON(t.uid = u.uid)
WHERE t.fid IN ({$target_forums}) AND u.usergroup IN({$group_filter}) ORDER BY `dateline` DESC LIMIT $limit;"); // Covered only main groups, not additionals, just for example ...
Yea, this is well beyond me as to where and how to add it and mod it to fit my situation.

If anyone else has some suggestions, please let me know.

There are alternatives, such as making it so only sponsors can post in their forum and creating a sub-forum for user complaints and reviews, then eliminate it as posted in the OP. But I'd prefer not to do it that way.
I'm sure Wildcard will shoot your trouble, else just drop me a PM, if you don't get any help at all and I'll try modifying the plugin for you in a spare time.
The latest thread module doesn't have the ability to behave as you want at this point, but if I could be sure what you are saying exactly then I'll try to help you make a module to do what you want.

Quote:Basically we don't want threads showing up in latest threads box from their forums unless it's a thread started by a sponsor.

What do you mean by 'from their forums'? Which forums do you mean?
The example logic is

if FID==# or # or # (forum numbers of the sponsor's forums) and OP UID (forum sponsors and admins) <> #,#,#, then don't show the thread in latest threads box.

But we need it to integrate with advanced side box.
I haven't tested this, but I think you can use this:

// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
	$unviewwhere = " AND t.fid NOT IN ({$unviewable}) AND NOT (t.fid IN (#, #, #) AND NOT t.uid IN (#, #, #))";
}

You would of course need to change the first set of #'s with the forum ids and the second set with the user ids.


EDIT: I just realized that would only be effective if there are forums the user cannot view (which is probably the case, but still . . .)

Just change line 287 from this:

$query_where = $unviewwhere . asb_build_SQL_where($where, ' AND ', ' AND ');

to the this

$query_where = $unviewwhere . asb_build_SQL_where($where, ' AND ', ' AND ') . " AND NOT (t.fid IN (#, #, #) AND NOT t.uid IN (#, #, #))";

again change the #'s