Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

delete_filter()

Description

Delete specified filter

Parameters

ColumnTypeDefaultDescription
$filter int - ID of filter

Return

boolean | array of users/groups using filter

Location

include/search_functions.php lines 2630 to 2653

Definition

 
function delete_filter($filter)
    {
    if(!
is_numeric($filter))
            {
            return 
false;    
            }
            
    
// Check for existing use of filter
    
$checkgroups sql_array("SELECT ref value FROM usergroup WHERE search_filter_id='" $filter "'","");
    
$checkusers  sql_array("SELECT ref value FROM user WHERE search_filter_o_id='" $filter "'","");
    
    if(
count($checkgroups)>|| count($checkusers)>0)
        {
        return array(
"groups"=>$checkgroups"users"=>$checkusers);
        }
    
    
// Delete and cleanup any unused 
    
sql_query("DELETE FROM filter WHERE ref='$filter'"); 
    
sql_query("DELETE FROM filter_rule WHERE filter NOT IN (SELECT ref FROM filter)");
    
sql_query("DELETE FROM filter_rule_node WHERE filter_rule NOT IN (SELECT ref FROM filter_rule)");
    
sql_query("DELETE FROM filter_rule WHERE ref NOT IN (SELECT DISTINCT filter_rule FROM filter_rule_node)"); 
        
    return 
true;
    }

This article was last updated 26th November 2020 03:35 Europe/London time based on the source file dated 19th November 2020 14:20 Europe/London time.