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

get_filters()

Description

Get all defined filters (currently only used for search)

Parameters

ColumnTypeDefaultDescription
$order string "ref" column to order by
$sort string "ASC" sort order ("ASC" or "DESC")
$find string "" text to search for in filter

Return

array

Location

include/search_functions.php lines 2952 to 2983

Definition

 
function get_filters($order "ref"$sort "ASC"$find "")
    {
    
$validorder = array("ref","name");
    if(!
in_array($order,$validorder))
        {
        
$order "ref";
        }

    if(
$sort != "ASC")
        {
        
$sort "DESC";
        }

    
$condition "";
    
$join "";
    
$params = array();

    if(
trim($find) != "")
        {
        
$join " LEFT JOIN filter_rule_node fn ON fn.filter=f.ref LEFT JOIN node n ON n.ref = fn.node LEFT JOIN resource_type_field rtf ON rtf.ref=n.resource_type_field";
        
$condition " WHERE f.name LIKE ? OR n.name LIKE ? OR rtf.name LIKE ? OR rtf.title LIKE ?";

        
$params[]="s";$params[]="%" $find "%";
        
$params[]="s";$params[]="%" $find "%";
        
$params[]="s";$params[]="" $find "";
        
$params[]="s";$params[]="" $find "";
        }

    
$sql "SELECT f.ref, f.name FROM filter f {$join}{$condition} GROUP BY f.ref ORDER BY f.{$order} {$sort}"// $order and $sort are already confirmed to be valid.

    
return ps_query($sql$params);
    }

This article was last updated 8th November 2024 14:05 Europe/London time based on the source file dated 8th November 2024 11:45 Europe/London time.