Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

update_resource_type()

Parameters

ColumnTypeDefaultDescription
$ref
$type

Location

include/resource_functions.php lines 4420 to 4452

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 13th December 2024 20:35 Europe/London time based on the source file dated 13th December 2024 14:45 Europe/London time.