Collections functions
General functions
Render functions
Theme permission 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 5982 to 6020

Definition

 
function get_featured_collections_by_resources(array $r_refs)
    {
    
$resources array_filter($r_refs"is_numeric");
    if(empty(
$resources))
        {
        return array();
        }
    
    
$featured_type_filter_sql "";
    
$featured_type_filter_sql_params =[];
    
$fcf_sql featured_collections_permissions_filter_sql("AND""c.ref");
    if(
is_array($fcf_sql))
        {
        
$featured_type_filter_sql "(c.`type` = ? " $fcf_sql[0] . ")";
        
$featured_type_filter_sql_params array_merge(["i",COLLECTION_TYPE_FEATURED],$fcf_sql[1]);
        }

        
    
$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,
        
ps_param_insert(count($resources)),
        
$featured_type_filter_sql
        
);

    
$fcs ps_query($sqlarray_merge(ps_param_fill($resources'i'), $featured_type_filter_sql_params));
    
    
$results = array();
    foreach(
$fcs as $fc)
        {
        
$results[] = get_featured_collection_category_branch_by_leaf($fc["ref"], array());
        }

    return 
$results;
    }

This article was last updated 4th October 2022 10:35 Europe/London time based on the source file dated 4th October 2022 09:50 Europe/London time.