Bug 214 - Separet auto execute flag from command.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1622 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-11-22 15:47:38 +00:00
parent b79f7e6c53
commit 51e3885c94
4 changed files with 22 additions and 16 deletions

View File

@ -9,6 +9,9 @@ alter table Filters add column Temp tinyint unsigned not null default 0;
update Filters set Temp = AutoDelete; update Filters set Temp = AutoDelete;
alter table Filters drop column AutoDelete; alter table Filters drop column AutoDelete;
alter table Filters change column Temp AutoDelete tinyint unsigned not null default 0; alter table Filters change column Temp AutoDelete tinyint unsigned not null default 0;
alter table Filters change column AutoExecute AutoExecuteCmd tinytext;
alter table Filters add column AutoExecute tinyint unsigned not null default 0 after AutoMessage;
update Filters set AutoExecute = if(isnull(AutoExecuteCmd)||AutoExecuteCmd='', 0, 1 );
-- --
-- These are optional, but we might as well do it now -- These are optional, but we might as well do it now
-- --

View File

@ -184,7 +184,8 @@ CREATE TABLE Filters (
AutoUpload tinyint(3) unsigned NOT NULL default '0', AutoUpload tinyint(3) unsigned NOT NULL default '0',
AutoEmail tinyint(3) unsigned NOT NULL default '0', AutoEmail tinyint(3) unsigned NOT NULL default '0',
AutoMessage tinyint(3) unsigned NOT NULL default '0', AutoMessage tinyint(3) unsigned NOT NULL default '0',
AutoExecute tinytext, AutoExecute tinyint(3) unsigned NOT NULL default '0',
AutoExecuteCmd tinytext,
AutoDelete tinyint(3) unsigned NOT NULL default '0', AutoDelete tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (Name) PRIMARY KEY (Name)
) TYPE=MyISAM; ) TYPE=MyISAM;

View File

