Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_resource_collections()

Parameters

ColumnTypeDefaultDescription
$ref

Location

include/resource_functions.php lines 5332 to 5361

Definition

 
function get_resource_collections($ref)
    {
    global 
$userref$anonymous_user$username;
    if (
checkperm('b') || (isset($anonymous_login) && $username==$anonymous_login))
        {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
        
));

    return 
$return;
    }

This article was last updated 2nd October 2022 15:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.