Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

allow_featured_collection_share()

Description

Check if user is allowed to share featured collection. If the featured collection provided is a category, then this
function will return FALSE if at least one sub featured collection has no share access (this is kept consistent with
the check for normal collections when checking resources).

Parameters

ColumnTypeDefaultDescription
$c array Collection data. You can add "has_resources" and "sub_fcs" keys if you already have this information

Return

boolean Return TRUE if user is allowed to share the featured collection, FALSE otherwise

Location

include/collections_functions.php lines 6010 to 6044

Definition

 
function allow_featured_collection_share(array $c)
    {
    if(
$c["type"] != COLLECTION_TYPE_FEATURED)
        {
        return 
allow_collection_share($c);
        }

    if(!
featured_collection_check_access_control($c["ref"]))
        {
        return 
false;
        }

    if(!isset(
$c["has_resources"]))
        {
        
$collection_resources get_collection_resources($c["ref"]);
        
$c["has_resources"] = (is_array($collection_resources) && !empty($collection_resources) ? 0);
        }

    
// Not a category, can be treated as a simple collection
    
if(!is_featured_collection_category($c))
        {
        return 
allow_collection_share($c);
        }

    
$sub_fcs = (!isset($c["sub_fcs"]) ? get_featured_collection_categ_sub_fcs($c) : $c["sub_fcs"]);
    return 
array_reduce($sub_fcs, function($carry$item)
        {
        
// Fake a collection data structure. allow_collection_share() only needs the ref
        
$c = array("ref" => $item);
        
$fc_allow_share allow_collection_share($c);

        
// FALSE if at least one collection has no share access (consistent with the check for normal collections when checking resources)
        
return !is_bool($carry) ? $fc_allow_share $carry && $fc_allow_share;
        }, 
null);
    }

This article was last updated 18th April 2024 12:05 Europe/London time based on the source file dated 15th April 2024 12:15 Europe/London time.