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

void

Location

include/collections_functions.php lines 600 to 634

Definition

 
function delete_collection($collection)
    {
    global 
$home_dash$lang;
    if(!
is_array($collection)){$collection=get_collection($collection);}
    
$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'");
    
    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,"X",0$collection["name"] . " (" $lang["owner"] . ":" $collection["username"] . ")");

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

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