Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

delete_collection()

Parameters

ColumnTypeDefaultDescription
$collection

Location

include/collections_functions.php lines 891 to 938

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 "&%"));
        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");
        }
    else
        {
        
/** {@see create_collection()} */
        
clear_query_cache("collection_access{$collection['user']}");
        }
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.