Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

get_resource_types()

Parameters

ColumnTypeDefaultDescription
$types ""
$translate true

Location

include/resource_functions.php lines 2851 to 2884

Definition

 
function get_resource_types($types ""$translate true)
    {
    
# Returns a list of resource types. The standard resource types are translated using $lang. Custom resource types are i18n translated.
    // support getting info for a comma-delimited list of restypes (as in a search)
    
if ($types==""){$sql="";} else
        {
        
# Ensure $types are suitably quoted and escaped
        
$cleantypes="";
        
$s=explode(",",$types);
        foreach (
$s as $type)
            {
            if (
is_numeric(str_replace("'","",$type))) # Process numeric types only, to avoid inclusion of collection-based filters (mycol, public, etc.)
                
{
                if (
strpos($type,"'")===false) {$type="'" $type "'";}
                if (
$cleantypes!="") {$cleantypes.=",";}
                
$cleantypes.=$type;
                }
            }
        
$sql=" where ref in ($cleantypes) ";
        }
    
    
$r=sql_query("select * from resource_type $sql order by order_by,ref","schema");
    
$return=array();
    
# Translate names (if $translate==true) and check permissions
    
for ($n=0;$n<count($r);$n++)
        {
        if (!
checkperm('T' $r[$n]['ref']))
            {
            if (
$translate==true) {$r[$n]["name"]=lang_or_i18n_get_translated($r[$n]["name"], "resourcetype-");} # Translate name
            
$return[]=$r[$n]; # Add to return array
            
}
        }
    return 
$return;
    }

This article was last updated 7th July 2020 10:35 Europe/London time based on the source file dated 6th July 2020 18:09 Europe/London time.