Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 2962 to 2985

Definition

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

    
// Check for existing use of filter
    
$checkgroups ps_array("SELECT ref value FROM usergroup WHERE search_filter_id=? OR edit_filter_id=? OR derestrict_filter_id=?",['i'$filter,'i'$filter,'i'$filter], "");
    
$checkusers  ps_array("SELECT ref value FROM user WHERE search_filter_o_id=? ",array("i",$filter),"");

    if(
count($checkgroups)>|| count($checkusers)>0)
        {
        return array(
"groups"=>$checkgroups"users"=>$checkusers);
        }

    
// Delete and cleanup any unused
    
ps_query("DELETE FROM filter WHERE ref=?",array("i",$filter));
    
ps_query("DELETE FROM filter_rule WHERE filter NOT IN (SELECT ref FROM filter)");
    
ps_query("DELETE FROM filter_rule_node WHERE filter_rule NOT IN (SELECT ref FROM filter_rule)");
    
ps_query("DELETE FROM filter_rule WHERE ref NOT IN (SELECT DISTINCT filter_rule FROM filter_rule_node)");

    return 
true;
    }

This article was last updated 23rd July 2024 21:35 Europe/London time based on the source file dated 17th July 2024 15:30 Europe/London time.