vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Trying to figure out if a thread is visible to guests... (https://vborg.vbsupport.ru/showthread.php?t=267182)

BirdOPrey5 07-21-2011 01:29 PM

Trying to figure out if a thread is visible to guests...
 
I opened showthread.php and found this code which deals with if the user has permission to view the thread:

PHP Code:

// *********************************************************************************
// check forum permissions
$forumperms fetch_permissions($thread['forumid']);
if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
{
    
print_no_permission();


The fetch_permissions function can take an optional second parameter to fetch permission for another user...

So I have this in a plugin:

PHP Code:

    $bopguest 0;

    
$bopguest fetch_userinfo($bopguest);

$forumperms fetch_permissions($threadinfo['forumid'], $bopguest);
if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
{
    
$joetest "NO PERMISSION";
}
else
{
    
$joetest "ok";


if $bopguest equals any true userid it works as expected... however to get guest/not-logged-in permission I thought maybe I could set $bopguest = 0. But that doesn't work I always get no permission even when guests do have permission... and yes $threadinfo['forumid'] is valid on the hook I am using.

Any ideas? I don't see any special code to deal with guests only...

kh99 07-21-2011 01:58 PM

It looks like if you pass a user id for the second param you need to also pass a userinfo array as the third param, otherwise it always returns 0. I didn't trace everything all the way through, but you might be able to get away with just passing array('usergroupid' => 1).

BirdOPrey5 07-21-2011 02:27 PM

Thanks Kevin, that was exactly right. I needed to pass the that array as the 3rd param. Works now. :)


All times are GMT. The time now is 09:49 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01764 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete