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

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 6151 to 6196

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]);
        }

    
# Add chunking to avoid exceeding MySQL parameter limits
    
$fcs = array();
    foreach (
array_chunk($resources10000) as $resource_chunk)
        {
        
$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($resource_chunk)),
            
$featured_type_filter_sql
            
);

        
$fcs_chunk ps_query($sqlarray_merge(ps_param_fill($resource_chunk'i'), $featured_type_filter_sql_params));
        
$fcs array_merge($fcs$fcs_chunk);
        }

    
$fcs array_unique($fcsSORT_REGULAR);

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

    return 
$results;
    }

This article was last updated 13th December 2024 08:35 Europe/London time based on the source file dated 12th December 2024 10:55 Europe/London time.