add IS and IS NOT as filter operators so that we can do IS NULL and IS NOT NULL because = NULL and !=NULL are not valid

This commit is contained in:
Isaac Connor committed 2017-10-27 08:37:53 -07:00
1 parent e27b95c820
commit 82fbec697f
6 files changed
+18 -4

No files matched your search

@@ -367,6 +367,7 @@ sub DiskSpace {
my $size = 0;
File::Find::find( { wanted=>sub { $size += -f $_ ? -s _ : 0 }, untaint=>1 }, $_[0]->Path() );
$_[0]{DiskSpace} = $size;
Debug("DiskSpace for event $_[0]{Id} Updated to $size bytes");
}
}
+7 -3
View File
@@ -259,6 +259,10 @@ sub Sql {
$self->{Sql} .= " regexp $value";
} elsif ( $term->{op} eq '!~' ) {
$self->{Sql} .= " not regexp $value";
} elsif ( $term->{op} eq 'IS' ) {
$self->{Sql} .= " IS $value";
} elsif ( $term->{op} eq 'IS NOT' ) {
$self->{Sql} .= " IS NOT $value";
} elsif ( $term->{op} eq '=[]' ) {
$self->{Sql} .= " in (".join( ",", @value_list ).")";
} elsif ( $term->{op} eq '!~' ) {
@@ -277,15 +281,15 @@ sub Sql {
if ( $self->{AutoMessage} ) {
# Include all events, including events that are still ongoing
# and have no EndTime yet
$sql .= " and ( ".$self->{Sql}." )";
$sql .= ' AND ( '.$self->{Sql}.' )';
} else {
# Only include closed events (events with valid EndTime)
$sql .= " where not isnull(E.EndTime) and ( ".$self->{Sql}." )";
$sql .= ' WHERE (E.EndTime IS NOT NULL) AND ( '.$self->{Sql}.' )';
}
}
my @auto_terms;
if ( $self->{AutoArchive} ) {
push @auto_terms, "E.Archived = 0";
push @auto_terms, 'E.Archived = 0';
}
# Don't do this, it prevents re-generation and concatenation.
# If the file already exists, then the video won't be re-recreated
+2 -1
View File
@@ -251,7 +251,8 @@ sub checkFilter {
my $filter = shift;
my @Events = $filter->Execute();
Info( join( "Checking filter '$filter->{Name}'",
Info( join( ' ',
"Checking filter '$filter->{Name}'",
($filter->{AutoDelete}?', delete':''),
($filter->{AutoArchive}?', archive':''),
($filter->{AutoVideo}?', video':''),
+4
View File
@@ -1274,6 +1274,10 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) {
case '![]' :
$filter['sql'] .= ' not in ('.join( ',', $valueList ).')';
break;
case 'IS' :
$filter['sql'] .= " IS $value";
case 'IS NOT' :
$filter['sql'] .= " IS NOT $value";
}
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][op]").'='.urlencode($terms[$i]['op']);
+2
View File
@@ -556,6 +556,8 @@ $SLANG = array(
'OpNe' => 'not equal to',
'OpNotIn' => 'not in set',
'OpNotMatches' => 'does not match',
'OpIs' => 'is',
'OpIsNot' => 'is not',
'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.',
+2
View File
@@ -104,6 +104,8 @@ $opTypes = array(
'!~' => translate('OpNotMatches'),
'=[]' => translate('OpIn'),
'![]' => translate('OpNotIn'),
'IS' => translate('OpIs'),
'IS NOT' => translate('OpIsNot'),
);
$archiveTypes = array(