Update saving action to use our ORM methods
parent
dda630f522
commit
4c8f96b786
|
@ -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");
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue