Merge branch 'master' of github.com:ZoneMinder/ZoneMinder

This commit is contained in:
Isaac Connor 2019-01-23 11:31:10 -05:00
commit 8d92375d41
6 changed files with 86 additions and 79 deletions

View File

@ -19,7 +19,10 @@
// //
// Event scope actions, view permissions only required // Event scope actions, view permissions only required
if ( canView('Events') ) { if ( !canView('Events') ) {
Warning('You do not have permission to view Events.');
return;
}
if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
if ( $action == 'addterm' ) { if ( $action == 'addterm' ) {
@ -32,7 +35,6 @@ if ( canView('Events') ) {
dbQuery('DELETE FROM Filters WHERE Id=?', array($_REQUEST['Id'])); dbQuery('DELETE FROM Filters WHERE Id=?', array($_REQUEST['Id']));
} }
} else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) { } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) {
# or ( $action == 'submit' ) ) {
$sql = ''; $sql = '';
$_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']); $_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']);
@ -69,13 +71,12 @@ if ( canView('Events') ) {
$_REQUEST['Id'] = dbInsertId(); $_REQUEST['Id'] = dbInsertId();
} }
if ( $action == 'execute' ) { if ( $action == 'execute' ) {
executeFilter( $tempFilterName ); executeFilter($_REQUEST['Id']);
$view = 'events';
} }
} // end if save or execute } // end if save or execute
} // end if canEdit(Events) } // end if canEdit(Events)
return;
} // end if object == filter } // end if object == filter
} // end canView(Events)
?> ?>

View File

@ -958,11 +958,11 @@ Logger::Debug("generating Video $command: result($result outptu:(".implode("\n",
return( $status?"":rtrim($result) ); return( $status?"":rtrim($result) );
} }
function executeFilter( $filter ) { function executeFilter( $filter_id ) {
$command = ZM_PATH_BIN."/zmfilter.pl --filter ".escapeshellarg($filter); $command = ZM_PATH_BIN.'/zmfilter.pl --filter_id '.escapeshellarg($filter_id);
$result = exec($command, $output, $status); $result = exec($command, $output, $status);
dbQuery( "delete from Filters where Name like '_TempFilter%'" ); dbQuery('DELETE FROM Filters WHERE Id=?', array($filter_id));
return( $status ); return $status;
} }
# This takes more than one scale amount, so it runs through each and alters dimension. # This takes more than one scale amount, so it runs through each and alters dimension.

View File

