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

update_resource_type()

Parameters

ColumnTypeDefaultDescription
$ref
$type

Location

include/resource_functions.php lines 3769 to 3793

Definition

 
function update_resource_type($ref,$type)
    {
    if (
checkperm("XU" $type))
        {
        return 
false;
        }
        
    
sql_query("update resource set resource_type='$type' where ref='" escape_check($ref) . "'");
    
    
# Clear data that is no longer needed (data/keywords set for other types).
    
sql_query("delete from resource_data where resource='" escape_check($ref) . "' and resource_type_field not in (select ref from resource_type_field where resource_type='$type' or resource_type=999 or resource_type=0)");
    
sql_query("delete from resource_keyword where resource='" escape_check($ref) . "' and resource_type_field>0 and resource_type_field not in (select ref from resource_type_field where resource_type='$type' or resource_type=999 or resource_type=0)");
    
sql_query("delete from resource_node where resource='" escape_check($ref) . "' and node>0 and node not in (select n.ref from node n left join resource_type_field rf on n.resource_type_field=rf.ref where rf.resource_type='$type' or rf.resource_type=999 or resource_type=0)");    
    
    
# Also index the resource type name, unless disabled
    
global $index_resource_type;
    if (
$index_resource_type)
            {
            
$restypename=sql_value("select name value from resource_type where ref='" escape_check($type) . "'","","schema");
            
remove_all_keyword_mappings_for_field($ref,-2);
            
add_keyword_mappings($ref,$restypename,-2);
            }
                
    return 
true;        
    }

This article was last updated 29th November 2020 03:35 Europe/London time based on the source file dated 27th November 2020 14:50 Europe/London time.