function fetch_forum_permissions($fid, $gid, $groupperms)
{
global $groupscache, $forum_cache, $fpermcache, $mybb, $fpermfields;
$groups = explode(",", $gid);
if(empty($fpermcache[$fid])) // This forum has no custom or inherited permissions so lets just return the group permissions
{
return $groupperms;
}
$current_permissions = array();
$only_view_own_threads = 1;
$erik_canview = 1; //Hack von Erik
foreach($groups as $gid)
{
if($groupscache[$gid])
{
$level_permissions = $fpermcache[$fid][$gid];
// If our permissions arn't inherited we need to figure them out
if(empty($level_permissions))
{
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if(!empty($parents))
{
foreach($parents as $parent_id)
{
if(!empty($fpermcache[$parent_id][$gid]))
{
$level_permissions = $fpermcache[$parent_id][$gid];
break;
}
}
// If we STILL don't have forum permissions we use the usergroup itself
if(empty($level_permissions))
{
$level_permissions = $groupscache[$gid];
}
}
}
foreach($level_permissions as $permission => $access)
{
if($access >= $current_permissions[$permission] || ($access == "yes" && $current_permissions[$permission] == "no") || !$current_permissions[$permission])
{
$current_permissions[$permission] = $access;
}
}
if($level_permissions["canview"] && !$level_permissions["canonlyviewownthreads"])
{
$only_view_own_threads = 0;
}
if($level_permissions["canview"]==0)
{
$erik_canview = 0; //Hack von Erik
}
}
}
// Figure out if we can view more than our own threads
if($only_view_own_threads == 0)
{
$current_permissions["canonlyviewownthreads"] = 0;
}
if(count($current_permissions) == 0)
{
$current_permissions = $groupperms;
}
if($erik_canview == 0 && !in_array(4, $groups)) //admin has view rights to all
{
$current_permissions["canview"] = 0; //Hack von Erik
}
return $current_permissions;
}