public static function getPermissionString($userid = false) { if (($userid === false) AND ($userid !== 0)) { $userid = vB::$vbulletin->userinfo['userid']; } if (($userid == vB::$vbulletin->userinfo['userid']) AND self::$permission_string) { return self::$permission_string; } require_once DIR . '/includes/class_bootstrap_framework.php' ; vB_Bootstrap_Framework::init(); $can_view = array(); $blocked = array(); $perms = self::getPerms($userid); //We need to block out unpublished sections. $sections = vBCms_ContentManager::getSections(); foreach($sections as $section) { $can_view_this = (intval($section['setpublish']) > 0) && ($section['publishdate'] < TIMENOW); if (!$can_view_this) { $blocked[$section['nodeid']] = 1; if (isset($can_view[$section['nodeid']])) { unset($can_view[$section['nodeid']]); } } else if (!isset($can_view[$section['nodeid']]) AND ! isset($blocked[$section['nodeid']])) { $can_view[$section['nodeid']] = 1; } } $canedit = array_unique(array_merge($perms['canedit'], $perms['canpublish'])); self::$permission_string = "( (node.permissionsfrom IN (" . implode(',', $canedit) . "))"; if (intval($userid)) { self::$permission_string .= " OR (node.userid =" . vB::$vbulletin->userinfo['userid'] . ") "; } if (!empty($can_view)) { self::$permission_string .= " OR ( node.permissionsfrom in (" . implode(',', $perms['canview']) . ") AND (node.parentnode IN (" . implode(',', array_keys($can_view)) . ")" . (isset($can_view[1]) ? " OR node.nodeid = 1" : "") . "))"; } self::$permission_string .= ")"; return self::$permission_string; }