Log in

View Full Version : PLEASE HELP!! How do you access the $_FORUMOPTIONS['showonforumjump']


dwh
01-25-2005, 03:32 PM
I'm trying to write some code that pulls up only the forum that the current user can use, NOT including the forums the current user is not allowed to view and NOT including the forums that are not $_FORUMOPTIONS['showonforumjump'].

I was doing great by copying the routine from the /archive/global.php subroutine for getting foruminfo. The only problem is there was nothing about 'showonforumjump'. So I went to the functions.php subroutine and all it says there is
!($forumcache["$forumid"]['options'] & $_FORUMOPTIONS['showonforumjump'])

If I try to copy that into my new subroutine, it doesn't work at all. If I print it out, all it says is 65536, regardless which forum, even forums marked as not showonforumjump.

There must be some way to access this. That's why I keep saying the permission system in vb is very good, but how the hell does it work?

Thank you in advance for any help you can offer.

Andreas
01-25-2005, 03:49 PM
Hmm, does work for me:


<?php
require_once('./global.php');
foreach ($forumcache AS $forumid => $forum) {
echo intval(!($forumcache[$forumid]['options'] & $_FORUMOPTIONS['showonforumjump'])) . '<br>';
}
?>

dwh
01-25-2005, 04:02 PM
Here's my code. It all prints out the same permission even for forums I know are not showonforumjump. What did I do wrong?

// function to list forums
function print_my_forum_list($parentid = -1)
{
global $DB_site, $session, $vboptions, $bbuserinfo, $iforumcache, $_FORUMOPTIONS, $myforumbits;
if (!is_array($iforumcache))
{
$forums = $DB_site->query("
SELECT forumid, title, link, parentid, displayorder,
(options & $_FORUMOPTIONS[cancontainthreads]) AS cancontainthreads
FROM " . TABLE_PREFIX . "forum AS forum
WHERE displayorder <> 0 AND
password = '' AND
(options & $_FORUMOPTIONS[active])
ORDER BY displayorder
");
$iforumcache = array();
while ($forum = $DB_site->fetch_array($forums))
{
$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forum[forumid]"] = $forum;
}
unset($forum);
$DB_site->free_result($forums);
}
if (is_array($iforumcache["$parentid"]))
{
foreach($iforumcache["$parentid"] AS $x)
{
foreach($x AS $forumid => $forum)
{
if (!($bbuserinfo['forumpermissions']["$forumid"] & CANVIEW) AND $vboptions['hideprivateforums'])
{
continue;
}
else
{
if ($forum['link'] !== '')
{
continue;
}
else if ($forum['cancontainthreads'])
{
$myforumbits.="<br>$forumid - $forum[title] - ";
//TEST print out permissions for showonforumjump
echo "<br>$forumid - $forum[title] - <b>".$_FORUMOPTIONS['showonforumjump']."</b>";
}
print_my_forum_list($forumid);
}
}
}
}
}
print_my_forum_list();

Andreas
01-25-2005, 04:13 PM
echo "<br>$forumid - $forum[title] - <b>".$_FORUMOPTIONS['showonforumjump']."</b>";

Well, $_FORUMOPTIONS['showonforumjump'] is 65536 so you shouldn't be surprised if it does display 65536 ;)

I think you want this:

echo "<br>$forumid - $forum[title] - <b>". intval($forum['options'] & $_FORUMOPTIONS['showonforumjump']) ."</b>";


But for this to work, $iforumcache must have options - which currently doesn't seem to be (it is not included in the query).
So either include it their, or directly check the bit in the query (like as it is done with cancontainthreads)

dwh
01-25-2005, 04:28 PM
Thank you I figured it out and got it working :)