You could use this :
PHP Code:
// generate string list of non-viewable forums, relative to current visitor
$forumsCannotView_strList = getForumPermissions($bbuserinfo[usergroupid]);
// generate WHERE clause for non-viewable forums, if any
$whereClause = ($forumsCannotView_strList != "") ? ("(forumid NOT IN ($forumsCannotView_strList)) AND") : ("");
// set return LIMIT
$return_limit = 1;
// query THREAD table, for top REPLIED TO thread
if ($forumsCannotView_strList != "") {
$topReplyThread_result = $DB_site->query("SELECT threadid,title,lastpost,postusername,lastposter
FROM thread WHERE $whereClause visible=1 AND open=1
ORDER BY replycount DESC
LIMIT $return_limit");
}
// query THREAD table, for top VIEWED thread
if ($forumsCannotView_strList != "") {
$topViewedThread_result = $DB_site->query("SELECT threadid,title,lastpost,postusername,lastposter
FROM thread WHERE $whereClause visible=1 AND open=1
ORDER BY views DESC
LIMIT $return_limit");
}
// extract and format top REPLIED TO thread
if (!$num_rows = $DB_site->num_rows($topReplyThread_result) <=0) {
while ($row = $DB_site->fetch_array($topReplyThread_result, MYSQL_ASSOC)) {
// put thread title into a link
$threadTitle = "<a href=\"http://YOUR_FORUMS_PATH/showthread.php?s=$session[sessionhash]&threadid=$row[threadid]\" target=\"_blank\">$row[title]</a>";
// get thread starter
$threadStarter = $row[postusername];
// get last poster
$lastPoster = $row[lastposter];
// get time of last post, relative to the current visitor's timezone offset, set in their forum options
$timezoneoffsetstamp = $bbuserinfo[timezoneoffset] * 3600;
$timeDate = date("$dateformat @ $timeformat", $row[lastpost] + $timezoneoffsetstamp);
// print it out to the browser
echo "Top REPLIED TO Thread : $threadTitle | $threadStarter | $lastPoster | $timeDate<br>";
}
} else {
echo "No data for top REPLIED TO Thread";
}
// extract and format top VIEWED thread
if (!$num_rows = $DB_site->num_rows($topViewedThread_result) <=0) {
while ($row = $DB_site->fetch_array($topViewedThread_result, MYSQL_ASSOC)) {
// put thread title into a link
$threadTitle = "<a href=\"http://YOUR_FORUMS_PATH/showthread.php?s=$session[sessionhash]&threadid=$row[threadid]\" target=\"_blank\">$row[title]</a>";
// get thread starter
$threadStarter = $row[postusername];
// get last poster
$lastPoster = $row[lastposter];
// get time of last post, relative to the current visitor's timezone offset, set in their forum options
$timezoneoffsetstamp = $bbuserinfo[timezoneoffset] * 3600;
$timeDate = date("$dateformat @ $timeformat", $row[lastpost] + $timezoneoffsetstamp);
// print it out to the browser
echo "Top VIEWED Thread : $threadTitle | $threadStarter | $lastPoster | $timeDate<br>";
}
} else {
echo "No data for top VEIWED Thread";
}
... which will get the stuff you need, for threads that are inside the visitors viewable forums, and that are open... no locked threads will be returned.
As far as i've tested, this only works (and only intended) for forums that have parent forum permissions - it doesn't cater for access masks... I believe that forums using their parent forum permissions show up in BLUE, in the forum permissions panel in the Admin CP... like this :
Code:
Example Forums
(COPPA) Users Awaiting Moderation
Administrators
.... etc ....
.... etc ....
Registered
.... etc ....
Example Sub Forum, Of Above Category
(COPPA) Users Awaiting Moderation
Administrators
.... etc ....
.... etc ....
Registered
.... etc ....
... i've done abit more testing since, and believe that forums using custom permissions may also be able to benefit from this function... they show up in red in the AdminCP.
Best to test it out yourself though, to be sure in your own mind.
You can simply echo out the returned string list, like this :
PHP Code:
// generate string list of non-viewable forums, relative to current visitor
$forumsCannotView_strList = getForumPermissions($bbuserinfo[usergroupid]);
// echo out string list
echo $forumsCannotView_strList;
... then check all the comma separated values, against your forum ids.
Play about with forum permissions, and log-in and out as different member groups, and see if the forums that get returned are the only ones viewable by that group.