Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

create_collection()

Description

Creates a new collection for user $userid called $name

Parameters

ColumnTypeDefaultDescription
$userid integer
$name string
$allowchanges boolean 0
$cant_delete boolean 0
$ref integer 0
$public boolean false

Return

integer

Location

include/collections_functions.php lines 557 to 591

Definition

 
function create_collection($userid,$name,$allowchanges=0,$cant_delete=0,$ref=0,$public=false)
    {
    
debug_function_call("create_collection"func_get_args());

    global 
$username,$anonymous_login,$rs_session$anonymous_user_session_collection;
    if(
$username==$anonymous_login && $anonymous_user_session_collection)
        {        
        
// 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="";
        }

    
$sql sprintf(
        
"INSERT INTO collection (%sname, user, created, allow_changes, cant_delete, session_id, type)
              VALUES (%s'%s', '%s', NOW(), '%s', '%s', %s, %s)"
,
        (
$ref != "ref, " ""),
        
// Values start here
        
($ref != "'" escape_check($ref) . "', " ""),
        
escape_check(mb_strcut($name0100)),
        
escape_check($userid),
        
escape_check($allowchanges),
        
escape_check($cant_delete),
        
sql_null_or_val((string)(int) $rs_session$rs_session == ""),
        (
$public COLLECTION_TYPE_PUBLIC COLLECTION_TYPE_STANDARD)
    );
    
sql_query($sql);

    
$ref sql_insert_id();
    
index_collection($ref);

    return 
$ref;
    }

This article was last updated 28th November 2020 22:35 Europe/London time based on the source file dated 25th November 2020 10:35 Europe/London time.