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_add_resources()

Parameters

ColumnTypeDefaultDescription
$collection
$resources ''
$search ''
$selected false

Location

include/collections_functions.php lines 552 to 592

Definition

 
function collection_add_resources($collection,$resources='',$search='',$selected=false)
    {
    global 
$USER_SELECTION_COLLECTION,$lang;
    if(
            !
is_int_loose($collection)
        ||  (
$resources == '' && $search == '')
        ||  !
collection_writeable($collection)
        ||  
is_featured_collection_category_by_children($collection)
    )
        {
        return 
$lang["cantmodifycollection"];
        }
    
$access_control true;
    
$external_share_keys get_external_shares([
        
'share_collection' => $collection,
        
'share_type' => 0,
        
'ignore_permissions' => true,
    ]);

    if(
$selected){$resources=get_collection_resources($USER_SELECTION_COLLECTION);}
    elseif(
$resources ==''){$resources=do_search($search);}

    if(
$resources === false){return $lang["noresourcesfound"];}
    if(!
is_array($resources)){$resources explode(",",$resources);}

    if (
count($resources) == 0){return $lang["noresourcesfound"];}
    
$collection_resources       get_collection_resources($collection);
    
$refs_to_add array_diff($resources$collection_resources);

    
$errors=0;
    foreach(
$refs_to_add as $ref)
        {
        if(!
add_resource_to_collection($ref,$collectionfalse''''$access_control$external_share_keys))
            {
            
$errors++;
            }
        }
    
    if(
$errors ==0){return true;}
    else {return 
$lang["cantaddresourcestocolection"];}
    }

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.