Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

copyResourceDataValues()

Description

Copy resource data from one resource to another one.

Parameters

ColumnTypeDefaultDescription
$from integer Resource we are copying data from
$to
$ref integer Resource we are copying data to

Return

void

Location

include/resource_functions.php lines 6320 to 6352

Definition

 
function copyResourceDataValues($from$to)
    {
    
$from            escape_check($from);    
    
$to              escape_check($to);
    
$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($from 0)
        {
        
$omitfields      sql_array("SELECT ref AS `value` FROM resource_type_field WHERE omit_when_copying = 1""schema");
        
$omit_fields_sql "AND rd.resource_type_field NOT IN ('" implode("','"$omitfields) . "')";
        }

    
sql_query("
        INSERT INTO resource_data(resource, resource_type_field, value)
             SELECT '
{$to}',
                    rd.resource_type_field,
                    rd.value
               FROM resource_data AS rd
               JOIN resource AS r ON rd.resource = r.ref
               JOIN resource_type_field AS rtf ON rd.resource_type_field = rtf.ref
                    AND (
                            rtf.resource_type = r.resource_type
                            OR rtf.resource_type = 999
                            OR rtf.resource_type = 0
                        )
              WHERE rd.resource = '
{$from}'
                
{$omit_fields_sql}
    "
);

    return;
    }

This article was last updated 3rd December 2020 13:05 Europe/London time based on the source file dated 30th November 2020 11:55 Europe/London time.