Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_resource_collections()

Parameters

ColumnTypeDefaultDescription
$ref

Location

include/resource_functions.php lines 5787 to 5817

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 19th March 2024 02:35 Europe/London time based on the source file dated 11th March 2024 14:25 Europe/London time.