| 
									
										
										
										
											2023-08-18 21:16:01 +08: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 22:58:27 +08:00
										 |  |  | 		foreach($obj as $option_key => $option_value) { | 
					
						
							|  |  |  | 			$obj[$option_key]=$this->security->xss_clean($option_value); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2023-08-18 21:30:04 +08:00
										 |  |  | 		if ($obj['sat_name'] ?? '' != '') { | 
					
						
							| 
									
										
										
										
											2023-08-19 00:54:50 +08:00
										 |  |  | 			$option_name=$obj['sat_name'].'/'.$obj['mode']; | 
					
						
							| 
									
										
										
										
											2023-08-18 21:30:04 +08:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			$option_name=$obj['band'].'/'.$obj['mode']; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2023-08-19 12:11:41 +08:00
										 |  |  | 		$this->user_options_model->set_option('Favourite',$option_name, $obj); | 
					
						
							|  |  |  | 		$jsonout['success']=1; | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($jsonout); | 
					
						
							| 
									
										
										
										
											2023-08-18 22:42:04 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-18 22:58:27 +08:00
										 |  |  | 	public function get_fav() { | 
					
						
							| 
									
										
										
										
											2023-08-18 22:42:04 +08:00
										 |  |  | 		$result=$this->user_options_model->get_options('Favourite'); | 
					
						
							| 
									
										
										
										
											2023-08-19 13:02:50 +08:00
										 |  |  | 		$jsonout=[]; | 
					
						
							| 
									
										
										
										
											2023-08-18 22:42:04 +08:00
										 |  |  | 		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 21:16:01 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-08-18 22:58:27 +08: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);	 | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2023-08-19 12:11:41 +08:00
										 |  |  | 		$jsonout['success']=1; | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($jsonout); | 
					
						
							| 
									
										
										
										
											2023-08-18 22:58:27 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// [MAP Custom] //
 | 
					
						
							|  |  |  | 	public function get_map_custom() { | 
					
						
							|  |  |  | 		$result=$this->user_options_model->get_options('map_custom'); | 
					
						
							|  |  |  | 		$jsonout=[]; | 
					
						
							|  |  |  | 		foreach($result->result() as $options) { | 
					
						
							|  |  |  | 			if ($options->option_name=='icon') $jsonout[$options->option_key]=json_decode($options->option_value,true); | 
					
						
							|  |  |  | 				else $jsonout[$options->option_name.'_'.$options->option_key]=$options->option_value; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		header('Content-Type: application/json'); | 
					
						
							|  |  |  | 		echo json_encode($jsonout); | 
					
						
							| 
									
										
										
										
											2023-12-04 08:20:27 +08:00
										 |  |  | 	}	 | 
					
						
							| 
									
										
										
										
											2023-12-03 16:37:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-04 08:20:27 +08:00
										 |  |  | 	public function dismissVersionDialog() { | 
					
						
							|  |  |  | 		$this->user_options_model->set_option('version_dialog', 'confirmed', array('boolean' => 'true')); | 
					
						
							| 
									
										
										
										
											2023-12-03 16:37:18 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-08-18 21:16:01 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |