From 9ffbaabde572796f0bf5ab7156f90fa3fac4b894 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 15 Dec 2015 11:12:33 -0500 Subject: [PATCH] add save and delete actions for Storage --- web/includes/actions.php | 74 ++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 7de7a8238..a6ff20ace 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -767,35 +767,65 @@ if ( !empty($action) ) // System edit actions if ( canEdit( 'System' ) ) { - if ( isset( $_REQUEST['object'] ) and ( $_REQUEST['object'] == 'server' ) ) { + if ( isset( $_REQUEST['object'] ) ) { + if ( $_REQUEST['object'] == 'server' ) { - if ( $action == "Save" ) { - if ( !empty($_REQUEST['id']) ) - $dbServer = dbFetchOne( "SELECT * FROM Servers WHERE Id=?", NULL, array($_REQUEST['id']) ); - else - $dbServer = array(); + if ( $action == "Save" ) { + if ( !empty($_REQUEST['id']) ) + $dbServer = dbFetchOne( "SELECT * FROM Servers WHERE Id=?", NULL, array($_REQUEST['id']) ); + else + $dbServer = array(); - $types = array(); - $changes = getFormChanges( $dbServer, $_REQUEST['newServer'], $types ); + $types = array(); + $changes = getFormChanges( $dbServer, $_REQUEST['newServer'], $types ); - if ( count( $changes ) ) { - if ( !empty($_REQUEST['id']) ) { - dbQuery( "UPDATE Servers SET ".implode( ", ", $changes )." WHERE Id = ?", array($_REQUEST['id']) ); - } else { - dbQuery( "INSERT INTO Servers set ".implode( ", ", $changes ) ); + if ( count( $changes ) ) { + if ( !empty($_REQUEST['id']) ) { + dbQuery( "UPDATE Servers SET ".implode( ", ", $changes )." WHERE Id = ?", array($_REQUEST['id']) ); + } else { + dbQuery( "INSERT INTO Servers set ".implode( ", ", $changes ) ); + } + $refreshParent = true; + } + $view = 'none'; + } else if ( $action == 'delete' ) { + if ( !empty($_REQUEST['markIds']) ) { + foreach( $_REQUEST['markIds'] as $Id ) + dbQuery( "DELETE FROM Servers WHERE Id=?", array($Id) ); } $refreshParent = true; + } else { + Error( "Unknown action $action in saving Server" ); } - $view = 'none'; - } else if ( $action == 'delete' ) { - if ( !empty($_REQUEST['markIds']) ) { - foreach( $_REQUEST['markIds'] as $Id ) - dbQuery( "DELETE FROM Servers WHERE Id=?", array($Id) ); + } else if ( $_REQUEST['object'] == 'storage' ) { + if ( $action == "Save" ) { + if ( !empty($_REQUEST['id']) ) + $dbStorage = dbFetchOne( "SELECT * FROM Storage WHERE Id=?", NULL, array($_REQUEST['id']) ); + else + $dbStorage = array(); + + $types = array(); + $changes = getFormChanges( $dbServer, $_REQUEST['newStorage'], $types ); + + if ( count( $changes ) ) { + if ( !empty($_REQUEST['id']) ) { + dbQuery( "UPDATE Storage SET ".implode( ", ", $changes )." WHERE Id = ?", array($_REQUEST['id']) ); + } else { + dbQuery( "INSERT INTO Storage set ".implode( ", ", $changes ) ); + } + $refreshParent = true; + } + $view = 'none'; + } else if ( $action == 'delete' ) { + if ( !empty($_REQUEST['markIds']) ) { + foreach( $_REQUEST['markIds'] as $Id ) + dbQuery( "DELETE FROM Storage WHERE Id=?", array($Id) ); + } + $refreshParent = true; + } else { + Error( "Unknown action $action in saving Storage" ); } - $refreshParent = true; - } else { - Error( "Unknown action $action in saving Server" ); - } + } # end if isset($_REQUEST['object'] ) } else if ( $action == "version" && isset($_REQUEST['option']) ) {