delete_collection()

Description

Deletes the collection with reference $ref

Parameters

ColumnTypeDefaultDescription
$collection integer

Return

boolean|void

Location

include/collections_functions.php lines 847 to 885

Definition

 
function delete_collection($collection)
{
    global 
$home_dash$lang;
    if (!
is_array($collection)) {
        
$collection get_collection($collection);
    }
    if (!
$collection) {
        return 
false;
    }
    
$ref $collection["ref"];
    
$type $collection["type"];

    if (!
collection_writeable($ref) || is_featured_collection_category_by_children($ref)) {
        return 
false;
    }

    
ps_query("DELETE FROM collection WHERE ref=?", array("i",$ref));
    
ps_query("DELETE FROM collection_resource WHERE collection=?", array("i",$ref));
    
ps_query("DELETE FROM collection_keyword WHERE collection=?", array("i",$ref));
    
ps_query("DELETE FROM external_access_keys WHERE collection=?", array("i",$ref));

    if (
$home_dash) {
        
// Delete any dash tiles pointing to this collection
        
$collection_dash_tiles ps_array("SELECT ref value FROM dash_tile WHERE link LIKE ?", array("s","%search.php?search=!collection" $ref "&%"));
        if (
count($collection_dash_tiles) > 0) {
            
ps_query("DELETE FROM dash_tile WHERE ref IN (" .  ps_param_insert(count($collection_dash_tiles)) . ")"ps_param_fill($collection_dash_tiles"i"));
            
ps_query("DELETE FROM user_dash_tile WHERE dash_tile IN (" .  ps_param_insert(count($collection_dash_tiles)) . ")"ps_param_fill($collection_dash_tiles"i"));
        }
    }

    
collection_log($refLOG_CODE_COLLECTION_DELETED_COLLECTION0$collection["name"] . " (" $lang["owner"] . ":" $collection["username"] . ")");

    if (
$type === COLLECTION_TYPE_FEATURED) {
        
clear_query_cache("featured_collections");
    } else {
        
/** {@see create_collection()} */
        
clear_query_cache("collection_access{$collection['user']}");
    }
}

This article was last updated 18th March 2025 14:05 Europe/London time based on the source file dated 11th March 2025 11:35 Europe/London time.