diff --git a/src/application/controllers/backend_api.php b/src/application/controllers/backend_api.php
index 674441bb..79a08689 100644
--- a/src/application/controllers/backend_api.php
+++ b/src/application/controllers/backend_api.php
@@ -807,13 +807,17 @@ class Backend_api extends CI_Controller {
public function ajax_save_settings() {
try {
if ($_POST['type'] == SETTINGS_SYSTEM) {
- // @task Implement save settings.
+ $this->load->model('settings_model');
+ $settings = json_decode($_POST['settings'], true);
+ $this->settings_model->save_settings($settings);
} else if ($_POST['type'] == SETTINGS_USER) {
$this->load->library('session');
$this->load->model('user_model');
$user_id = $this->session->userdata('user_id');
$this->user_model->save_settings($_POST['settings'], $user_id);
}
+
+ echo json_encode(AJAX_SUCCESS);
} catch(Exception $exc) {
echo json_encode(array(
'exceptions' => array(exceptionToJavaScript($exc))
diff --git a/src/application/models/settings_model.php b/src/application/models/settings_model.php
index 98b3acd3..48bf3e75 100644
--- a/src/application/models/settings_model.php
+++ b/src/application/models/settings_model.php
@@ -107,9 +107,11 @@ class Settings_Model extends CI_Model {
throw new Exception('$settings argument is invalid: '. print_r($settings, TRUE));
}
- foreach($settings as $name=>$value) {
- if (!$this->db->update('ea_settings', array('value' => $value), array('name' => $name))) {
- throw new Exception('Could not save setting (' . $name . ' - ' . $value . ')');
+ foreach($settings as $setting) {
+ $this->db->where('name', $setting['name']);
+ if (!$this->db->update('ea_settings', array('value' => $setting['value']))) {
+ throw new Exception('Could not save setting (' . $setting['name']
+ . ' - ' . $setting['value'] . ')');
}
}
diff --git a/src/application/views/backend/settings.php b/src/application/views/backend/settings.php
index 1ad43951..9a86721c 100644
--- a/src/application/views/backend/settings.php
+++ b/src/application/views/backend/settings.php
@@ -1,5 +1,9 @@
+
+
-
+
- General
- Business Logic
@@ -35,7 +39,7 @@