From 0d83fc5be74a4dec3d303b095f58f3cf85a048e2 Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:27:59 +1000 Subject: [PATCH] Converted filter action to use table Id's instead of filterName's when editing existings and creating new filters. --- web/includes/actions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 20a20c6a4..8c71c15a4 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -139,16 +139,25 @@ if ( !empty($action) ) { { if ( !empty($_REQUEST['execute']) ) $tempFilterName = "_TempFilter".time(); - if ( isset($tempFilterName) ) + if ( isset($tempFilterName) ) { $filterName = $tempFilterName; - elseif ( !empty($_REQUEST['newFilterName']) ) + } + elseif ( !empty($_REQUEST['newFilterName']) ) { $filterName = $_REQUEST['newFilterName']; - if ( !empty($filterName) ) + $sql = "replace into Filters set Name = ".dbEscape($filterName).","; + $endSql = ''; + } + else { + $doUpdate = 1; + $sql = "update Filters set"; + $endSql = "where Id = ".$_REQUEST['filterId']; + } + if ( !empty($filterName) || $doUpdate ) { $_REQUEST['filter']['sort_field'] = validStr($_REQUEST['sort_field']); $_REQUEST['filter']['sort_asc'] = validStr($_REQUEST['sort_asc']); $_REQUEST['filter']['limit'] = validInt($_REQUEST['limit']); - $sql = "replace into Filters set Name = ".dbEscape($filterName).", Query = ".dbEscape(jsonEncode($_REQUEST['filter'])); + $sql .= " Query = ".dbEscape(jsonEncode($_REQUEST['filter'])); if ( !empty($_REQUEST['AutoArchive']) ) $sql .= ", AutoArchive = ".dbEscape($_REQUEST['AutoArchive']); if ( !empty($_REQUEST['AutoVideo']) ) @@ -167,6 +176,7 @@ if ( !empty($action) ) { $sql .= ", Background = ".dbEscape($_REQUEST['background']); if ( !empty($_REQUEST['concurrent']) ) $sql .= ", Concurrent = ".dbEscape($_REQUEST['concurrent']); + $sql .= $endSql; dbQuery( $sql ); $refreshParent = true; }