Collections functions
General functions
Render functions
Theme permission functions
Resource functions

collection_remove_resources()

Description

collection_remove_resources

Parameters

ColumnTypeDefaultDescription
$collection mixed
$resources mixed ''
$removeall mixed false
$selected false

Return

boolean | string

Location

include/collections_functions.php lines 601 to 639

Definition

 
function collection_remove_resources($collection,$resources='',$removeall=false,$selected=false)
    {
    global 
$USER_SELECTION_COLLECTION,$lang;
    
    if(    (string)(int)
$collection != (string)$collection 
        
|| ($resources == '' && !$removeall && !$selected)
        || (!
collection_writeable($collection))
        || 
is_featured_collection_category_by_children($collection)
    )
        {
        return 
$lang["cantmodifycollection"];
        }

    if (
$removeall)
        {
        foreach(
get_collection_resources($collection) as $ref)
            {
            
remove_resource_from_collection($ref$collection);
            }
        return 
true;
        }

    if(
$selected){$resources=get_collection_resources($USER_SELECTION_COLLECTION);}
    if(
$resources===false){return $lang["noresourcesfound"];}
    
    
$collection_resources       get_collection_resources($collection);
    
    if(!
is_array($resources)){$resources explode(",",$resources);}
    
$refs_to_remove array_intersect($collection_resources$resources);
    
    
$errors=0;
    foreach(
$refs_to_remove as $ref)
        {
        if(!
remove_resource_from_collection($ref$collection)){$errors++;}
        }
    
    if (
$errors == 0){return true;}
    else {return 
$lang["cantremoveresourcesfromcollection"];}
    }

This article was last updated 26th September 2022 14:05 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.