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

copy_resource_type_field_nodes()

Parameters

ColumnTypeDefaultDescription
$from
bool $to:
are they
we so
array"i"
0
"schema";
$FIXED_LIST_FIELD_TYPES

Location

include/node_functions.php lines 1719 to 1774

Definition

 
function copy_resource_type_field_nodes($from$to): bool
    
{
    global 
$FIXED_LIST_FIELD_TYPES;

    
// Since field has been copied, they are both the same, so we only need to check the from field
    
$type ps_value("SELECT `type` AS `value` FROM resource_type_field WHERE ref = ?", array("i"$from), 0"schema");

    if(!
in_array($type$FIXED_LIST_FIELD_TYPES))
        {
        return 
false;
        }

    if (
FIELD_TYPE_CATEGORY_TREE == $type)
        {
        
$nodes get_cattree_nodes_ordered($fromnulltrue);
        
// Remove the fake "root" node which get_cattree_nodes_ordered() is adding since we won't be
        // using get_cattree_node_strings() with it.
        
array_shift($nodes);
        
$nodes array_filter($nodes'node_is_active');

        
// array(from_ref => new_ref)
        
$processed_nodes = array();

        foreach(
$nodes as $node)
            {
            if(
array_key_exists($node['ref'], $processed_nodes))
                {
                continue;
                }

            
// Make the parent the expected type of a node parent (i.e. null|int) because get_cattree_nodes_ordered() is
            // setting root parent to string zero for some unknown reason.
            
$parent $node['parent'] == null $node['parent'];

            
// Child nodes need to have their parent set to the new parent ID
            
if($parent !== null)
                {
                
$parent $processed_nodes[$parent];
                }

            
$new_node_id set_node(null$to$node['name'], $parent$node['order_by']);
            
$processed_nodes[$node['ref']] = $new_node_id;
            }

        return 
true;
        }

    
// Default handle for types different than category trees
    
$nodes array_filter(get_nodes($from), 'node_is_active');
    foreach(
$nodes as $node)
        {
        
set_node(null$to$node['name'], $node['parent'], $node['order_by']);
        }

    return 
true;
    }

This article was last updated 17th November 2024 15:05 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.