Esempio n. 1
0
function print_forums($parentid = -1, $indent = "\t")
{
    // new version - DRASTICALLY reduces queries...
    global $vbulletin, $imodcache, $accesscache, $vbphrase;
    // check to see if we need to do the queries
    if (empty($vbulletin->iforumcache)) {
        cache_ordered_forums(0, 1);
    }
    if (!is_array($imodcache)) {
        require_once DIR . '/includes/functions_forumlist.php';
        cache_moderators();
    }
    // check to see if this forum actually exists / has children
    if (empty($vbulletin->iforumcache["{$parentid}"])) {
        return;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forum =& $vbulletin->forumcache["{$forumid}"];
        echo "{$indent}<ul class=\"lsq\">\n";
        // forum title and links
        echo "{$indent}<li><b><a name=\"forum{$forumid}\" href=\"forum.php?{$session['sessionurl']}do=edit&amp;f={$forumid}\">{$forum['title']}</a> <span class=\"smallfont\">(" . construct_link_code($vbphrase['reset'], "accessmask.php?{$session['sessionurl']}do=resetforum&amp;f={$forumid}&amp;hash=" . CP_SESSIONHASH) . ")</span></b>";
        // get moderators
        if (is_array($imodcache["{$forumid}"])) {
            echo "<span class=\"smallfont\"><br /> - <i>" . $vbphrase['moderators'] . ":";
            foreach ($imodcache["{$forumid}"] as $moderator) {
                // moderator username and links
                echo " <a href=\"moderator.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;moderatorid={$moderator['moderatorid']}\">{$moderator['username']}</a>";
            }
            echo "</i></span>";
        }
        $allaccessmasks = 0;
        $forbidden = '';
        $permitted = '';
        $deny = $accesscache["{$forumid}"]['0'];
        $permit = $accesscache["{$forumid}"]['1'];
        /*echo "<pre>--$forumid--\n";
        		print_r($accesscache["$forumid"]);
        		echo '</pre>';*/
        if (is_array($deny)) {
            $forbidden = "{$indent}\t<li class=\"am-deny\"><b>" . construct_phrase($vbphrase['access_denied_x_users'], $deny['count']) . '</b>' . construct_link_code($vbphrase['display_users'], "accessmask.php?" . $vbulletin->session->vars['sessionurl'] . "&do=edit&f={$forumid}&accessmask={$deny['accessmask']}") . "</li>\n";
            $allaccessmasks = $deny['count'];
        }
        if (is_array($permit)) {
            $permitted = "{$indent}\t<li class=\"am-grant\"><b>" . construct_phrase($vbphrase['access_granted_x_users'], $permit['count']) . '</b>' . construct_link_code($vbphrase['display_users'], "accessmask.php?" . $vbulletin->session->vars['sessionurl'] . "&do=edit&f={$forumid}&accessmask={$permit['accessmask']}") . "</li>\n";
            $allaccessmasks = $allaccessmasks + $permit['count'];
        }
        if ($allaccessmasks > 0) {
            echo "{$indent}\t<ul class=\"usergroups\">\n";
            echo "{$indent}\t<li>" . construct_phrase($vbphrase['x_access_masks_set'], $allaccessmasks) . ' ' . construct_link_code('<b>' . $vbphrase['display_all_users'] . '</b>', "accessmask.php?" . $vbulletin->session->vars['sessionurl'] . "&do=edit&f={$forum['forumid']}&accessmask=2") . "</li>";
            echo $permitted;
            echo $forbidden;
            echo "{$indent}\t</ul><br />\n";
        } else {
            echo "{$indent}\t\n";
            echo "{$indent}\t<br />\n";
        }
        print_forums($forumid, "{$indent}\t");
        echo "{$indent}</li>\n";
        echo "{$indent}</ul>\n";
        if ($forum['parentid'] == -1) {
            echo "<hr size=\"1\" />\n";
        }
    }
    unset($vbulletin->iforumcache["{$parentid}"]);
}
Esempio n. 2
0
function print_forums($permissions, $inheritance = array(), $parentid = -1, $indent = '	')
{
    global $vbulletin, $permscache;
    global $imodcache, $fpermscache, $vbphrase;
    // check to see if this forum actually exists / has children
    if (empty($vbulletin->iforumcache["{$parentid}"])) {
        return;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        if (!defined('ONLYID')) {
            echo "{$indent}<ul class=\"lsq\">\n";
        }
        // get current forum info
        $forum =& $vbulletin->forumcache["{$forumid}"];
        // make a copy of the current permissions set up
        $perms = $permissions;
        // make a copy of the inheritance set up
        $inherit = $inheritance;
        if ($forumid == ONLYID) {
            echo "{$indent}<ul class=\"lsq\">\n";
        }
        // echo forum title and links
        if ($forumid == ONLYID or !defined('ONLYID')) {
            echo "{$indent}<li><b><a name=\"forum{$forumid}\" href=\"forum.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;f={$forumid}\">{$forum['title']}</a> <span class=\"smallfont\">(" . construct_link_code($vbphrase['reset'], "forumpermission.php?" . $vbulletin->session->vars['sessionurl'] . "do=quickset&amp;type=reset&amp;f={$forumid}&amp;hash=" . CP_SESSIONHASH) . construct_link_code($vbphrase['deny_all'], "forumpermission.php?" . $vbulletin->session->vars['sessionurl'] . "do=quickset&amp;type=deny&amp;f={$forumid}&amp;hash=" . CP_SESSIONHASH) . ")</span></b>";
            // get moderators
            if (is_array($imodcache["{$forumid}"])) {
                echo "<span class=\"smallfont\"><br /> - <i>" . $vbphrase['moderators'] . ":";
                foreach ($imodcache["{$forumid}"] as $moderator) {
                    // moderator username and links
                    echo " <a href=\"moderator.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;moderatorid={$moderator['moderatorid']}\">{$moderator['username']}</a>";
                }
                echo "</i></span>";
            }
            echo "{$indent}\t<ul class=\"usergroups\">\n";
        }
        foreach ($vbulletin->usergroupcache as $usergroupid => $usergroup) {
            if ($inherit["{$usergroupid}"] == 'col-c') {
                $inherit["{$usergroupid}"] = 'col-i';
            }
            // if there is a custom permission for the current usergroup, use it
            if (isset($fpermscache["{$forumid}"]["{$usergroupid}"])) {
                $inherit["{$usergroupid}"] = 'col-c';
                $perms["{$usergroupid}"] = $fpermscache["{$forumid}"]["{$usergroupid}"]['forumpermissions'];
                $fplink = 'fp=' . $fpermscache["{$forumid}"]["{$usergroupid}"]['forumpermissionid'];
            } else {
                $fplink = "f={$forumid}&amp;u={$usergroupid}";
            }
            // work out display style
            $liStyle = '';
            if (isset($inherit["{$usergroupid}"])) {
                $liStyle = " class=\"{$inherit[$usergroupid]}\"";
            }
            if (!($perms["{$usergroupid}"] & $vbulletin->bf_ugp_forumpermissions['canview'])) {
                $liStyle .= " style=\"list-style:circle\"";
            }
            if ($forumid == ONLYID or !defined('ONLYID')) {
                echo "{$indent}\t<li{$liStyle}>" . construct_link_code($vbphrase['edit'], "forumpermission.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;{$fplink}") . $usergroup['title'] . "</li>\n";
            }
        }
        if ($forumid == ONLYID or !defined('ONLYID')) {
            echo "{$indent}\t</ul><br />\n";
        }
        if ($forumid == ONLYID and defined('ONLYID')) {
            echo "{$indent}</li>\n";
            echo "{$indent}</ul>\n";
            return;
        }
        print_forums($perms, $inherit, $forumid, "{$indent}\t");
        if ($forumid == ONLYID or !defined('ONLYID')) {
            echo "{$indent}</li>\n";
        }
        unset($inherit);
        if ($forumid == ONLYID or !defined('ONLYID')) {
            echo "{$indent}</ul>\n";
        }
        if ($forum['parentid'] == -1 and !defined('ONLYID')) {
            echo "<hr size=\"1\" />\n";
        }
    }
}