Update saving action to use our ORM methods

pull/2993/head
Isaac Connor 2020-07-25 14:28:01 -04:00
parent dda630f522
commit 4c8f96b786
1 changed files with 4 additions and 13 deletions

View File

@ -19,31 +19,22 @@
//
// System edit actions
if ( ! canEdit('System') ) {
if ( !canEdit('System') ) {
ZM\Warning('Need System permission to edit Storage');
return;
}
if ( $action == 'Save' ) {
if ( !empty($_REQUEST['id']) )
$dbStorage = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, array($_REQUEST['id']));
else
$dbStorage = array();
$storage = new ZM\Storage($_REQUEST['id']);
$types = array();
$changes = getFormChanges($dbStorage, $_REQUEST['newStorage'], $types);
$changes = $storage->changes($_REQUEST['newStorage']);
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));
}
$storage->save($changes);
$refreshParent = true;
}
$view = 'none';
} else {
ZM\Error("Unknown action $action in saving Storage");
}
?>