Fix saving logic
This commit is contained in:
parent
dc96ca72a8
commit
93f81daa8d
|
@ -126,13 +126,11 @@ if ( !empty($action) ) {
|
|||
if ( $action == 'delete' ) {
|
||||
if ( ! empty($_REQUEST['Id']) ) {
|
||||
dbQuery( 'DELETE FROM Filters WHERE Id=?', array( $_REQUEST['Id'] ) );
|
||||
//$refreshParent = true;
|
||||
}
|
||||
} else if ( ( $action == 'save' ) or ( $action == 'execute' ) or ( $action == 'submit' ) ) {
|
||||
|
||||
$sql = '';
|
||||
$endSql = '';
|
||||
$filterName = '';
|
||||
if ( $action == 'execute' or $action == 'submit' ) {
|
||||
# Replace will teplace any filter with the same Id
|
||||
# Since we aren't specifying the Id , this is effectively an insert
|
||||
|
@ -144,8 +142,6 @@ if ( !empty($action) ) {
|
|||
$sql = 'INSERT INTO Filters SET';
|
||||
}
|
||||
|
||||
# endSql is only set if ! filterName... so... woulnd't this always be true
|
||||
if ( !empty($filterName) || $endSql ) {
|
||||
$_REQUEST['filter']['sort_field'] = validStr($_REQUEST['filter']['sort_field']);
|
||||
$_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['filter']['sort_asc']);
|
||||
$_REQUEST['filter']['limit'] = validInt($_REQUEST['filter']['limit']);
|
||||
|
@ -163,16 +159,10 @@ if ( !empty($action) ) {
|
|||
$sql .= ', Concurrent = '. ( !empty($_REQUEST['filter']['Concurrent']) ? 1 : 0);
|
||||
|
||||
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");
|
||||
if ( ! $_REQUEST['Id'] ) {
|
||||
$_REQUEST['Id'] = dbInsertId();
|
||||
}
|
||||
}
|
||||
} // end if filterName or endsql
|
||||
|
||||
} // end if save or execute
|
||||
} // end if canEdit(Events)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue