Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

remove_resource_from_collection()

Description

Remove resource $resource from collection $collection

Parameters

ColumnTypeDefaultDescription
$resource integer
$collection integer
$smartadd boolean false

Return

boolean | string

Location

include/collections_functions.php lines 509 to 543

Definition

 
function remove_resource_from_collection($resource,$collection,$smartadd=false)
    {
    global 
$lang;

    if((string)(int)
$collection != (string)$collection || (string)(int)$resource != (string)$resource)
        {
        return 
$lang["cantmodifycollection"];
        }

    if (
collection_writeable($collection)||$smartadd)
        {   
        
hook("Removefromcollectionsuccess""", array( "resourceId" => $resource"collectionId" => $collection ) );
        
        if(!
hook("removefromcollectionsql""", array( $resource,$collection)))
            {
            
$delparams = ["i",$resource,"i",$collection];
            
ps_query("DELETE FROM collection_resource WHERE resource = ? AND collection = ?",$delparams);
            
ps_query("DELETE FROM external_access_keys WHERE resource = ? AND collection = ?",$delparams);
            }
        
        
// log this
        
collection_log($collection,LOG_CODE_COLLECTION_REMOVED_RESOURCE,$resource);

        
// Clear theme image cache
        
clear_query_cache("themeimage");
        
clear_query_cache('col_total_ref_count_w_perm');

        return 
true;
        }
    else
        {
        
hook("Removefromcollectionfail""", array( "resourceId" => $resource"collectionId" => $collection ) );
        return 
$lang["cantmodifycollection"];
        }
    }

This article was last updated 19th March 2024 04:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.