spacing. Add defaults for AutoMoveTo and AutoCopyTo so that we don't get false changes. redirect is a global, so make it so. Re-null the Id of the filter object after temp execute so that we don't reference a no longer existing filter.

This commit is contained in:
Isaac Connor 2021-08-12 12:53:46 -04:00
parent ccb4bb27dd
commit cd3359c3eb
1 changed files with 23 additions and 23 deletions

View File

@ -32,7 +32,6 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
} else if ($action == 'delterm') {
$_REQUEST['filter'] = delFilterTerm($_REQUEST['filter'], $_REQUEST['line']);
} else if (canEdit('Events')) {
require_once('includes/Filter.php');
$filter = new ZM\Filter($_REQUEST['Id']);
@ -42,18 +41,18 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
$filter->control('stop');
}
$filter->delete();
} else {
ZM\Error('No filter id passed when deleting');
}
} else if (( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' )) {
$_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']);
$_REQUEST['filter']['Query']['sort_asc'] = validStr($_REQUEST['filter']['Query']['sort_asc']);
$_REQUEST['filter']['Query']['limit'] = validInt($_REQUEST['filter']['Query']['limit']);
$_REQUEST['filter']['AutoCopy'] = empty($_REQUEST['filter']['AutoCopy']) ? 0 : 1;
$_REQUEST['filter']['AutoCopyTo'] = empty($_REQUEST['filter']['AutoCopyTo']) ? 0 : $_REQUEST['filter']['AutoCopyTo'];
$_REQUEST['filter']['AutoMove'] = empty($_REQUEST['filter']['AutoMove']) ? 0 : 1;
$_REQUEST['filter']['AutoMoveTo'] = empty($_REQUEST['filter']['AutoMoveTo']) ? 0 : $_REQUEST['filter']['AutoMoveTo'];
$_REQUEST['filter']['AutoArchive'] = empty($_REQUEST['filter']['AutoArchive']) ? 0 : 1;
$_REQUEST['filter']['AutoVideo'] = empty($_REQUEST['filter']['AutoVideo']) ? 0 : 1;
$_REQUEST['filter']['AutoUpload'] = empty($_REQUEST['filter']['AutoUpload']) ? 0 : 1;
@ -75,6 +74,7 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
}
} else {
if ($action == 'execute') {
# If there are changes use a temp filter to do the execute
if (count($changes)) {
$filter->Name('_TempFilter'.time());
$filter->Id(null);
@ -93,13 +93,14 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
if ($action == 'execute') {
$filter->execute();
if ( count($changes) )
if (count($changes)) {
$filter->delete();
$view = 'events';
$filter->Id(null);
}
} else if ($filter->Background()) {
$filter->control('start');
}
global $redirect;
$redirect = '?view=filter'.$filter->querystring('filter', '&');
} else if ($action == 'control') {
@ -114,5 +115,4 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
} // end if save or execute
} // end if canEdit(Events)
} // end if object == filter
?>