2023-08-18 13:16:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class User_Options extends CI_Controller {
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->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);
|
2023-08-18 14:58:27 +00:00
|
|
|
foreach($obj as $option_key => $option_value) {
|
|
|
|
$obj[$option_key]=$this->security->xss_clean($option_value);
|
|
|
|
}
|
2023-08-18 13:30:04 +00:00
|
|
|
if ($obj['sat_name'] ?? '' != '') {
|
2023-08-18 16:54:50 +00:00
|
|
|
$option_name=$obj['sat_name'].'/'.$obj['mode'];
|
2023-08-18 13:30:04 +00:00
|
|
|
} else {
|
|
|
|
$option_name=$obj['band'].'/'.$obj['mode'];
|
|
|
|
}
|
2023-08-18 14:42:04 +00:00
|
|
|
return $this->user_options_model->set_option('Favourite',$option_name, $obj);
|
|
|
|
}
|
|
|
|
|
2023-08-18 14:58:27 +00:00
|
|
|
public function get_fav() {
|
2023-08-18 14:42:04 +00:00
|
|
|
$result=$this->user_options_model->get_options('Favourite');
|
|
|
|
foreach($result->result() as $options) {
|
|
|
|
$jsonout[$options->option_name][$options->option_key]=$options->option_value;
|
|
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode($jsonout);
|
2023-08-18 13:16:01 +00:00
|
|
|
}
|
2023-08-18 14:58:27 +00:00
|
|
|
|
|
|
|
public function del_fav() {
|
|
|
|
$result=$this->user_options_model->get_options('Favourite');
|
|
|
|
$obj = json_decode(file_get_contents("php://input"), true);
|
|
|
|
if ($obj['option_name'] ?? '' != '') {
|
|
|
|
$option_name=$this->security->xss_clean($obj['option_name']);
|
|
|
|
$this->user_options_model->del_option('Favourite',$option_name);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2023-08-18 13:16:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|