diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index 611bea059..e14ae8d14 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -236,6 +236,11 @@ sub Sql { || $term->{attr} eq 'Cause' || $term->{attr} eq 'Notes' ) { + if ( $term->{op} eq 'LIKE' + || $term->{op} eq 'NOT LIKE' + ) { + $temp_value = '%'.$temp_value.'%' if $temp_value !~ /%/; + } $value = "'$temp_value'"; } elsif ( $term->{attr} eq 'DateTime' or $term->{attr} eq 'StartDateTime' or $term->{attr} eq 'EndDateTime' ) { if ( $temp_value eq 'NULL' ) { @@ -295,6 +300,10 @@ sub Sql { $self->{Sql} .= ' IN ('.join(',', @value_list).')'; } elsif ( $term->{op} eq '!~' ) { $self->{Sql} .= ' NOT IN ('.join(',', @value_list).')'; + } elsif ( $term->{op} eq 'LIKE' ) { + $self->{Sql} .= " LIKE $value"; + } elsif ( $term->{op} eq 'NOT LIKE' ) { + $self->{Sql} .= " NOT LIKE $value"; } else { $self->{Sql} .= ' '.$term->{op}.' '.$value; } diff --git a/web/includes/functions.php b/web/includes/functions.php index 7d8ace272..825467fb4 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1223,6 +1223,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') { case 'Name': case 'Cause': case 'Notes': + if($term['op'] == 'LIKE' || $term['op'] == 'NOT LIKE') { + $value = '%'.$value.'%'; + } $value = dbEscape($value); break; case 'MonitorServerId': @@ -1275,6 +1278,8 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&') { case '>' : case '<' : case '<=' : + case 'LIKE' : + case 'NOT LIKE': $filter['sql'] .= ' '.$term['op'].' '. $value; break; case '=~' : diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index b2890a605..94236dc81 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -579,6 +579,8 @@ $SLANG = array( 'OpNotMatches' => 'does not match', 'OpIs' => 'is', 'OpIsNot' => 'is not', + 'OpLike' => 'Contains', + 'OpNotLike' => 'Does not Contain', 'OptionalEncoderParam' => 'Optional Encoder Parameters', 'OptionHelp' => 'Option Help', 'OptionRestartWarning' => 'These changes may not come into effect fully\nwhile the system is running. When you have\nfinished making your changes please ensure that\nyou restart ZoneMinder.', diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 67eaf7fc2..425e914c9 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -115,6 +115,8 @@ $opTypes = array( '![]' => translate('OpNotIn'), 'IS' => translate('OpIs'), 'IS NOT' => translate('OpIsNot'), + 'LIKE' => translate('OpLike'), + 'NOT LIKE' => translate('OpNotLike'), ); $archiveTypes = array(