Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 6057 to 6091

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 4th December 2024 08:35 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.