Collections functions
Encryption functions
General 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 2637 to 2655

Definition

 
function copy_filter($filter)
    {
    if(!
is_numeric($filter))
            {
            return 
false;    
            }
            
    
sql_query("INSERT INTO filter (name, filter_condition) SELECT name, filter_condition FROM filter WHERE ref={$filter}"); 
    
$newfilter sql_insert_id();
    
$rules sql_array("SELECT ref value from filter_rule  WHERE filter={$filter}"); 
    foreach(
$rules as $rule)
        {
        
sql_query("INSERT INTO filter_rule (filter) VALUES ({$newfilter})");
        
$newrule sql_insert_id();
        
sql_query("INSERT INTO filter_rule_node (filter_rule, node_condition, node) SELECT '{$newrule}', node_condition, node FROM filter_rule_node WHERE filter_rule='{$rule}'");
        }

    return 
$newfilter;
    }

This article was last updated 12th July 2020 04:35 Europe/London time based on the source file dated 7th July 2020 15:22 Europe/London time.