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

migrate_resource_type_field_check()

Parameters

ColumnTypeDefaultDescription
&$resource_type_field

Location

include/migration_functions.php lines 5 to 45

Definition

 
function migrate_resource_type_field_check(&$resource_type_field)
    {

    if (
        !isset(
$resource_type_field['options']) ||
        
is_null($resource_type_field['options']) ||
        
$resource_type_field['options']=='' ||
        (
$resource_type_field['type'] == && preg_match('/^' MIGRATION_FIELD_OPTIONS_DEPRECATED_PREFIX_CATEGORY_TREE '/',$resource_type_field['options'])) ||
        
preg_match('/^' MIGRATION_FIELD_OPTIONS_DEPRECATED_PREFIX '/',$resource_type_field['options'])
    )
        {
        return;  
// get out of here as there is nothing to do
        
}

    
// Delete all nodes for this resource type field
    // This is to prevent systems that migrated to have old values that have been removed from a default field
    // example: Country field
    
delete_nodes_for_resource_type_field($resource_type_field['ref']);

    if (
$resource_type_field['type'] == 7)        // category tree
        
{
        
migrate_category_tree_to_nodes($resource_type_field['ref'],$resource_type_field['options']);

        
// important!  this signifies that this field has been migrated by prefixing with -1,,MIGRATION_FIELD_OPTIONS_DEPRECATED_PREFIX
        
sql_query("UPDATE `resource_type_field` SET `options`=CONCAT('" escape_check (MIGRATION_FIELD_OPTIONS_DEPRECATED_PREFIX_CATEGORY_TREE) . "',options) WHERE `ref`={$resource_type_field['ref']}");

        }
    else        
// general comma separated fields
        
{
        
$options preg_split('/\s*,\s*/',$resource_type_field['options']);
        
$order=10;
        foreach (
$options as $option)
            {
            
set_node(null,$resource_type_field['ref'],$option,null,$order);
            
$order+=10;
            }

        
// important!  this signifies that this field has been migrated by prefixing with MIGRATION_FIELD_OPTIONS_DEPRECATED_PREFIX
        
sql_query("UPDATE `resource_type_field` SET `options`=CONCAT('" MIGRATION_FIELD_OPTIONS_DEPRECATED_PREFIX "',',',options) WHERE `ref`={$resource_type_field['ref']}");
        }
    }

This article was last updated 28th November 2020 22:35 Europe/London time based on the source file dated 26th November 2020 16:30 Europe/London time.