Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_default_user_collection()

Description

Get the user's default collection, creating one if necessary

Parameters

ColumnTypeDefaultDescription
$setactive bool false Set the collection as the user's active collection?

Return

int collection ID

Location

include/collections_functions.php lines 6871 to 6888

Definition

 
function get_default_user_collection($setactive=false)
    {
    global 
$userref;
    
$usercollection ps_value("SELECT ref value FROM collection WHERE user=? AND name LIKE 'Default Collection%' ORDER BY created ASC LIMIT 1",array("i",$userref),0);
    if (
$usercollection == 0)
        {
        
# Create a collection for this user
        # The collection name is translated when displayed!
        
$usercollection=create_collection($userref,"Default Collection",0,1); # Do not translate this string!
        
}
    if(
$setactive)
        {
        
# set this to be the user's current collection
        
ps_query("UPDATE user SET current_collection=? where ref=?",array("i",$usercollection,"i",$userref));
        
set_user_collection($userref,$usercollection);
        }
    return 
$usercollection;
    }

This article was last updated 19th March 2024 10:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.