Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

featured_collection_check_access_control()

Description

Access control function used to determine if a featured collection should be accessed by the user

Parameters

ColumnTypeDefaultDescription
$c_ref integer Collection ref to be tested

Return

boolean Returns TRUE if user should have access to the featured collection (no parent category prevents this), FALSE otherwise

Location

include/collections_functions.php lines 4521 to 4561

Definition

 
function featured_collection_check_access_control(int $c_ref)
    {
    if(
checkperm("-j" $c_ref))
        {
        return 
false;
        }
    elseif(
checkperm("j*") || checkperm("j" $c_ref))
        {
        return 
true;
        }
    else
        {
        
// Get all parents
        
$allparents sql_query("
                SELECT  C2.ref, C2.parent
                  FROM  (SELECT @r AS p_ref,
                        (SELECT @r := parent FROM collection WHERE ref = p_ref) AS parent,
                        @l := @l + 1 AS lvl
                  FROM  (SELECT @r := '" 
$c_ref "', @l := 0) vars,
                        collection c
                 WHERE  @r <> 0) C1
                  JOIN  collection C2
                    ON  C1.p_ref = C2.ref
              ORDER BY  C1.lvl DESC"
,
                
"featured_collections");

          foreach(
$allparents as $parent)
                {
                if(
checkperm("-j" $parent["ref"]))
                    {
                    
// Denied access to parent
                    
return false;
                    }
                elseif(
checkperm("j" $parent["ref"]))
                    {
                    return 
true;
                    }
                }
        return 
false// No explicit permission given and user doesn't have f*
        
}
    }

This article was last updated 25th January 2021 09:35 Europe/London time based on the source file dated 19th January 2021 16:15 Europe/London time.