Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_collection()

Parameters

ColumnTypeDefaultDescription
$ref
$usecache false

Location

include/collections_functions.php lines 216 to 272

Definition

 
function get_collection($ref$usecache false)
    {
    global 
$lang$userref,$k,$attach_user_smart_groups;
    if(isset(
$GLOBALS['get_collection_cache'][$ref]) && $usecache)
        {
        return 
$GLOBALS['get_collection_cache'][$ref];
        }

    
$columns ", u.fullname, u.username";
        
    
$return ps_query("SELECT "columns_in('collection''c') . $columns ." FROM collection c LEFT OUTER JOIN user u ON u.ref = c.user WHERE c.ref = ?",array("i",$ref));

    if (
count($return)==0)
        {
        return 
false;
        }
    else 
        {
        
$return=$return[0];
        
$users ps_array("SELECT u.username value FROM user u,user_collection c WHERE u.ref=c.user AND c.collection = ? ORDER BY u.username",array("i",$ref));
        
$return["users"]=join(", ",$users);
        if(
$attach_user_smart_groups)
            {
            
$groups ps_array("SELECT concat('" $lang["groupsmart"] . "',u.name) value FROM usergroup u,usergroup_collection c WHERE u.ref = c.usergroup AND c.collection = ? ORDER BY u.name",array("i",$ref));
            
$return["groups"]=join(", ",$groups);
            }

        
$request_feedback=0;
        if (
$return["user"]!=$userref)
            {
            
# If this is not the user's own collection, fetch the user_collection row so that the 'request_feedback' property can be returned.
            
$request_feedback=ps_value("SELECT request_feedback value FROM user_collection WHERE collection = ? AND user = ?",array("i",$ref,"i",$userref),0);
            if(!
$request_feedback && $attach_user_smart_groups && $k=="")
                {
                
# try to set via usergroup_collection
                
global $usergroup;
                
$request_feedback=ps_value("SELECT request_feedback value FROM usergroup_collection WHERE collection = ? AND usergroup = ?",array("i",$ref,"i",$usergroup),0);
                }
            }
        if (
$k!="")
            {
            
# If this is an external user (i.e. access key based) then fetch the 'request_feedback' value from the access keys table
            
$request_feedback=ps_value("SELECT request_feedback value FROM external_access_keys WHERE access_key = ? AND request_feedback = 1",array("s",$k),0);
            }
        
        
$return["request_feedback"]=$request_feedback;
        
        
// Legacy property which is now superseeded by types. FCs need to be public before they can be put under a category by an admin (perm h)
        
global $COLLECTION_PUBLIC_TYPES;
        
$return["public"] = (int) in_array($return["type"], $COLLECTION_PUBLIC_TYPES);

        
$GLOBALS['get_collection_cache'][$ref] = $return;
        return 
$return;
        }

    return 
false;
    }

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