diff --git a/db/zmalter-0.9.10.sql b/db/zmalter-0.9.10.sql index 1d54e1c44..cf8d6f805 100644 --- a/db/zmalter-0.9.10.sql +++ b/db/zmalter-0.9.10.sql @@ -5,6 +5,7 @@ alter table Monitors change column Colours Palette tinyint(3) unsigned NOT NULL update Monitors set Palette = 1 where Palette = 8; update Monitors set Palette = 4 where Palette = 24; alter table Zones modify column Type enum('Active','Inclusive','Exclusive','Preclusive','Inactive') not null default 'Active'; +alter table Filters add column AutoArchive tinyint unsigned not null default 0 after Query; -- These are optional, it just seemed a good time... optimize table Frames; optimize table Events; diff --git a/db/zmschema.sql.z b/db/zmschema.sql.z index dcc3e56ca..83b9ab9a2 100644 --- a/db/zmschema.sql.z +++ b/db/zmschema.sql.z @@ -49,6 +49,7 @@ CREATE TABLE Filters ( MonitorId int(10) unsigned NOT NULL default '0', Name varchar(64) NOT NULL default '', Query text NOT NULL, + AutoArchive tinyint(3) unsigned NOT NULL default '0', AutoDelete tinyint(3) unsigned NOT NULL default '0', AutoUpload tinyint(3) unsigned NOT NULL default '0', AutoEmail tinyint(3) unsigned NOT NULL default '0', diff --git a/scripts/zmfilter.pl.z b/scripts/zmfilter.pl.z index 9446c12e5..e4bab079f 100755 --- a/scripts/zmfilter.pl.z +++ b/scripts/zmfilter.pl.z @@ -223,6 +223,7 @@ while( 1 ) foreach my $filter ( @$filters ) { print( "Checking filter '$filter->{Name}'". + ($filter->{AutoArchive}?", archive":""). ($filter->{AutoDelete}?", delete":""). ($filter->{AutoUpload}?", upload":""). ($filter->{AutoEmail}?", email":""). @@ -261,6 +262,14 @@ while( 1 ) uploadArchFile( $filter, $event ); } + if ( $filter->{AutoArchive} ) + { + print( "Archiving event $event->{Id}\n" ); + # Do it individually to avoid locking up the table for new events + my $sql = "update Events set Archived = 1 where Id = ?"; + my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) or die( "Can't execute: ".$sth->errstr() ); + } if ( $filter->{AutoDelete} ) { print( "Deleting event $event->{Id}\n" ); @@ -290,7 +299,7 @@ sub GetFilters my $monitor = shift; my @filters; - my $sql = "select Filters.*,Monitors.Name as MonitorName from Filters inner join Monitors on Filters.MonitorId = Monitors.Id where Monitors.Id = '$monitor' and (AutoDelete = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1) order by Name"; + my $sql = "select Filters.*,Monitors.Name as MonitorName from Filters inner join Monitors on Filters.MonitorId = Monitors.Id where Monitors.Id = '$monitor' and (AutoArchive = 1 or AutoDelete = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1) order by Name"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() ); FILTER: while( my $filter_data = $sth->fetchrow_hashref() ) diff --git a/web/zm_actions.php b/web/zm_actions.php index 7fdfef1c3..1f3a6a28d 100644 --- a/web/zm_actions.php +++ b/web/zm_actions.php @@ -331,7 +331,7 @@ if ( $action ) } $filter_query_string = join( '&', $filter_parms ); //$filter_query_string = serialize( $filter_query ); - $sql = "replace into Filters set MonitorId = '$mid', Name = '$filter_name', Query = '$filter_query_string', AutoDelete = '$auto_delete', AutoUpload = '$auto_upload', AutoEmail = '$auto_email', AutoMessage = '$auto_message'"; + $sql = "replace into Filters set MonitorId = '$mid', Name = '$filter_name', Query = '$filter_query_string', AutoArchive = '$auto_archive', AutoDelete = '$auto_delete', AutoUpload = '$auto_upload', AutoEmail = '$auto_email', AutoMessage = '$auto_message'"; #echo "$sql"; $result = mysql_query( $sql ); if ( !$result ) diff --git a/web/zm_config.php.z b/web/zm_config.php.z index 7f4d6ab05..5f5da5b85 100644 --- a/web/zm_config.php.z +++ b/web/zm_config.php.z @@ -152,7 +152,7 @@ $jws = array( 'events' => array( 'w'=>720, 'h'=>480 ), 'event' => array( 'w'=>420, 'h'=>500 ), 'filter' => array( 'w'=>560, 'h'=>250 ), - 'filtersave' => array( 'w'=>520, 'h'=>180 ), + 'filtersave' => array( 'w'=>520, 'h'=>200 ), 'zones' => array( 'w'=>72, 'h'=>232 ), 'zone' => array( 'w'=>360, 'h'=>480 ), 'video' => array( 'w'=>100, 'h'=>80 ), diff --git a/web/zm_html.php b/web/zm_html.php index 62d6359a5..3bebb6a90 100644 --- a/web/zm_html.php +++ b/web/zm_html.php @@ -1532,6 +1532,10 @@ window.focus();   +Automatically archive all matching events:  +> + + Automatically delete all matching events:  >