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_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 4th December 2024 08:35 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.