@ -79,7 +79,9 @@ $pagination = getPagination($pages, $page, $maxShortcuts, $filterQuery.$sortQuer
$focusWindow = true; $focusWindow = true;
if ( $_POST ) { if ( $_POST ) {
header('Location: ' . $_SERVER['REQUEST_URI'].htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page); // I think this is basically so that a refresh doesn't repost
Logger::Debug("Redirecting to " . $_SERVER['REQUEST_URI']);
header('Location: ?view=' . $view.htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
exit(); exit();
} }

View File

@ -177,9 +177,9 @@ if ( (null !== $filter->Concurrent()) and $filter->Concurrent() )
?> ?>
</div> </div>
</form> </form>
<form name="contentForm" id="contentForm" method="post" class="validateFormOnSubmit"> <form name="contentForm" id="contentForm" method="post" class="validateFormOnSubmit" action="?view=filter">
<input type="hidden" name="Id" value="<?php echo $filter->Id() ?>"/> <input type="hidden" name="Id" value="<?php echo $filter->Id() ?>"/>
<input type="hidden" name="action" value=""/> <input type="hidden" name="action"/>
<input type="hidden" name="object" value="filter"/> <input type="hidden" name="object" value="filter"/>
<hr/> <hr/>
@ -393,7 +393,7 @@ if ( ZM_OPT_MESSAGE ) {
</p> </p>
<p><label><?php echo translate('FilterMoveEvents') ?></label> <p><label><?php echo translate('FilterMoveEvents') ?></label>
<input type="checkbox" name="filter[AutoMove]" value="1"<?php if ( $filter->AutoMove() ) { ?> checked="checked"<?php } ?> onclick="updateButtons(this);if(this.checked){$j(this.form.elements['filter[AutoMoveTo]']).css('display','inline');}else{this.form.elements['filter[AutoMoveTo]'].hide();};"/> <input type="checkbox" name="filter[AutoMove]" value="1"<?php if ( $filter->AutoMove() ) { ?> checked="checked"<?php } ?> onclick="updateButtons(this);if(this.checked){$j(this.form.elements['filter[AutoMoveTo]']).css('display','inline');}else{this.form.elements['filter[AutoMoveTo]'].hide();};"/>
<?php echo htmlSelect( "filter[AutoMoveTo]", $storageareas, $filter->AutoMoveTo(), $filter->AutoMove() ? null : array('style'=>'display:none;' ) ); ?> <?php echo htmlSelect('filter[AutoMoveTo]', $storageareas, $filter->AutoMoveTo(), $filter->AutoMove() ? null : array('style'=>'display:none;' )); ?>
</p> </p>
<p> <p>
<label for="background"><?php echo translate('BackgroundFilter') ?></label> <label for="background"><?php echo translate('BackgroundFilter') ?></label>
@ -407,7 +407,7 @@ if ( ZM_OPT_MESSAGE ) {
<hr/> <hr/>
<div id="contentButtons"> <div id="contentButtons">
<button type="submit" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button> <button type="submit" data-on-click-this="submitToEvents"><?php echo translate('ListMatches') ?></button>
<button type="submit" name="executeButton" id="executeButton" data-on-click-this="executeFilter"><?php echo translate('Execute') ?></button> <button type="button" name="executeButton" id="executeButton" data-on-click-this="executeFilter"><?php echo translate('Execute') ?></button>
<?php <?php
if ( canEdit('Events') ) { if ( canEdit('Events') ) {
?> ?>

View File

@ -12,7 +12,7 @@ function validateForm( form ) {
return false; return false;
} }
} }
if (obrCount - cbrCount != 0) { if ( (obrCount - cbrCount) != 0 ) {
alert(errorBrackets); alert(errorBrackets);
return false; return false;
} }
@ -21,6 +21,7 @@ function validateForm( form ) {
alert("There appear to be non-numeric characters in your limit. Limit must be a positive integer value or empty."); alert("There appear to be non-numeric characters in your limit. Limit must be a positive integer value or empty.");
return false; return false;
} }
console.log("Success validating");
return true; return true;
} }
@ -82,9 +83,10 @@ function submitToEvents( element ) {
function executeFilter( element ) { function executeFilter( element ) {
var form = element.form; var form = element.form;
form.action = thisUrl + '?view=events'; form.action = thisUrl + '?view=filter';
form.elements['action'].value = 'execute'; form.elements['action'].value = 'execute';
history.replaceState(null, null, '?view=filter&' + $j(form).serialize()); form.submit();
//history.replaceState(null, null, '?view=filter&' + $j(form).serialize());
} }
function saveFilter( element ) { function saveFilter( element ) {
@ -228,12 +230,12 @@ function stringFilter(term) {
function addTerm( element ) { function addTerm( element ) {
var row = $j(element).closest('tr'); var row = $j(element).closest('tr');
row.find('select').chosen("destroy"); row.find('select').chosen('destroy');
var newRow = row.clone().insertAfter(row); var newRow = row.clone().insertAfter(row);
row.find('select').chosen({width: "101%"}); row.find('select').chosen({width: '101%'});
newRow.find('select').each( function() { //reset new row to default newRow.find('select').each( function() { //reset new row to default
this[0].selected = 'selected'; this[0].selected = 'selected';
}).chosen({width: "101%"}); }).chosen({width: '101%'});
newRow.find('input[type="text"]').val(''); newRow.find('input[type="text"]').val('');
var rows = $j(row).parent().children(); var rows = $j(row).parent().children();
parseRows(rows); parseRows(rows);

View File

@ -725,11 +725,13 @@ function Polygon_calcArea( coords ) {
var n_coords = coords.length; var n_coords = coords.length;
var float_area = 0.0; var float_area = 0.0;
for ( i = 0, j = n_coords-1; i < n_coords; j = i++ ) { for ( i = 0; i < n_coords-1; i++ ) {
var trap_area = ( ( coords[i].x - coords[j].x ) * ( coords[i].y + coords[j].y ) ) / 2; var trap_area = (coords[i].x*coords[i+1].y - coords[i+1].x*coords[i].y) / 2;
float_area += trap_area; float_area += trap_area;
//printf( "%.2f (%.2f)\n", float_area, trap_area ); //printf( "%.2f (%.2f)\n", float_area, trap_area );
} }
float_area += (coords[n_coords-1].x*coords[0].y - coords[0].x*coords[n_coords-1].y) / 2;
return Math.round( Math.abs( float_area ) ); return Math.round( Math.abs( float_area ) );
} }