Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

copy_resource_nodes()

Description

Copy resource nodes from one resource to another

Parameters

ColumnTypeDefaultDescription
$resourcefrom integer Resource we are copying data from
$resourceto integer Resource we are copying data to

Return

void

Location

include/node_functions.php lines 1379 to 1404

Definition

 
function copy_resource_nodes($resourcefrom$resourceto)
    {
    
$resourcefrom    escape_check($resourcefrom);
    
$resourceto      escape_check($resourceto);
    
$omit_fields_sql '';

    
// When copying normal resources from one to another, check for fields that should be excluded
    // NOTE: this does not apply to user template resources (negative ID resource)
    
if($resourcefrom 0)
        {
        
$omitfields      sql_array("SELECT ref AS `value` FROM resource_type_field WHERE omit_when_copying = 1""schema");
        
$omit_fields_sql "AND n.resource_type_field NOT IN ('" implode("','"$omitfields) . "')";
        }

    
sql_query("
        INSERT INTO resource_node(resource, node, hit_count, new_hit_count)
             SELECT '
{$resourceto}', node, 0, 0
               FROM resource_node AS rnold
          LEFT JOIN node AS n ON n.ref = rnold.node
              WHERE resource ='
{$resourcefrom}'
                
{$omit_fields_sql}
                 ON DUPLICATE KEY UPDATE hit_count = rnold.new_hit_count;
    "
);

    return;
    }

This article was last updated 14th July 2020 01:35 Europe/London time based on the source file dated 6th July 2020 18:09 Europe/London time.