public function save_action() { if ($this->_validate()) { require_once UNOSLIDER_BASE . '/application/models/unoslider_presets.php'; $model = new Unoslider_Presets_Model(); $data = array('title' => $_POST['title'], 'animation' => serialize($_POST['animation']), 'block' => serialize($_POST['block'])); if (empty($_POST['id'])) { $id = $model->insert($data); $success = $id === 0 ? false : true; $response = json_encode(array('success' => $success, 'id' => $id)); } else { $result = $model->update($_POST['id'], $data); $success = $result === false ? false : true; $response = json_encode(array('success' => $success)); } if (!$success) { header('HTTP/1.1 403 Forbidden'); } header("Content-Type: application/json"); echo $response; } exit; }