public function save($id) { $post = AECToolbox::cleanPOST($_POST, false); if ($id) { $row = aecService::getById($id); } else { $row = aecService::getByType($post['type']); } $row->savePOSTsettings($post); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-2); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-2); </script>\n"; exit; } $row->reorder(); if (empty($id)) { $this->params['id'] = $row->getMax(); } }