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

get_featured_collections_by_resources()

Description

Get all featured collections branches where the specified resources can be found.

Parameters

ColumnTypeDefaultDescription
$r_refs array List of resource IDs

Return

array Returns list of featured collections (categories included) that contain the specified resource(s).

Location

include/collections_functions.php lines 4940 to 4967

Definition

 
function get_featured_collections_by_resources(array $r_refs)
    {
    
$resources array_filter($r_refs"is_numeric");
    if(empty(
$resources))
        {
        return array();
        }

    
$sql sprintf(
        
"SELECT c.ref, c.`name`, c.`parent`
           FROM collection_resource AS cr
           JOIN collection AS c ON cr.collection = c.ref AND c.`type` = %s
          WHERE cr.resource IN (%s)
            %s # access control filter (ok if empty - it means we don't want permission checks or there's nothing to filter out)"
,
        
COLLECTION_TYPE_FEATURED,
        
"'" join("', '"$resources) . "'",
        
trim(featured_collections_permissions_filter_sql("AND""c.ref"))
    );
    
$fcs sql_query($sql);

    
$results = array();
    foreach(
$fcs as $fc)
        {
        
$results[] = get_featured_collection_category_branch_by_leaf($fc["ref"], array());
        }

    return 
$results;
    }

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