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_resource_collections()

Description

Retrieves a list of collections that a resource is used in for the specified resource reference.

Parameters

ColumnTypeDefaultDescription
$ref int The resource reference for which to retrieve associated collections.

Return

array An array of collections associated with the resource, including user information and resource count.

Location

include/resource_functions.php lines 5993 to 6023

Definition

 
function get_resource_collections($ref)
    {
    global 
$userref;
    if (
checkperm('b') || is_anonymous_user())
        {
        return array();
        }

    
# Returns a list of collections that a resource is used in for the $view_resource_collections option
    
$sql="";

    
# Include themes in my collections?
    # Only filter out themes if $themes_in_my_collections is set to false in config.php
    
global $themes_in_my_collections;
    if (!
$themes_in_my_collections)
        {
        if (
$sql!="") {$sql.=" and ";}
        
$sql.="(length(c.theme)=0 or c.theme is null) ";
        }
    if (
$sql!="") {$sql="where " $sql;}

    return 
ps_query("select * from
    (select c.*,u.username,u.fullname,count(r.resource) count from user u join collection c on u.ref=c.user and c.user=? left outer join collection_resource r on c.ref=r.collection group by c.ref
    union
    select c.*,u.username,u.fullname,count(r.resource) count from user_collection uc join collection c on uc.collection=c.ref and uc.user=? and c.user<>? left outer join collection_resource r on c.ref=r.collection left join user u on c.user=u.ref group by c.ref) clist where clist.ref in (select collection from collection_resource cr where cr.resource=?)"
,array(
        
"i",$userref,
        
"i",$userref,
        
"i",$userref,
        
"i",$ref
        
));
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 15th November 2024 18:30 Europe/London time.