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

delete_resource_nodes()

Description

Delete nodes in array from resource

Parameters

ColumnTypeDefaultDescription
$resourceid integer Resource ID to add nodes to
$nodes array array Array of node IDs to remove
$logthis boolean true Log this? Log entries are ideally added when more data on all changes made is available to make reverts easier.

Return

void

Location

include/node_functions.php lines 1545 to 1584

Definition

 
function delete_resource_nodes(int $resourceid,$nodes=array(),$logthis=true)
    {
    if(!
is_array($nodes))
        {
        
$nodes = array($nodes);
        }

    
$nodes array_filter($nodes'is_int_loose');
    
$nodes_count count($nodes);
    if(
$nodes_count === 0)
        {
        return;
        }

    
$chunks array_chunk($nodes,SYSTEM_DATABASE_IDS_CHUNK_SIZE);
    foreach(
$chunks as $chunk)
        {
        
ps_query('DELETE FROM resource_node WHERE resource = ? AND node IN (' ps_param_insert(count($chunk)) . ')',
            
array_merge(['i'$resourceid], ps_param_fill($chunk'i'))
        );
        }

    if(
$logthis)
        {
        
$field_nodes_arr = array();
        foreach (
$nodes as $node)
            {
            
$nodedata = array();
            
get_node($node$nodedata);
            if(
$nodedata)
                {
                
$field_nodes_arr[$nodedata["resource_type_field"]][] = $nodedata["name"];
                }
            }
        foreach (
$field_nodes_arr as $key => $value)
            {
            
resource_log($resourceid,"e",$key,"","," implode(",",$value),'');
            }
        }
    }

This article was last updated 8th December 2024 20:35 Europe/London time based on the source file dated 6th December 2024 12:00 Europe/London time.