Collections functions
General functions
Render functions
Theme permission functions
Resource functions

remove_resource_from_collection()

Description

Remove resource $resource from collection $collection

Parameters

ColumnTypeDefaultDescription
$resource integer
$collection integer
$smartadd boolean false
$size string ""

Return

boolean | string

Location

include/collections_functions.php lines 507 to 541

Definition

 
function remove_resource_from_collection($resource,$collection,$smartadd=false,$size="")
    {
    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$size)))
            {
            
$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 2nd October 2022 03:35 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.