diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index 91b87e615..c0e05226e 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -82,6 +82,13 @@ sub Execute { my $self = $_[0]; my $sql = $self->Sql(undef); + if ( @{$$self{PreConditions}} ) { + foreach my $term ( @{$$self{PreConditions}} ) { + if ( $$term{attr} eq 'DiskPercent' ) { + } + } + } + if ( $self->{HasDiskPercent} ) { my $disk_percent = getDiskPercent($$self{Storage} ? $$self{Storage}->Path() : ()); $sql =~ s/zmDiskPercent/$disk_percent/g; @@ -104,12 +111,13 @@ sub Execute { return; } my @results; - while ( my $event = $sth->fetchrow_hashref() ) { push @results, $event; } $sth->finish(); - Debug('Loaded ' . @results . " events for filter $_[0]{Name} using query ($sql)"); + Debug('Loaded ' . @results . ' events for filter '.$$self{Name}.' using query ('.$sql.')"'); + if ( $self->{HasNonSqlConditions} ) { + } return @results; } @@ -183,18 +191,23 @@ sub Sql { $self->{Sql} .= "weekday( E.EndTime )"; # + } elsif ( $term->{attr} eq 'EventExists' ) { + push @{$self->{PreConditions}}, $term; } elsif ( $term->{attr} eq 'DiskSpace' ) { $self->{Sql} .= 'E.DiskSpace'; - $self->{HasDiskPercent} = !undef; + push @{$self->{PostConditions}}, $term; } elsif ( $term->{attr} eq 'DiskPercent' ) { $self->{Sql} .= 'zmDiskPercent'; $self->{HasDiskPercent} = !undef; + $self->{HasPreCondition} = !undef; } elsif ( $term->{attr} eq 'DiskBlocks' ) { $self->{Sql} .= 'zmDiskBlocks'; $self->{HasDiskBlocks} = !undef; + $self->{HasPreCondition} = !undef; } elsif ( $term->{attr} eq 'SystemLoad' ) { $self->{Sql} .= 'zmSystemLoad'; $self->{HasSystemLoad} = !undef; + $self->{HasPreCondition} = !undef; } else { $self->{Sql} .= 'E.'.$term->{attr}; }