View Single Post
  #15  
Old 08-31-2002, 12:10 PM
tHE DSS's Avatar
tHE DSS tHE DSS is offline
 
Join Date: Jun 2002
Location: UK
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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_resultMYSQL_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_resultMYSQL_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.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01277 seconds
  • Memory Usage 1,829KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete