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_user_selection_collection()

Description

Get a users' collection of type SELECTION.

There can only be one collection of this type per user. If more, the first one found will be used instead.

Parameters

ColumnTypeDefaultDescription
$user integer User ID

Return

null|integer Returns NULL if none found or the collection ID

Location

include/collections_functions.php lines 5415 to 5449

Definition

 
function get_user_selection_collection($user)
    {
    if(!
is_numeric($user))
        {
        return 
null;
        }
    
    global 
$username,$anonymous_login$rs_session$anonymous_user_session_collection;
    if((
$username==$anonymous_login && $anonymous_user_session_collection) || upload_share_active())
        {       
        
// We need to set a collection session_id for the anonymous user. Get session ID to create collection with this set
        
$rs_session=get_rs_session_id(true);
        
$cache '';
        }
    else
        {   
        
$rs_session="";
        
$cache 'user_selection_collection' $user;
        }

    
$params = [
        
'i'$user,
        
'i'COLLECTION_TYPE_SELECTION,
    ];

    
$session_id_sql '';
    if(isset(
$rs_session) && $rs_session !== '')
        {
        
$session_id_sql 'AND session_id = ?';
        
$params[] = 'i';
        
$params[] = $rs_session;
        }

    return 
ps_value("SELECT ref AS `value` FROM collection WHERE `user` = ? AND `type` = ? {$session_id_sql} ORDER BY ref ASC"$paramsnull$cache);
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.