updates in filters, try to get the new filter loaded when saving with a new name
This commit is contained in:
parent
146ac87b51
commit
8ef7a708bd
|
@ -133,37 +133,50 @@ if ( !empty($action) ) {
|
|||
$filterName = $_REQUEST['newFilterName'];
|
||||
}
|
||||
if ( $filterName ) {
|
||||
$sql = "REPLACE INTO Filters SET Name = ".dbEscape($filterName).",";
|
||||
# Replace will teplace any filter with the same Id
|
||||
# Since we aren't specifying the Id , this is effectively an insert
|
||||
$sql = 'REPLACE INTO Filters SET Name = '.dbEscape($filterName).',';
|
||||
} else {
|
||||
$sql = 'UPDATE Filters SET';
|
||||
$endSql = "where Id = ".$_REQUEST['Id'];
|
||||
$endSql = 'WHERE Id = '.$_REQUEST['Id'];
|
||||
}
|
||||
|
||||
# endSql is only set if ! filterName... so... woulnd't this always be true
|
||||
if ( !empty($filterName) || $endSql ) {
|
||||
$_REQUEST['filter']['sort_field'] = validStr($_REQUEST['sort_field']);
|
||||
$_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['sort_asc']);
|
||||
$_REQUEST['filter']['limit'] = validInt($_REQUEST['limit']);
|
||||
$sql .= " Query = ".dbEscape(jsonEncode($_REQUEST['filter']));
|
||||
$sql .= ' Query = '.dbEscape(jsonEncode($_REQUEST['filter']));
|
||||
if ( !empty($_REQUEST['AutoArchive']) )
|
||||
$sql .= ", AutoArchive = ".dbEscape($_REQUEST['AutoArchive']);
|
||||
$sql .= ', AutoArchive = '.dbEscape($_REQUEST['AutoArchive']);
|
||||
if ( !empty($_REQUEST['AutoVideo']) )
|
||||
$sql .= ", AutoVideo = ".dbEscape($_REQUEST['AutoVideo']);
|
||||
$sql .= ', AutoVideo = '.dbEscape($_REQUEST['AutoVideo']);
|
||||
if ( !empty($_REQUEST['AutoUpload']) )
|
||||
$sql .= ", AutoUpload = ".dbEscape($_REQUEST['AutoUpload']);
|
||||
$sql .= ', AutoUpload = '.dbEscape($_REQUEST['AutoUpload']);
|
||||
if ( !empty($_REQUEST['AutoEmail']) )
|
||||
$sql .= ", AutoEmail = ".dbEscape($_REQUEST['AutoEmail']);
|
||||
$sql .= ', AutoEmail = '.dbEscape($_REQUEST['AutoEmail']);
|
||||
if ( !empty($_REQUEST['AutoMessage']) )
|
||||
$sql .= ", AutoMessage = ".dbEscape($_REQUEST['AutoMessage']);
|
||||
$sql .= ', AutoMessage = '.dbEscape($_REQUEST['AutoMessage']);
|
||||
if ( !empty($_REQUEST['AutoExecute']) && !empty($_REQUEST['AutoExecuteCmd']) )
|
||||
$sql .= ", AutoExecute = ".dbEscape($_REQUEST['AutoExecute']).", AutoExecuteCmd = ".dbEscape($_REQUEST['AutoExecuteCmd']);
|
||||
$sql .= ', AutoExecute = '.dbEscape($_REQUEST['AutoExecute']).", AutoExecuteCmd = ".dbEscape($_REQUEST['AutoExecuteCmd']);
|
||||
if ( !empty($_REQUEST['AutoDelete']) )
|
||||
$sql .= ", AutoDelete = ".dbEscape($_REQUEST['AutoDelete']);
|
||||
$sql .= ', AutoDelete = '.dbEscape($_REQUEST['AutoDelete']);
|
||||
if ( !empty($_REQUEST['background']) )
|
||||
$sql .= ", Background = ".dbEscape($_REQUEST['background']);
|
||||
$sql .= ', Background = '.dbEscape($_REQUEST['background']);
|
||||
if ( !empty($_REQUEST['concurrent']) )
|
||||
$sql .= ", Concurrent = ".dbEscape($_REQUEST['concurrent']);
|
||||
$sql .= ', Concurrent = '.dbEscape($_REQUEST['concurrent']);
|
||||
$sql .= $endSql;
|
||||
dbQuery( $sql );
|
||||
$refreshParent = true;
|
||||
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");
|
||||
}
|
||||
}
|
||||
$refreshParent = '/index.php?view=filter&Id='.$_REQUEST['Id'];
|
||||
}
|
||||
} // end if canedit events
|
||||
} // end if action == filter
|
||||
|
|
|
@ -26,13 +26,13 @@ $selectName = 'Id';
|
|||
$filterNames = array( ''=>translate('ChooseFilter') );
|
||||
$dbFilter = NULL;
|
||||
|
||||
foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row ) {
|
||||
foreach ( dbFetchAll( 'SELECT * FROM Filters ORDER BY Name' ) as $row ) {
|
||||
$filterNames[$row['Id']] = $row['Name'];
|
||||
if ( $row['Background'] )
|
||||
$filterNames[$row['Id']] .= "*";
|
||||
$filterNames[$row['Id']] .= '*';
|
||||
if ( $row['Concurrent'] )
|
||||
$filterNames[$row['Id']] .= "&";
|
||||
if ( !empty($_REQUEST['reload']) && isset($_REQUEST['Id']) && $_REQUEST['Id'] == $row['Id'] ) {
|
||||
$filterNames[$row['Id']] .= '&';
|
||||
if ( isset($_REQUEST['Id']) && $_REQUEST['Id'] == $row['Id'] ) {
|
||||
$dbFilter = $row;
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,12 @@ $backgroundStr = '';
|
|||
if ( $dbFilter ) {
|
||||
if ( $dbFilter['Background'] )
|
||||
$backgroundStr = '['.strtolower(translate('Background')).']';
|
||||
if ( $dbFilter['Concurrent'] )
|
||||
$backgroundStr .= '['.strtolower(translate('Concurrent')).']';
|
||||
$_REQUEST['filter'] = jsonDecode( $dbFilter['Query'] );
|
||||
$_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field'])?$_REQUEST['filter']['sort_field']:"DateTime";
|
||||
$_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc'])?$_REQUEST['filter']['sort_asc']:"1";
|
||||
$_REQUEST['limit'] = isset($_REQUEST['filter']['limit'])?$_REQUEST['filter']['limit']:"";
|
||||
$_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field'])?$_REQUEST['filter']['sort_field']:'DateTime';
|
||||
$_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc'])?$_REQUEST['filter']['sort_asc']:'1';
|
||||
$_REQUEST['limit'] = isset($_REQUEST['filter']['limit'])?$_REQUEST['filter']['limit']:'';
|
||||
unset( $_REQUEST['filter']['sort_field'] );
|
||||
unset( $_REQUEST['filter']['sort_asc'] );
|
||||
unset( $_REQUEST['filter']['limit'] );
|
||||
|
@ -71,8 +73,8 @@ $obracketTypes = array();
|
|||
$cbracketTypes = array();
|
||||
if ( isset($_REQUEST['filter']['terms']) ) {
|
||||
for ( $i = 0; $i <= count($_REQUEST['filter']['terms'])-2; $i++ ) {
|
||||
$obracketTypes[$i] = str_repeat( "(", $i );
|
||||
$cbracketTypes[$i] = str_repeat( ")", $i );
|
||||
$obracketTypes[$i] = str_repeat( '(', $i );
|
||||
$cbracketTypes[$i] = str_repeat( ')', $i );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,21 +18,18 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
if ( !canEdit( 'Events' ) )
|
||||
{
|
||||
$view = "error";
|
||||
if ( !canEdit( 'Events' ) ) {
|
||||
$view = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
$selectName = "Id";
|
||||
$newSelectName = "newFilterName";
|
||||
foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row )
|
||||
{
|
||||
$filterNames[$row['Id']] = $row['Name'];
|
||||
if ( $_REQUEST['Id'] == $row['Id'] )
|
||||
{
|
||||
$filterData = $row;
|
||||
}
|
||||
$selectName = 'Id';
|
||||
$newSelectName = 'newFilterName';
|
||||
foreach ( dbFetchAll( 'SELECT * FROM Filters ORDER BY Name' ) as $row ) {
|
||||
$filterNames[$row['Id']] = $row['Name'];
|
||||
if ( $_REQUEST['Id'] == $row['Id'] ) {
|
||||
$filterData = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$focusWindow = true;
|
||||
|
@ -64,13 +61,14 @@ xhtmlHeaders(__FILE__, translate('SaveFilter') );
|
|||
<input type="hidden" name="AutoExecute" value="<?php echo requestVar( 'AutoExecute' ) ?>"/>
|
||||
<input type="hidden" name="AutoExecuteCmd" value="<?php echo requestVar( 'AutoExecuteCmd' ) ?>"/>
|
||||
<input type="hidden" name="AutoDelete" value="<?php echo requestVar( 'AutoDelete' ) ?>"/>
|
||||
<input type="hidden" name="Id" value="<?php echo $filterData['Id'] ?>"/>
|
||||
<?php if ( count($filterNames) ) { ?>
|
||||
<p>
|
||||
<label for="<?php echo $selectName ?>"><?php echo translate('SaveAs') ?></label><?php echo buildSelect( $selectName, $filterNames ); ?><label for="<?php echo $newSelectName ?>"><?php echo translate('OrEnterNewName') ?></label><input type="text" size="32" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" value="<?php echo requestVar('filterName') ?>"/>
|
||||
</p>
|
||||
<?php } else { ?>
|
||||
<p>
|
||||
<label for="<?php echo $newSelectName ?>"><?php echo translate('EnterNewFilterName') ?></label><input type="text" size="32" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" value="">
|
||||
<label for="<?php echo $newSelectName ?>"><?php echo translate('EnterNewFilterName') ?></label><input type="text" id="<?php echo $newSelectName ?>" name="<?php echo $newSelectName ?>" />
|
||||
</p>
|
||||
<?php } ?>
|
||||
<p>
|
||||
|
|
Loading…
Reference in New Issue