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

delete_collection()

Description

Deletes the collection with reference $ref

Parameters

ColumnTypeDefaultDescription
$collection integer

Return

boolean|void

Location

include/collections_functions.php lines 670 to 712

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

    
hook("beforedeletecollection","",array($ref));
    
sql_query("DELETE FROM collection WHERE ref='$ref'");
    
sql_query("DELETE FROM collection_resource WHERE collection='$ref'");
    
sql_query("DELETE FROM collection_keyword WHERE collection='$ref'");
    
sql_query("DELETE FROM external_access_keys WHERE collection='$ref'");
    
    if(
$home_dash)
        {
        
// Delete any dash tiles pointing to this collection
        
$collection_dash_tiles=sql_array("SELECT ref value FROM dash_tile WHERE link LIKE '%search.php?search=!collection" $ref "&%'",0);
        if(
count($collection_dash_tiles)>0)
            {
            
sql_query("DELETE FROM dash_tile WHERE ref IN (" .  implode(",",$collection_dash_tiles) . ")");
            
sql_query("DELETE FROM user_dash_tile WHERE dash_tile IN (" .  implode(",",$collection_dash_tiles) . ")");
            }
        }

    
collection_log($ref,LOG_CODE_COLLECTION_DELETED_COLLECTION,0$collection["name"] . " (" $lang["owner"] . ":" $collection["username"] . ")");

    if(
$type == COLLECTION_TYPE_FEATURED)
        {
        
clear_query_cache("featured_collections");
        }
    }

This article was last updated 14th May 2021 07:05 Europe/London time based on the source file dated 10th May 2021 09:15 Europe/London time.