diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php new file mode 100755 index 00000000..c021dfb0 --- /dev/null +++ b/application/controllers/User_options.php @@ -0,0 +1,19 @@ +load->model('user_model'); + $this->load->model('user_options_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function add_edit_fav() { + $obj = json_decode(file_get_contents("php://input"), true); + $this->user_options_model->set_option('Favourite',$obj); + } +} + + +?> diff --git a/application/models/User_options.php b/application/models/User_options_model.php similarity index 82% rename from application/models/User_options.php rename to application/models/User_options_model.php index ea375bc3..68e07816 100644 --- a/application/models/User_options.php +++ b/application/models/User_options_model.php @@ -1,6 +1,6 @@ db->where('user_id', $this->session->userdata('user_id')); @@ -11,8 +11,7 @@ class User_options extends CI_Model public function set_option($option_type, $option_array) { $uid=$this->session->userdata('user_id'); $sql='insert into user_options (user_id,option_type,option_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; - $query = $this->db->query($sql); - foreach ($option_array() as $one_option) { + foreach($option_array as $option_key => $option_value) { $query = $this->db->query($sql, array($uid, $option_type, $option_key, $option_value, $option_value)); } } diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 4e04d580..02acf4fc 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -15,7 +15,7 @@ $( document ).ready(function() { payload.prop_mode=$('#prop_mode').val(); payload.mode=$('#mode').val(); $.ajax({ - url: base_url+'index.php/user_options/set_options', + url: base_url+'index.php/user_options/add_edit_fav', method: 'POST', dataType: 'json', contentType: "application/json; charset=utf-8",