@ -330,7 +330,7 @@ sub getDiskBlocks
sub getFilters sub getFilters
{ {
my @filters; my @filters;
my $sql = "select * from Filters where (AutoDelete = 1 or AutoArchive = 1 or AutoVideo = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1 or AutoExecute != '') order by Name"; my $sql = "select * from Filters where (AutoArchive = 1 or AutoVideo = 1 or AutoUpload = 1 or AutoEmail = 1 or AutoMessage = 1 or AutoExecute = 1 or AutoDelete = 1) order by Name";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() ); my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() );
FILTER: while( my $filter_data = $sth->fetchrow_hashref() ) FILTER: while( my $filter_data = $sth->fetchrow_hashref() )
@ -579,7 +579,8 @@ sub getFilters
$filter_data->{Sql} = $sql; $filter_data->{Sql} = $sql;
if ( $filter_data->{AutoExecute} ) if ( $filter_data->{AutoExecute} )
{ {
my $script = $filter_data->{AutoExecute}; my $script = $filter_data->{AutoExecuteCmd};
$script ~= s/\s.*$//;
if ( !-e $script ) if ( !-e $script )
{ {
Error( "Auto execute script '$script' not found, skipping filter '$filter_data->{Name}'\n" ); Error( "Auto execute script '$script' not found, skipping filter '$filter_data->{Name}'\n" );
@ -1165,7 +1166,7 @@ sub executeCommand
my $event_path = "$event->{MonitorId}/$event->{Id}"; my $event_path = "$event->{MonitorId}/$event->{Id}";
my $command = $filter->{AutoExecute}; my $command = $filter->{AutoExecuteCmd};
$command .= " $event_path"; $command .= " $event_path";
Info( "Executing '$command'\n" ); Info( "Executing '$command'\n" );

View File

@ -90,17 +90,17 @@ while ( $row = mysql_fetch_assoc( $result ) )
} }
?> ?>
<?php if ( count($filter_names) ) { ?> <?php if ( count($filter_names) ) { ?>
<td align="left" colspan="2" class="text"><?= $zmSlangSaveAs ?>:&nbsp;<?= buildSelect( $select_name, $filter_names, "submitToFilter( document.filter_form );" ); ?>&nbsp;<?= $zmSlangOrEnterNewName ?>:&nbsp;<input type="text" size="32" name="new_<?= $select_name ?>" value="<?= $filter_name ?>" class="form"></td> <td align="left" colspan="3" class="text"><?= $zmSlangSaveAs ?>:&nbsp;<?= buildSelect( $select_name, $filter_names, "submitToFilter( document.filter_form );" ); ?>&nbsp;<?= $zmSlangOrEnterNewName ?>:&nbsp;<input type="text" size="32" name="new_<?= $select_name ?>" value="<?= $filter_name ?>" class="form"></td>
<?php } else { ?> <?php } else { ?>
<td align="left" colspan="2" class="text"><?= $zmSlangEnterNewFilterName ?>:&nbsp;<input type="text" size="32" name="new_<?= $select_name ?>" value="" class="form"></td> <td align="left" colspan="3" class="text"><?= $zmSlangEnterNewFilterName ?>:&nbsp;<input type="text" size="32" name="new_<?= $select_name ?>" value="" class="form"></td>
<?php } ?> <?php } ?>
</tr> </tr>
<tr> <tr>
<td align="right" colspan="2" class="text">&nbsp;</td> <td align="right" colspan="3" class="text">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoArchiveEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoArchiveEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="checkbox" name="auto_archive" value="1"<?php if ( $filter_data['AutoArchive'] ) { echo " checked"; } ?> class="form-noborder"></td> <td align="left" class="text" colspan="2"><input type="checkbox" name="auto_archive" value="1"<?php if ( $filter_data['AutoArchive'] ) { echo " checked"; } ?> class="form-noborder"></td>
</tr> </tr>
<?php <?php
if ( ZM_OPT_MPEG != "no" ) if ( ZM_OPT_MPEG != "no" )
@ -108,7 +108,7 @@ if ( ZM_OPT_MPEG != "no" )
?> ?>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoVideoEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoVideoEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="checkbox" name="auto_video" value="1"<?php if ( $filter_data['AutoVideo'] ) { echo " checked"; } ?> class="form-noborder"></td> <td align="left" class="text" colspan="2"><input type="checkbox" name="auto_video" value="1"<?php if ( $filter_data['AutoVideo'] ) { echo " checked"; } ?> class="form-noborder"></td>
</tr> </tr>
<?php <?php
} }
@ -117,7 +117,7 @@ if ( ZM_OPT_UPLOAD )
?> ?>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoUploadEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoUploadEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="checkbox" name="auto_upload" value="1"<?php if ( $filter_data['AutoUpload'] ) { echo " checked"; } ?> class="form-noborder"></td> <td align="left" class="text" colspan="2"><input type="checkbox" name="auto_upload" value="1"<?php if ( $filter_data['AutoUpload'] ) { echo " checked"; } ?> class="form-noborder"></td>
</tr> </tr>
<?php <?php
} }
@ -126,7 +126,7 @@ if ( ZM_OPT_EMAIL )
?> ?>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoEmailEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoEmailEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="checkbox" name="auto_email" value="1"<?php if ( $filter_data['AutoEmail'] ) { echo " checked"; } ?> class="form-noborder"></td> <td align="left" class="text" colspan="2"><input type="checkbox" name="auto_email" value="1"<?php if ( $filter_data['AutoEmail'] ) { echo " checked"; } ?> class="form-noborder"></td>
</tr> </tr>
<?php <?php
} }
@ -135,24 +135,25 @@ if ( ZM_OPT_MESSAGE )
?> ?>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoMessageEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoMessageEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="checkbox" name="auto_message" value="1"<?php if ( $filter_data['AutoMessage'] ) { echo " checked"; } ?> class="form-noborder"></td> <td align="left" class="text" colspan="2"><input type="checkbox" name="auto_message" value="1"<?php if ( $filter_data['AutoMessage'] ) { echo " checked"; } ?> class="form-noborder"></td>
</tr> </tr>
<?php <?php
} }
?> ?>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoExecuteEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoExecuteEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="text" name="auto_execute" value="<?= $filter_data['AutoExecute'] ?>" size="32" maxlength="255" class="form"></td> <td align="left" class="text"><input type="checkbox" name="auto_execute" value="1"<?php if ( $filter_data['AutoExecute'] ) { echo " checked"; } ?> class="form-noborder"></td>
<td align="left" class="text"><input type="text" name="auto_execute_cmd" value="<?= $filter_data['AutoExecuteCmd'] ?>" size="32" maxlength="255" class="form"></td>
</tr> </tr>
<tr> <tr>
<td align="left" class="text"><?= $zmSlangAutoDeleteEvents ?>:&nbsp;</td> <td align="left" class="text"><?= $zmSlangAutoDeleteEvents ?>:&nbsp;</td>
<td align="left" class="text"><input type="checkbox" name="auto_delete" value="1"<?php if ( $filter_data['AutoDelete'] ) { echo " checked"; } ?> class="form-noborder"></td> <td align="left" class="text" colspan="2"><input type="checkbox" name="auto_delete" value="1"<?php if ( $filter_data['AutoDelete'] ) { echo " checked"; } ?> class="form-noborder"></td>
</tr> </tr>
<tr> <tr>
<td align="right" colspan="2" class="text">&nbsp;</td> <td align="right" colspan="3" class="text">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td align="right" colspan="2" class="text"><input type="submit" value="<?= $zmSlangSave ?>" class="form"<?php if ( !canEdit( 'Events' ) ) { ?> disabled<?php } ?>>&nbsp;<input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow();"></td> <td align="right" colspan="3" class="text"><input type="submit" value="<?= $zmSlangSave ?>" class="form"<?php if ( !canEdit( 'Events' ) ) { ?> disabled<?php } ?>>&nbsp;<input type="button" value="<?= $zmSlangCancel ?>" class="form" onClick="closeWindow();"></td>
</tr> </tr>
</table></center> </table></center>
</form> </form>