Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

get_collection()

Description

Returns all data for collection $ref.

Parameters

ColumnTypeDefaultDescription
$ref int Collection ID

Return

array|boolean

Location

include/collections_functions.php lines 135 to 175

Definition

 
function get_collection($ref)
    {
    
$return=sql_query("select c.*, c.theme2, c.theme3, c.keywords, u.fullname, u.username, c.home_page_publish, c.home_page_text, c.home_page_image, c.session_id, c.description from collection c left outer join user u on u.ref = c.user where c.ref = '" escape_check($ref) . "'");
    if (
count($return)==0)
        {
        return 
false;
        }
    else 
        {
        
$return=$return[0];
        
$return["users"]=join(", ",sql_array("select u.username value from user u,user_collection c where u.ref=c.user and c.collection='" escape_check($ref) . "' order by u.username"));
        global 
$attach_user_smart_groups,$lang;
        if(
$attach_user_smart_groups)
            {
            
$return["groups"]=join(", ",sql_array("select concat('{$lang["groupsmart"]}: ',u.name) value from usergroup u,usergroup_collection c where u.ref=c.usergroup and c.collection='" escape_check($ref) . "' order by u.name"));
            }
            
        global 
$userref,$k,$attach_user_smart_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=sql_value("select request_feedback value from user_collection where collection='" escape_check($ref) . "' and user='$userref'",0);
            if(!
$request_feedback && $attach_user_smart_groups && $k=="")
                {
                
# try to set via usergroup_collection
                
global $usergroup;
                
$request_feedback=sql_value("select request_feedback value from usergroup_collection where collection='" escape_check($ref) . "' and usergroup='$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=sql_value("select request_feedback value from external_access_keys where access_key='$k' and request_feedback=1",0);
            }
        
        
$return["request_feedback"]=$request_feedback;
        return 
$return;}
    
    return 
false;
    }

This article was last updated 11th July 2020 02:35 Europe/London time based on the source file dated 9th July 2020 17:22 Europe/London time.