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

get_collection()

Parameters

ColumnTypeDefaultDescription
$ref
$usecache false

Location

include/collections_functions.php lines 216 to 269

Definition

 
function get_collection($ref$usecache false)
    {
    global 
$lang$userref,$k;
    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);

        
$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 && $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 superseded 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;
        }
    }

This article was last updated 19th March 2024 03:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.