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_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 6916 to 6933

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 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.