Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 1534 to 1573

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 19th March 2024 06:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.