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

copy_filter()

Description

Copy specified filter_rule

Parameters

ColumnTypeDefaultDescription
$filter int - ID of filter_rule to copy

Return

boolean | integer - false, or ID of new filter

Location

include/search_functions.php lines 3210 to 3228

Definition

 
function copy_filter($filter)
    {
    if(!
is_numeric($filter))
            {
            return 
false;
            }

    
ps_query("INSERT INTO filter (name, filter_condition) SELECT name, filter_condition FROM filter WHERE ref=?",array("i",$filter));
    
$newfilter sql_insert_id();
    
$rules ps_array("SELECT ref value from filter_rule  WHERE filter=?",array("i",$filter));
    foreach(
$rules as $rule)
        {
        
ps_query("INSERT INTO filter_rule (filter) VALUES (?)",array("i",$newfilter));
        
$newrule sql_insert_id();
        
ps_query("INSERT INTO filter_rule_node (filter_rule, node_condition, node) SELECT ? , node_condition, node FROM filter_rule_node WHERE filter_rule=?",array("i",$newrule,"i",$rule));
        }

    return 
$newfilter;
    }

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