Collections functions
General functions
Render functions
Theme permission 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 889 to 931

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));
    
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 "&%"),0);
        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($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 30th September 2022 16:05 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.