Collections functions
General functions
Render functions
Theme permission functions
Resource 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 2828 to 2846

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",$newfilter,"i",$rule));
        }

    return 
$newfilter;
    }

This article was last updated 5th October 2022 03:35 Europe/London time based on the source file dated 3rd October 2022 17:20 Europe/London time.