Fix saving logic
This commit is contained in:
parent
dc96ca72a8
commit
93f81daa8d
|
@ -126,13 +126,11 @@ if ( !empty($action) ) {
|
||||||
if ( $action == 'delete' ) {
|
if ( $action == 'delete' ) {
|
||||||
if ( ! empty($_REQUEST['Id']) ) {
|
if ( ! empty($_REQUEST['Id']) ) {
|
||||||
dbQuery( 'DELETE FROM Filters WHERE Id=?', array( $_REQUEST['Id'] ) );
|
dbQuery( 'DELETE FROM Filters WHERE Id=?', array( $_REQUEST['Id'] ) );
|
||||||
//$refreshParent = true;
|
|
||||||
}
|
}
|
||||||
} else if ( ( $action == 'save' ) or ( $action == 'execute' ) or ( $action == 'submit' ) ) {
|
} else if ( ( $action == 'save' ) or ( $action == 'execute' ) or ( $action == 'submit' ) ) {
|
||||||
|
|
||||||
$sql = '';
|
$sql = '';
|
||||||
$endSql = '';
|
$endSql = '';
|
||||||
$filterName = '';
|
|
||||||
if ( $action == 'execute' or $action == 'submit' ) {
|
if ( $action == 'execute' or $action == 'submit' ) {
|
||||||
# Replace will teplace any filter with the same Id
|
# Replace will teplace any filter with the same Id
|
||||||
# Since we aren't specifying the Id , this is effectively an insert
|
# Since we aren't specifying the Id , this is effectively an insert
|
||||||
|
@ -144,35 +142,27 @@ if ( !empty($action) ) {
|
||||||
$sql = 'INSERT INTO Filters SET';
|
$sql = 'INSERT INTO Filters SET';
|
||||||
}
|
}
|
||||||
|
|
||||||
# endSql is only set if ! filterName... so... woulnd't this always be true
|
$_REQUEST['filter']['sort_field'] = validStr($_REQUEST['filter']['sort_field']);
|
||||||
if ( !empty($filterName) || $endSql ) {
|
$_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['filter']['sort_asc']);
|
||||||
$_REQUEST['filter']['sort_field'] = validStr($_REQUEST['filter']['sort_field']);
|
$_REQUEST['filter']['limit'] = validInt($_REQUEST['filter']['limit']);
|
||||||
$_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['filter']['sort_asc']);
|
$sql .= ' Name = '.dbEscape($_REQUEST['filter']['Name']);
|
||||||
$_REQUEST['filter']['limit'] = validInt($_REQUEST['filter']['limit']);
|
$sql .= ', Query = '.dbEscape(jsonEncode($_REQUEST['filter']['terms']));
|
||||||
$sql .= ' Name = '.dbEscape($_REQUEST['filter']['Name']);
|
$sql .= ', AutoArchive = '.(!empty($_REQUEST['filter']['AutoArchive']) ? 1 : 0);
|
||||||
$sql .= ', Query = '.dbEscape(jsonEncode($_REQUEST['filter']['terms']));
|
$sql .= ', AutoVideo = '. ( !empty($_REQUEST['filter']['AutoVideo']) ? 1 : 0);
|
||||||
$sql .= ', AutoArchive = '.(!empty($_REQUEST['filter']['AutoArchive']) ? 1 : 0);
|
$sql .= ', AutoUpload = '. ( !empty($_REQUEST['filter']['AutoUpload']) ? 1 : 0);
|
||||||
$sql .= ', AutoVideo = '. ( !empty($_REQUEST['filter']['AutoVideo']) ? 1 : 0);
|
$sql .= ', AutoEmail = '. ( !empty($_REQUEST['filter']['AutoEmail']) ? 1 : 0);
|
||||||
$sql .= ', AutoUpload = '. ( !empty($_REQUEST['filter']['AutoUpload']) ? 1 : 0);
|
$sql .= ', AutoMessage = '. ( !empty($_REQUEST['filter']['AutoMessage']) ? 1 : 0);
|
||||||
$sql .= ', AutoEmail = '. ( !empty($_REQUEST['filter']['AutoEmail']) ? 1 : 0);
|
$sql .= ', AutoExecute = '. ( !empty($_REQUEST['filter']['AutoExecute']) ? 1 : 0);
|
||||||
$sql .= ', AutoMessage = '. ( !empty($_REQUEST['filter']['AutoMessage']) ? 1 : 0);
|
$sql .= ', AutoExecuteCmd = '.dbEscape($_REQUEST['filter']['AutoExecuteCmd']);
|
||||||
$sql .= ', AutoExecute = '. ( !empty($_REQUEST['filter']['AutoExecute']) ? 1 : 0);
|
$sql .= ', AutoDelete = '. ( !empty($_REQUEST['filter']['AutoDelete']) ? 1 : 0);
|
||||||
$sql .= ', AutoExecuteCmd = '.dbEscape($_REQUEST['filter']['AutoExecuteCmd']);
|
$sql .= ', Background = '. ( !empty($_REQUEST['filter']['Background']) ? 1 : 0);
|
||||||
$sql .= ', AutoDelete = '. ( !empty($_REQUEST['filter']['AutoDelete']) ? 1 : 0);
|
$sql .= ', Concurrent = '. ( !empty($_REQUEST['filter']['Concurrent']) ? 1 : 0);
|
||||||
$sql .= ', Background = '. ( !empty($_REQUEST['filter']['Background']) ? 1 : 0);
|
|
||||||
$sql .= ', Concurrent = '. ( !empty($_REQUEST['filter']['Concurrent']) ? 1 : 0);
|
dbQuery( $sql. $endSql );
|
||||||
|
if ( ! $_REQUEST['Id'] ) {
|
||||||
|
$_REQUEST['Id'] = dbInsertId();
|
||||||
|
}
|
||||||
|
|
||||||
dbQuery( $sql. $endSql );
|
|
||||||
if ( $filterName ) {
|
|
||||||
$filter = dbFetchOne( 'SELECT * FROM Filters WHERE Name=?', NULL, array($filterName) );
|
|
||||||
if ( $filter ) {
|
|
||||||
# This won't work yet because refreshparent refreshes the old filter. Need to do a redirect instead of a refresh.
|
|
||||||
$_REQUEST['Id'] = $filter['Id'];
|
|
||||||
} else {
|
|
||||||
Error("No new Id despite new name");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // end if filterName or endsql
|
|
||||||
} // end if save or execute
|
} // end if save or execute
|
||||||
} // end if canEdit(Events)
|
} // end if canEdit(Events)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue