Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

save_filter_rule()

Parameters

ColumnTypeDefaultDescription
$filter_rule
$filterid
$rule_data

Location

include/search_functions.php lines 2885 to 2922

Definition

 
function save_filter_rule($filter_rule$filterid$rule_data)
    {
    if(!
is_array($rule_data))
        {
        
$rule_data json_decode($rule_data);
        }
        
    if(
$filter_rule != "new" && is_int_loose($filter_rule) && $filter_rule 0)
        {
        
ps_query("DELETE FROM filter_rule_node WHERE filter_rule = ?",array("i",$filter_rule));
        }
    else
        {
        
ps_query("INSERT INTO filter_rule (filter) VALUES (?)",array("i",$filterid));
        
$filter_rule sql_insert_id();
        }    
        
    if(
count($rule_data) > 0)
        {
        
$nodeinsert = array();
        
$params=array();
        for(
$n=0;$n<count($rule_data);$n++)
            {
            
$condition $rule_data[$n][0];
            for(
$rd=0;$rd<count($rule_data[$n][1]);$rd++)
                {
                
$nodeid $rule_data[$n][1][$rd];
                
$nodeinsert[] = "(?,?,?)";
                
$params[]="i";$params[]=$filter_rule;
                
$params[]="i";$params[]=$nodeid;
                
$params[]="i";$params[]=$condition;
                }
            }
        
$sql "INSERT INTO filter_rule_node (filter_rule,node,node_condition) VALUES " implode(',',$nodeinsert);
        
ps_query($sql,$params);
        }
    return 
$filter_rule;
    }

This article was last updated 21st May 2024 11:35 Europe/London time based on the source file dated 13th May 2024 14:40 Europe/London time.