PDA

View Full Version : Problem with print_no_permission


Booyakan
04-01-2011, 06:57 PM
I want to not allow a thread to be viewed (I will later add conditionals for certain usergroups). My problem is that EVERY thread cannot be viewed and I cannot figure it out. Any help would be appreciated, thanks.

I have this code in my SHOWTHREAD

<if condition="$threadinfo['threadid'] == 1014">
$includedphp
</if>

And I have made a global_start plugin to include a file with print_no_permission

ob_start();
include('test.php');
$includedphp = ob_get_contents();
ob_end_clean();

Here is my test.php file contents

<?php
print_no_permission();
?>
--------------------------------------------------------------------------------------------------------------------------------
Thing I don't understand is that when I do this code instead on my included test.php file, it does work for outputting the text on just that thread.

<?php
echo "hello";
?>

kh99
04-01-2011, 09:36 PM
I think the problem is that print_no_permissiion() doesn't just produce output that you can capture in a string, it has other side effects. I think what you'll want to do is create a plugin using a hook near the start of showthread.php and check the thread id there.

Booyakan
04-01-2011, 09:40 PM
I think the problem is that print_no_permissiion() doesn't just produce output that you can capture in a string, it has other side effects. I think what you'll want to do is create a plugin using a hook near the start of showthread.php and check the thread id there.

Yes, it was actually breaking my forum using global_start. I tried a few different showthread hooks but it still gives me no permission on EVERY thread. Is there another call I should be using instead of print_no_permission?

Lynne
04-01-2011, 09:42 PM
Just use a plugin at the top of the showthread page and check there:

if ($threadinfo['threadid'] == x) print_no_permission();

Booyakan
04-01-2011, 10:10 PM
Thank you both.

I ended up not using any plugins or includes. I just edited my showthread.php. That worked for me. If anyone sees anything wrong with doing it this way please let me know, thanks.

************************************************** ****************************** *
// check forum permissions
$forumperms = fetch_permissions($thread['forumid']);
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR ($threadinfo['threadid'] == 1014)
)
{
print_no_permission();
}
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($thread['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))
{
print_no_permission();
}

//

Lynne
04-02-2011, 02:59 AM
The problem I see with that is that you now need to remember to edit that file every time you upgrade. Other than that, it's fine. We used to always have to remember which files we edited and edit them again and it worked for us back then (back when we walked six miles to school, in the snow, both ways.... ) . :)

Boofo
04-02-2011, 03:03 AM
We used to always have to remember which files we edited and edit them again and it worked for us back then (back when we walked six miles to school, in the snow, both ways.... ) . :)

Uphill with no shoes!

Lynne
04-02-2011, 03:07 AM
Uphill with no shoes!
Or in high heels. :D