From 0d83fc5be74a4dec3d303b095f58f3cf85a048e2 Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:27:59 +1000 Subject: [PATCH 1/6] 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; } From 99a212803a87e1ed945fa78e12e4e10da9728355 Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:29:35 +1000 Subject: [PATCH 2/6] Converted filter action to use table Id's instead of filterName's when editing existings and creating new filters. --- web/skins/classic/views/filter.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 757fd1bee..8723bcc99 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -22,15 +22,15 @@ if ( !canView( 'Events' ) ) { $view = "error"; return; } -$selectName = "filterName"; +$selectName = "filterId"; $filterNames = array( ''=>translate('ChooseFilter') ); -foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row ) { - $filterNames[$row['Name']] = $row['Name']; +foreach ( dbFetchAll( "select * from Filters order by Id" ) as $row ) { + $filterNames[$row['Id']] = $row['Name']; if ( $row['Background'] ) - $filterNames[$row['Name']] .= "*"; + $filterNames[$row['Id']] .= "*"; if ( $row['Concurrent'] ) - $filterNames[$row['Name']] .= "&"; - if ( !empty($_REQUEST['reload']) && isset($_REQUEST['filterName']) && $_REQUEST['filterName'] == $row['Name'] ) + $filterNames[$row['Id']] .= "&"; + if ( !empty($_REQUEST['reload']) && isset($_REQUEST['filterId']) && $_REQUEST['filterId'] == $row['Id'] ) $dbFilter = $row; } @@ -57,7 +57,7 @@ if ( isset( $_REQUEST['reload'] ) and ! $_REQUEST['reload'] ) { $dbFilter['AutoUpload'] = isset( $_REQUEST['AutoUpload'] ); $dbFilter['AutoVideo'] = isset( $_REQUEST['AutoVideo'] ); $dbFilter['AutoDelete'] = isset( $_REQUEST['AutoDelete'] ); - $dbFilter['Name'] = $_REQUEST['filterName']; + $dbFilter['Name'] = $_REQUEST['filterId']; } $conjunctionTypes = array( From cd626a54ee5fd80cc3dc9abb9e7a307d2e71a496 Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:29:44 +1000 Subject: [PATCH 3/6] Converted filter action to use table Id's instead of filterName's when editing existings and creating new filters. --- web/skins/classic/views/filtersave.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/skins/classic/views/filtersave.php b/web/skins/classic/views/filtersave.php index 1ce41087c..981fc7a36 100644 --- a/web/skins/classic/views/filtersave.php +++ b/web/skins/classic/views/filtersave.php @@ -24,12 +24,12 @@ if ( !canEdit( 'Events' ) ) return; } -$selectName = "filterName"; -$newSelectName = "new".ucfirst($selectName); -foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row ) +$selectName = "filterId"; +$newSelectName = "newFilterName"; +foreach ( dbFetchAll( "select * from Filters order by Id" ) as $row ) { - $filterNames[$row['Name']] = $row['Name']; - if ( $_REQUEST['filterName'] == $row['Name'] ) + $filterNames[$row['Id']] = $row['Name']; + if ( $_REQUEST['filterId'] == $row['Id'] ) { $filterData = $row; } From 67f2ddc404907835ba16990f1e077514464806a4 Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:55:58 +1000 Subject: [PATCH 4/6] Changed filter list order back to Name Added extra argument 'Id' to delete button onClick call --- web/skins/classic/views/filter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 8723bcc99..4d818a408 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -24,7 +24,7 @@ if ( !canView( 'Events' ) ) { } $selectName = "filterId"; $filterNames = array( ''=>translate('ChooseFilter') ); -foreach ( dbFetchAll( "select * from Filters order by Id" ) as $row ) { +foreach ( dbFetchAll( "select * from Filters order by Name" ) as $row ) { $filterNames[$row['Id']] = $row['Name']; if ( $row['Background'] ) $filterNames[$row['Id']] .= "*"; @@ -328,7 +328,7 @@ if ( ZM_OPT_MESSAGE ) { - + From 17555bf6236d4665f2eb35ce0641b0e516d4d1a4 Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:57:31 +1000 Subject: [PATCH 5/6] Added extra argument 'id' to deleteFilter function to send to delete action for deleting a filter. --- web/skins/classic/views/js/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index 5ed5d62f3..a90f492b2 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -79,13 +79,13 @@ function saveFilter( element ) form.submit(); } -function deleteFilter( element, name ) +function deleteFilter( element, id, name ) { if ( confirm( deleteSavedFilterString+" '"+name+"'" ) ) { var form = element.form; form.action.value = 'delete'; - form.fid.value = name; + form.fid.value = id; submitToFilter( element, 1 ); } } From 01ae4de123552636b990b1c4201f38e7a61a05bd Mon Sep 17 00:00:00 2001 From: bhaal2 Date: Thu, 15 Sep 2016 01:59:31 +1000 Subject: [PATCH 6/6] Modified so deleting a filter is done by table Id instead of Name --- web/includes/actions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 8c71c15a4..09b43696b 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -232,7 +232,7 @@ if ( !empty($action) ) { } if ( !empty($_REQUEST['fid']) ) { - dbQuery( 'DELETE FROM Filters WHERE Name=?', array( $_REQUEST['fid'] ) ); + dbQuery( 'DELETE FROM Filters WHERE Id=?', array( $_REQUEST['filterId'] ) ); //$refreshParent = true; } }