Collections functions
General functions
Render functions
Theme permission 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 5057 to 5089

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);
        }
    else
        {    
        
$rs_session="";
        }

    
$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);
    }

This article was last updated 24th May 2022 19:05 Europe/London time based on the source file dated 17th May 2022 15:20 Europe/London time.