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

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 603 to 641

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 4th December 2024 09:05 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.