Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

update_resource_type()

Parameters

ColumnTypeDefaultDescription
$ref
$type

Location

include/resource_functions.php lines 4416 to 4448

Definition

 
function update_resource_type($ref,$type)
    {
    global 
$lang;
    
    if (
checkperm("XU" $type))
        {
        return 
false;
        }

    
$old_rt ps_value("SELECT resource_type `value` FROM resource WHERE ref = ?",["i",$ref], '');
    
ps_query("UPDATE resource SET resource_type = ? WHERE ref = ?",["i",$type,"i",$ref]);

    
# Clear data that is no longer needed (data/keywords set for other types).
    
ps_query("DELETE FROM resource_node
                    WHERE resource = ?
                          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
                              LEFT JOIN resource_type_field_resource_type rtfrt ON rf.ref=rtfrt.resource_type_field
                                  WHERE (rtfrt.resource_type = ? OR rf.global=1)
                                )"
                
,["i",$ref,"i",$type]);

    if(
$type != $old_rt)
        {
        
$rts get_resource_types("$type,$old_rt");
        
$rts array_column($rts'name''ref');
        
resource_log($ref''null$lang["log-rtchange"], $rts[$old_rt]??""$rts[$type]??"");
        }
    return 
true;
    }

This article was last updated 23rd July 2024 21:05 Europe/London time based on the source file dated 23rd July 2024 11:20 Europe/London time.