Posts: 872
Threads: 221
Joined: Feb 2013
Reputation:
18
2014-03-06, 04:49 PM
(This post was last modified: 2014-03-06, 05:03 PM by DrXotick.)
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})";
}
Posts: 4,081
Threads: 120
Joined: May 2012
Reputation:
477
2014-03-06, 04:58 PM
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.
Posts: 872
Threads: 221
Joined: Feb 2013
Reputation:
18
2014-03-06, 05:12 PM
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.
Posts: 4,081
Threads: 120
Joined: May 2012
Reputation:
477
2014-03-06, 05:22 PM
(This post was last modified: 2014-03-06, 05:32 PM by effone.)
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 ...
Posts: 872
Threads: 221
Joined: Feb 2013
Reputation:
18
2014-03-06, 05:25 PM
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.
Posts: 4,081
Threads: 120
Joined: May 2012
Reputation:
477
2014-03-06, 05:35 PM
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.
Posts: 2,753
Threads: 63
Joined: Nov 2011
Reputation:
261
2014-03-07, 01:53 AM
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?
[retired]
Posts: 872
Threads: 221
Joined: Feb 2013
Reputation:
18
2014-03-07, 02:04 AM
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.
Posts: 2,753
Threads: 63
Joined: Nov 2011
Reputation:
261
2014-03-07, 02:29 AM
(This post was last modified: 2014-03-07, 07:27 PM by Wildcard.)
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
[retired]
|