From e2f32ab0917b8d1b2bfb3719a9cff721fa2fd001 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 4 Jan 2019 09:43:36 -0500 Subject: [PATCH] Upgrade config saving --- web/includes/actions/options.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/web/includes/actions/options.php b/web/includes/actions/options.php index f6cae406b..263a592f8 100644 --- a/web/includes/actions/options.php +++ b/web/includes/actions/options.php @@ -48,18 +48,24 @@ if ( $action == 'delete' ) { } } else if ( $action == 'options' && isset($_REQUEST['tab']) ) { - $configCat = $configCats[$_REQUEST['tab']]; + + $result = dbQuery('SELECT Name,Value,Type FROM Config WHERE Category=? ORDER BY Id ASC', array($_REQUEST['tab'])); + if ( !$result ) { + echo mysql_error(); + return; + } + $changed = false; - foreach ( $configCat as $name=>$value ) { + while( $config = dbFetchNext($result) ) { unset($newValue); - if ( $value['Type'] == 'boolean' && empty($_REQUEST['newConfig'][$name]) ) { + if ( $config['Type'] == 'boolean' && empty($_REQUEST['newConfig'][$config['Name']]) ) { $newValue = 0; - } else if ( isset($_REQUEST['newConfig'][$name]) ) { - $newValue = preg_replace("/\r\n/", "\n", stripslashes($_REQUEST['newConfig'][$name])); + } else if ( isset($_REQUEST['newConfig'][$config['Name']]) ) { + $newValue = preg_replace("/\r\n/", "\n", stripslashes($_REQUEST['newConfig'][$config['Name']])); } - if ( isset($newValue) && ($newValue != $value['Value']) ) { - dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $name)); + if ( isset($newValue) && ($newValue != $config['Value']) ) { + dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $config['Name'])); $changed = true; } }