add save and delete actions for Storage

This commit is contained in:
Isaac Connor 2015-12-15 11:12:33 -05:00
parent c07c63cde6
commit 9ffbaabde5
1 changed files with 52 additions and 22 deletions

View File

@ -767,35 +767,65 @@ if ( !empty($action) )
// System edit actions // System edit actions
if ( canEdit( 'System' ) ) if ( canEdit( 'System' ) )
{ {
if ( isset( $_REQUEST['object'] ) and ( $_REQUEST['object'] == 'server' ) ) { if ( isset( $_REQUEST['object'] ) ) {
if ( $_REQUEST['object'] == 'server' ) {
if ( $action == "Save" ) { if ( $action == "Save" ) {
if ( !empty($_REQUEST['id']) ) if ( !empty($_REQUEST['id']) )
$dbServer = dbFetchOne( "SELECT * FROM Servers WHERE Id=?", NULL, array($_REQUEST['id']) ); $dbServer = dbFetchOne( "SELECT * FROM Servers WHERE Id=?", NULL, array($_REQUEST['id']) );
else else
$dbServer = array(); $dbServer = array();
$types = array(); $types = array();
$changes = getFormChanges( $dbServer, $_REQUEST['newServer'], $types ); $changes = getFormChanges( $dbServer, $_REQUEST['newServer'], $types );
if ( count( $changes ) ) { if ( count( $changes ) ) {
if ( !empty($_REQUEST['id']) ) { if ( !empty($_REQUEST['id']) ) {
dbQuery( "UPDATE Servers SET ".implode( ", ", $changes )." WHERE Id = ?", array($_REQUEST['id']) ); dbQuery( "UPDATE Servers SET ".implode( ", ", $changes )." WHERE Id = ?", array($_REQUEST['id']) );
} else { } else {
dbQuery( "INSERT INTO Servers set ".implode( ", ", $changes ) ); 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; $refreshParent = true;
} else {
Error( "Unknown action $action in saving Server" );
} }
$view = 'none'; } else if ( $_REQUEST['object'] == 'storage' ) {
} else if ( $action == 'delete' ) { if ( $action == "Save" ) {
if ( !empty($_REQUEST['markIds']) ) { if ( !empty($_REQUEST['id']) )
foreach( $_REQUEST['markIds'] as $Id ) $dbStorage = dbFetchOne( "SELECT * FROM Storage WHERE Id=?", NULL, array($_REQUEST['id']) );
dbQuery( "DELETE FROM Servers WHERE Id=?", array($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; } # end if isset($_REQUEST['object'] )
} else {
Error( "Unknown action $action in saving Server" );
}
} else if ( $action == "version" && isset($_REQUEST['option']) ) } else if ( $action == "version" && isset($_REQUEST['option']) )
{ {