Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 5369 to 5403

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 24th April 2024 21:35 Europe/London time based on the source file dated 19th April 2024 15:45 Europe/London time.