Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 3156 to 3179

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 17th November 2024 15:35 Europe/London time based on the source file dated 8th November 2024 11:45 Europe/London time.