Skip to content
Snippets Groups Projects
Commit b4f0f6bf authored by Jared Hancock's avatar Jared Hancock
Browse files

Add support for start-/ends-with in filters

parent 68ee5665
No related branches found
No related tags found
No related merge requests found
......@@ -233,7 +233,9 @@ class Filter {
'equal' => array('strcmp', 0),
'not_equal' => array('strcmp', null, 0),
'contains' => array('strpos', null, false),
'dn_contain'=> array('strpos', false)
'dn_contain'=> array('strpos', false),
'starts' => array('strpos', 0),
'ends' => array('endsWith', true)
);
$match = false;
......@@ -309,7 +311,9 @@ class Filter {
'equal'=> 'Equal',
'not_equal'=> 'Not Equal',
'contains'=> 'Contains',
'dn_contain'=> 'Does Not Contain'
'dn_contain'=> 'Does Not Contain',
'starts'=> 'Starts With',
'ends'=> 'Ends With'
);
}
......@@ -366,8 +370,8 @@ class Filter {
function save_rules($id,$vars,&$errors) {
$matches=array('name','email','subject','body','header');
$types=array('equal','not_equal','contains','dn_contain');
$matches = array_keys(self::getSupportedMatches());
$types = array_keys(self::getSupportedMatchTypes());
$rules=array();
for($i=1; $i<=25; $i++) { //Expecting no more than 25 rules...
......@@ -903,4 +907,20 @@ class TicketFilter {
return $sources[strtolower($origin)];
}
}
/**
* Function: endsWith
*
* Returns TRUE if the haystack ends with needle and FALSE otherwise.
* Thanks, http://stackoverflow.com/a/834355
*/
function endsWith($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0) {
return true;
}
return (substr($haystack, -$length) === $needle);
}
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment