| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | class User extends CI_Controller | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-06 18:58:55 +08:00
										 |  |  | 	function __construct() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		parent::__construct(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		$this->lang->load(array( | 
					
						
							|  |  |  | 			'account', | 
					
						
							|  |  |  | 			'lotw', | 
					
						
							|  |  |  | 			'eqsl', | 
					
						
							|  |  |  | 			'admin', | 
					
						
							|  |  |  | 		)); | 
					
						
							| 
									
										
										
										
											2021-05-06 18:58:55 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-07-09 02:42:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Index method for the User controller. | 
					
						
							|  |  |  | 	 * This method loads the user model, authorizes the user, and displays the user accounts. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 	public function index() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		 | 
					
						
							|  |  |  | 		// Check if the user is authorized
 | 
					
						
							|  |  |  | 		if (!$this->user_model->authorize(99)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		// Get the user accounts
 | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$data['results'] = $this->user_model->users(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		// Set the page title
 | 
					
						
							| 
									
										
										
										
											2023-05-17 22:01:55 +08:00
										 |  |  | 		$data['page_title'] = $this->lang->line('admin_user_accounts'); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		// Load the views
 | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 		$this->load->view('user/main'); | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function add() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-08-18 09:27:53 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if (!$this->user_model->authorize(99)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 15:06:34 +08:00
										 |  |  | 		$data['existing_languages'] = $this->find(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 		$this->load->model('bands'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-18 09:27:53 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_name', 'Username', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_email', 'E-mail', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_password', 'Password', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_type', 'Type', 'required'); | 
					
						
							| 
									
										
										
										
											2011-09-27 03:45:07 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_firstname', 'First name', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_lastname', 'Last name', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_callsign', 'Callsign', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_locator', 'Locator', 'required'); | 
					
						
							| 
									
										
										
										
											2022-10-27 21:18:50 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_locator', 'Locator', 'callback_check_locator'); | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_timezone', 'Timezone', 'required'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-18 02:16:23 +08:00
										 |  |  | 		$data['user_add'] = true; | 
					
						
							|  |  |  | 		$data['user_form_action'] = site_url('user/add'); | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 		$data['bands'] = $this->bands->get_user_bands(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-09 19:13:41 +08:00
										 |  |  | 		// Get themes list
 | 
					
						
							|  |  |  | 		$data['themes'] = $this->user_model->getThemes(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 		// Get timezones
 | 
					
						
							|  |  |  | 		$data['timezones'] = $this->user_model->timezones(); | 
					
						
							| 
									
										
										
										
											2023-08-02 15:06:34 +08:00
										 |  |  | 		$data['language'] = 'english'; | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		// Set defaults
 | 
					
						
							|  |  |  | 		$data['dashboard_upcoming_dx_card'] = false; | 
					
						
							|  |  |  | 		$data['dashboard_qslcard_card'] = false; | 
					
						
							|  |  |  | 		$data['dashboard_eqslcard_card'] = false; | 
					
						
							|  |  |  | 		$data['dashboard_lotw_card'] = false; | 
					
						
							|  |  |  | 		$data['dashboard_vuccgrids_card'] = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$dashboard_options = $this->user_options_model->get_options('dashboard')->result(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		foreach ($dashboard_options as $item) { | 
					
						
							|  |  |  | 			$option_name = $item->option_name; | 
					
						
							|  |  |  | 			$option_key = $item->option_key; | 
					
						
							|  |  |  | 			$option_value = $item->option_value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($option_name == 'dashboard_upcoming_dx_card' && $option_key == 'enabled') { | 
					
						
							|  |  |  | 				if ($item->option_value == 'true') { | 
					
						
							|  |  |  | 					$data['dashboard_upcoming_dx_card'] = true; | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2024-04-10 22:04:07 +08:00
										 |  |  | 					$data['dashboard_upcoming_dx_card'] = false; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($option_name == 'dashboard_qslcards_card' && $option_key == 'enabled') { | 
					
						
							|  |  |  | 				if ($item->option_value == 'true') { | 
					
						
							|  |  |  | 					$data['dashboard_qslcard_card'] = true; | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2024-04-10 22:04:07 +08:00
										 |  |  | 					$data['dashboard_qslcard_card'] = false; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($option_name == 'dashboard_eqslcards_card' && $option_key == 'enabled') { | 
					
						
							|  |  |  | 				if ($item->option_value == 'true') { | 
					
						
							|  |  |  | 					$data['dashboard_eqslcard_card'] = true; | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2024-04-10 22:04:07 +08:00
										 |  |  | 					$data['dashboard_eqslcard_card'] = false; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($option_name == 'dashboard_lotw_card' && $option_key == 'enabled') { | 
					
						
							|  |  |  | 				if ($item->option_value == 'true') { | 
					
						
							|  |  |  | 					$data['dashboard_lotw_card'] = true; | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2024-04-10 22:04:07 +08:00
										 |  |  | 					$data['dashboard_lotw_card'] = false; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($option_name == 'dashboard_vuccgrids_card' && $option_key == 'enabled') { | 
					
						
							|  |  |  | 				if ($item->option_value == 'true') { | 
					
						
							|  |  |  | 					$data['dashboard_vuccgrids_card'] = true; | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2024-04-10 22:04:07 +08:00
										 |  |  | 					$data['dashboard_vuccgrids_card'] = false; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-04-10 22:04:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 15:06:34 +08:00
										 |  |  | 		if ($this->form_validation->run() == FALSE) { | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$data['page_title'] = "Add User"; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			$data['measurement_base'] = $this->config->item('measurement_base'); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_name')) { | 
					
						
							| 
									
										
										
										
											2011-08-18 09:27:53 +08:00
										 |  |  | 				$data['user_name'] = $this->input->post('user_name'); | 
					
						
							|  |  |  | 				$data['user_email'] = $this->input->post('user_email'); | 
					
						
							|  |  |  | 				$data['user_password'] = $this->input->post('user_password'); | 
					
						
							|  |  |  | 				$data['user_type'] = $this->input->post('user_type'); | 
					
						
							| 
									
										
										
										
											2011-09-27 03:45:07 +08:00
										 |  |  | 				$data['user_firstname'] = $this->input->post('user_firstname'); | 
					
						
							|  |  |  | 				$data['user_lastname'] = $this->input->post('user_lastname'); | 
					
						
							|  |  |  | 				$data['user_callsign'] = $this->input->post('user_callsign'); | 
					
						
							|  |  |  | 				$data['user_locator'] = $this->input->post('user_locator'); | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 				$data['user_timezone'] = $this->input->post('user_timezone'); | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 				$data['user_measurement_base'] = $this->input->post('user_measurement_base'); | 
					
						
							|  |  |  | 				$data['user_stylesheet'] = $this->input->post('user_stylesheet'); | 
					
						
							| 
									
										
										
										
											2022-10-19 22:27:26 +08:00
										 |  |  | 				$data['user_qth_lookup'] = $this->input->post('user_qth_lookup'); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 				$data['user_sota_lookup'] = $this->input->post('user_sota_lookup'); | 
					
						
							| 
									
										
										
										
											2022-10-19 20:52:43 +08:00
										 |  |  | 				$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup'); | 
					
						
							| 
									
										
										
										
											2023-05-02 03:14:30 +08:00
										 |  |  | 				$data['user_pota_lookup'] = $this->input->post('user_pota_lookup'); | 
					
						
							| 
									
										
										
										
											2021-03-21 04:19:07 +08:00
										 |  |  | 				$data['user_show_notes'] = $this->input->post('user_show_notes'); | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$data['user_column1'] = $this->input->post('user_column1'); | 
					
						
							|  |  |  | 				$data['user_column2'] = $this->input->post('user_column2'); | 
					
						
							|  |  |  | 				$data['user_column3'] = $this->input->post('user_column3'); | 
					
						
							|  |  |  | 				$data['user_column4'] = $this->input->post('user_column4'); | 
					
						
							| 
									
										
										
										
											2021-05-07 14:03:25 +08:00
										 |  |  | 				$data['user_column5'] = $this->input->post('user_column5'); | 
					
						
							| 
									
										
										
										
											2022-07-03 17:39:05 +08:00
										 |  |  | 				$data['user_show_profile_image'] = $this->input->post('user_show_profile_image'); | 
					
						
							| 
									
										
										
										
											2022-11-25 07:22:31 +08:00
										 |  |  | 				$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type'); | 
					
						
							| 
									
										
										
										
											2023-01-28 00:24:48 +08:00
										 |  |  | 				$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload'); | 
					
						
							| 
									
										
										
										
											2023-07-06 16:17:20 +08:00
										 |  |  | 				$data['user_mastodon_url'] = $this->input->post('user_mastodon_url'); | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 				$data['user_default_band'] = $this->input->post('user_default_band'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '') . ($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '') . ($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '') . ($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : ''); | 
					
						
							| 
									
										
										
										
											2023-11-01 21:24:13 +08:00
										 |  |  | 				$data['user_qso_end_times'] = $this->input->post('user_qso_end_times'); | 
					
						
							| 
									
										
										
										
											2023-11-05 01:31:46 +08:00
										 |  |  | 				$data['user_quicklog'] = $this->input->post('user_quicklog'); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:29:59 +08:00
										 |  |  | 				$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter'); | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 				$data['user_hamsat_key'] = $this->input->post('user_hamsat_key'); | 
					
						
							|  |  |  | 				$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 				$data['language'] = $this->input->post('language'); | 
					
						
							| 
									
										
										
										
											2023-12-18 02:16:23 +08:00
										 |  |  | 				$this->load->view('user/edit', $data); | 
					
						
							| 
									
										
										
										
											2011-08-18 09:27:53 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2023-12-18 02:16:23 +08:00
										 |  |  | 				$this->load->view('user/edit', $data); | 
					
						
							| 
									
										
										
										
											2011-08-18 09:27:53 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2023-08-02 15:06:34 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			switch ($this->user_model->add( | 
					
						
							|  |  |  | 				$this->input->post('user_name'), | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$this->input->post('user_password'), | 
					
						
							|  |  |  | 				$this->input->post('user_email'), | 
					
						
							|  |  |  | 				$this->input->post('user_type'), | 
					
						
							|  |  |  | 				$this->input->post('user_firstname'), | 
					
						
							|  |  |  | 				$this->input->post('user_lastname'), | 
					
						
							|  |  |  | 				$this->input->post('user_callsign'), | 
					
						
							|  |  |  | 				$this->input->post('user_locator'), | 
					
						
							|  |  |  | 				$this->input->post('user_timezone'), | 
					
						
							|  |  |  | 				$this->input->post('user_measurement_base'), | 
					
						
							|  |  |  | 				$this->input->post('user_date_format'), | 
					
						
							|  |  |  | 				$this->input->post('user_stylesheet'), | 
					
						
							| 
									
										
										
										
											2022-10-19 22:27:26 +08:00
										 |  |  | 				$this->input->post('user_qth_lookup'), | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$this->input->post('user_sota_lookup'), | 
					
						
							| 
									
										
										
										
											2022-10-19 20:52:43 +08:00
										 |  |  | 				$this->input->post('user_wwff_lookup'), | 
					
						
							| 
									
										
										
										
											2023-05-02 03:14:30 +08:00
										 |  |  | 				$this->input->post('user_pota_lookup'), | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$this->input->post('user_show_notes'), | 
					
						
							|  |  |  | 				$this->input->post('user_column1'), | 
					
						
							|  |  |  | 				$this->input->post('user_column2'), | 
					
						
							|  |  |  | 				$this->input->post('user_column3'), | 
					
						
							| 
									
										
										
										
											2021-05-07 14:03:25 +08:00
										 |  |  | 				$this->input->post('user_column4'), | 
					
						
							| 
									
										
										
										
											2022-04-04 19:17:33 +08:00
										 |  |  | 				$this->input->post('user_column5'), | 
					
						
							| 
									
										
										
										
											2022-11-25 07:22:31 +08:00
										 |  |  | 				$this->input->post('user_show_profile_image'), | 
					
						
							| 
									
										
										
										
											2023-01-28 00:24:48 +08:00
										 |  |  | 				$this->input->post('user_previous_qsl_type'), | 
					
						
							| 
									
										
										
										
											2023-07-06 16:17:20 +08:00
										 |  |  | 				$this->input->post('user_amsat_status_upload'), | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 				$this->input->post('user_mastodon_url'), | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 				$this->input->post('user_default_band'), | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '') . ($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '') . ($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '') . ($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : ''), | 
					
						
							| 
									
										
										
										
											2023-11-01 21:24:13 +08:00
										 |  |  | 				$this->input->post('user_qso_end_times'), | 
					
						
							| 
									
										
										
										
											2023-11-05 01:31:46 +08:00
										 |  |  | 				$this->input->post('user_quicklog'), | 
					
						
							| 
									
										
										
										
											2023-11-05 19:29:59 +08:00
										 |  |  | 				$this->input->post('user_quicklog_enter'), | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 				$this->input->post('language'), | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 				$this->input->post('user_hamsat_key'), | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 				$this->input->post('user_hamsat_workable_only'), | 
					
						
							|  |  |  | 				$this->input->post('user_callbook_type'), | 
					
						
							|  |  |  | 				$this->input->post('user_callbook_username'), | 
					
						
							|  |  |  | 				$this->input->post('user_callbook_password') | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			)) { | 
					
						
							|  |  |  | 					// Check for errors
 | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 				case EUSERNAMEEXISTS: | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$data['username_error'] = 'Username <b>' . $this->input->post('user_name') . '</b> already in use!'; | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				case EEMAILEXISTS: | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$data['email_error'] = 'E-mail address <b>' . $this->input->post('user_email') . '</b> already in use!'; | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				case EPASSWORDINVALID: | 
					
						
							|  |  |  | 					$data['password_error'] = 'Invalid password!'; | 
					
						
							|  |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					// All okay, return to user screen
 | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 				case OK: | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$this->session->set_flashdata('notice', 'User ' . $this->input->post('user_name') . ' added'); | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 					redirect('user'); | 
					
						
							|  |  |  | 					return; | 
					
						
							| 
									
										
										
										
											2011-08-18 09:27:53 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$data['page_title'] = "Users"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 			$data['user_name'] = $this->input->post('user_name'); | 
					
						
							|  |  |  | 			$data['user_email'] = $this->input->post('user_email'); | 
					
						
							|  |  |  | 			$data['user_password'] = $this->input->post('user_password'); | 
					
						
							|  |  |  | 			$data['user_type'] = $this->input->post('user_type'); | 
					
						
							| 
									
										
										
										
											2011-09-27 03:45:07 +08:00
										 |  |  | 			$data['user_firstname'] = $this->input->post('user_firstname'); | 
					
						
							|  |  |  | 			$data['user_lastname'] = $this->input->post('user_lastname'); | 
					
						
							|  |  |  | 			$data['user_callsign'] = $this->input->post('user_callsign'); | 
					
						
							|  |  |  | 			$data['user_locator'] = $this->input->post('user_locator'); | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 			$data['user_measurement_base'] = $this->input->post('user_measurement_base'); | 
					
						
							|  |  |  | 			$data['user_stylesheet'] = $this->input->post('user_stylesheet'); | 
					
						
							| 
									
										
										
										
											2022-10-19 22:27:26 +08:00
										 |  |  | 			$data['user_qth_lookup'] = $this->input->post('user_qth_lookup'); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 			$data['user_sota_lookup'] = $this->input->post('user_sota_lookup'); | 
					
						
							| 
									
										
										
										
											2022-10-19 20:52:43 +08:00
										 |  |  | 			$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup'); | 
					
						
							| 
									
										
										
										
											2023-05-02 03:14:30 +08:00
										 |  |  | 			$data['user_pota_lookup'] = $this->input->post('user_pota_lookup'); | 
					
						
							| 
									
										
										
										
											2021-03-21 04:19:07 +08:00
										 |  |  | 			$data['user_show_notes'] = $this->input->post('user_show_notes'); | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 			$data['user_column1'] = $this->input->post('user_column1'); | 
					
						
							|  |  |  | 			$data['user_column2'] = $this->input->post('user_column2'); | 
					
						
							|  |  |  | 			$data['user_column3'] = $this->input->post('user_column3'); | 
					
						
							|  |  |  | 			$data['user_column4'] = $this->input->post('user_column4'); | 
					
						
							| 
									
										
										
										
											2021-05-07 14:03:25 +08:00
										 |  |  | 			$data['user_column5'] = $this->input->post('user_column5'); | 
					
						
							| 
									
										
										
										
											2022-07-03 17:39:05 +08:00
										 |  |  | 			$data['user_show_profile_image'] = $this->input->post('user_show_profile_image'); | 
					
						
							| 
									
										
										
										
											2022-11-25 07:22:31 +08:00
										 |  |  | 			$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type'); | 
					
						
							| 
									
										
										
										
											2023-01-28 00:24:48 +08:00
										 |  |  | 			$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload'); | 
					
						
							| 
									
										
										
										
											2023-07-06 16:17:20 +08:00
										 |  |  | 			$data['user_mastodon_url'] = $this->input->post('user_mastodon_url'); | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 			$data['user_default_band'] = $this->input->post('user_default_band'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '') . ($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '') . ($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '') . ($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : ''); | 
					
						
							| 
									
										
										
										
											2023-11-01 21:24:13 +08:00
										 |  |  | 			$data['user_qso_end_times'] = $this->input->post('user_qso_end_times'); | 
					
						
							| 
									
										
										
										
											2023-11-05 01:31:46 +08:00
										 |  |  | 			$data['user_quicklog'] = $this->input->post('user_quicklog'); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:29:59 +08:00
										 |  |  | 			$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 			$data['language'] = $this->input->post('language'); | 
					
						
							| 
									
										
										
										
											2023-12-18 02:16:23 +08:00
										 |  |  | 			$this->load->view('user/edit', $data); | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function find() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 		$existing_langs = array(); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		$lang_path = APPPATH . 'language'; | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$results = scandir($lang_path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		foreach ($results as $result) { | 
					
						
							|  |  |  | 			if ($result === '.' or $result === '..') continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if (is_dir(APPPATH . 'language' . '/' . $result)) { | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 				$dirs[] = $result; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return $dirs; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function edit() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if (($this->session->userdata('user_id') == '') || ((!$this->user_model->authorize(99)) && ($this->session->userdata('user_id') != $this->uri->segment(3)))) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$query = $this->user_model->get_by_id($this->uri->segment(3)); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 		$data['existing_languages'] = $this->find(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 		$this->load->model('bands'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_name', 'Username', 'required|xss_clean'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_email', 'E-mail', 'required|xss_clean'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($this->session->userdata('user_type') == 99) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 			$this->form_validation->set_rules('user_type', 'Type', 'required|xss_clean'); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_firstname', 'First name', 'required|xss_clean'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_lastname', 'Last name', 'required|xss_clean'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_callsign', 'Callsign', 'trim|required|xss_clean'); | 
					
						
							| 
									
										
										
										
											2022-10-27 21:18:50 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_locator', 'Locator', 'callback_check_locator'); | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 		$this->form_validation->set_rules('user_timezone', 'Timezone', 'required'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		$data['user_form_action'] = site_url('user/edit') . "/" . $this->uri->segment(3);; | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 		$data['bands'] = $this->bands->get_user_bands(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-09 19:13:41 +08:00
										 |  |  | 		// Get themes list
 | 
					
						
							|  |  |  | 		$data['themes'] = $this->user_model->getThemes(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 		// Get timezones
 | 
					
						
							|  |  |  | 		$data['timezones'] = $this->user_model->timezones(); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($this->form_validation->run() == FALSE) { | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$data['page_title'] = "Edit User"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			$q = $query->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$data['id'] = $q->user_id; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_name', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_name'] = $this->input->post('user_name', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_name'] = $q->user_name; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_email', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_email'] = $this->input->post('user_email', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_email'] = $q->user_email; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_password', true)) { | 
					
						
							|  |  |  | 				$data['user_password'] = $this->input->post('user_password', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_password'] = $q->user_password; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_type', true)) { | 
					
						
							|  |  |  | 				$data['user_type'] = $this->input->post('user_type', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_type'] = $q->user_type; | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_callsign', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_callsign'] = $this->input->post('user_callsign', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_callsign'] = $q->user_callsign; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_locator', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_locator'] = $this->input->post('user_locator', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_locator'] = $q->user_locator; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_firstname', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_firstname'] = $this->input->post('user_firstname', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_firstname'] = $q->user_firstname; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_lastname', true)) { | 
					
						
							| 
									
										
										
										
											2020-09-16 00:04:38 +08:00
										 |  |  | 				$data['user_lastname'] = $this->input->post('user_lastname', true); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_lastname'] = $q->user_lastname; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_callsign', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_callsign'] = $this->input->post('user_callsign', true); | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_callsign'] = $q->user_callsign; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_locator', true)) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_locator'] = $this->input->post('user_locator', true); | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_locator'] = $q->user_locator; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_timezone')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_timezone'] = $this->input->post('user_timezone', true); | 
					
						
							| 
									
										
										
										
											2011-09-28 06:47:25 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_timezone'] = $q->user_timezone; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_lotw_name')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_lotw_name'] = $this->input->post('user_lotw_name', true); | 
					
						
							| 
									
										
										
										
											2013-02-22 08:31:31 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_lotw_name'] = $q->user_lotw_name; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-06-19 21:14:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_clublog_name')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_clublog_name'] = $this->input->post('user_clublog_name', true); | 
					
						
							| 
									
										
										
										
											2019-06-19 21:14:10 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_clublog_name'] = $q->user_clublog_name; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_clublog_password')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_clublog_password'] = $this->input->post('user_clublog_password', true); | 
					
						
							| 
									
										
										
										
											2019-06-19 21:14:10 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_clublog_password'] = $q->user_clublog_password; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_lotw_password')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_lotw_password'] = $this->input->post('user_lotw_password', true); | 
					
						
							| 
									
										
										
										
											2013-02-22 08:31:31 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_lotw_password'] = $q->user_lotw_password; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_eqsl_name')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_eqsl_name'] = $this->input->post('user_eqsl_name', true); | 
					
						
							| 
									
										
										
										
											2013-08-17 22:08:26 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_eqsl_name'] = $q->user_eqsl_name; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_eqsl_password')) { | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 				$data['user_eqsl_password'] = $this->input->post('user_eqsl_password', true); | 
					
						
							| 
									
										
										
										
											2013-08-17 22:08:26 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_eqsl_password'] = $q->user_eqsl_password; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-09-14 18:29:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_measurement_base')) { | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 				$data['user_measurement_base'] = $this->input->post('user_measurement_base', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_measurement_base'] = $q->user_measurement_base; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-09-16 05:04:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_date_format')) { | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 				$data['user_date_format'] = $this->input->post('user_date_format', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_date_format'] = $q->user_date_format; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-09-23 16:59:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('language')) { | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 				$data['language'] = $this->input->post('language', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['language'] = $q->language; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			if ($this->input->post('user_stylesheet')) { | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 				$data['user_stylesheet'] = $this->input->post('user_stylesheet', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_stylesheet'] = $q->user_stylesheet; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_qth_lookup')) { | 
					
						
							| 
									
										
										
										
											2022-10-19 22:27:26 +08:00
										 |  |  | 				$data['user_qth_lookup'] = $this->input->post('user_qth_lookup', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_qth_lookup'] = $q->user_qth_lookup; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_sota_lookup')) { | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 				$data['user_sota_lookup'] = $this->input->post('user_sota_lookup', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_sota_lookup'] = $q->user_sota_lookup; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_wwff_lookup')) { | 
					
						
							| 
									
										
										
										
											2022-10-19 20:52:43 +08:00
										 |  |  | 				$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_wwff_lookup'] = $q->user_wwff_lookup; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_pota_lookup')) { | 
					
						
							| 
									
										
										
										
											2023-05-02 03:14:30 +08:00
										 |  |  | 				$data['user_pota_lookup'] = $this->input->post('user_pota_lookup', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_pota_lookup'] = $q->user_pota_lookup; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_show_notes')) { | 
					
						
							| 
									
										
										
										
											2021-03-21 04:19:07 +08:00
										 |  |  | 				$data['user_show_notes'] = $this->input->post('user_show_notes', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_show_notes'] = $q->user_show_notes; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_qso_end_times')) { | 
					
						
							| 
									
										
										
										
											2023-11-01 21:24:13 +08:00
										 |  |  | 				$data['user_qso_end_times'] = $this->input->post('user_qso_end_times', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_qso_end_times'] = $q->user_qso_end_times; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_quicklog')) { | 
					
						
							| 
									
										
										
										
											2023-11-05 01:31:46 +08:00
										 |  |  | 				$data['user_quicklog'] = $this->input->post('user_quicklog', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_quicklog'] = $q->user_quicklog; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_quicklog_enter')) { | 
					
						
							| 
									
										
										
										
											2023-11-05 19:29:59 +08:00
										 |  |  | 				$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_quicklog_enter'] = $q->user_quicklog_enter; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_show_profile_image')) { | 
					
						
							| 
									
										
										
										
											2022-07-03 17:39:05 +08:00
										 |  |  | 				$data['user_show_profile_image'] = $this->input->post('user_show_profile_image', false); | 
					
						
							| 
									
										
										
										
											2022-04-04 19:17:33 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2022-07-03 17:39:05 +08:00
										 |  |  | 				$data['user_show_profile_image'] = $q->user_show_profile_image; | 
					
						
							| 
									
										
										
										
											2022-04-04 19:17:33 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_previous_qsl_type')) { | 
					
						
							| 
									
										
										
										
											2022-11-25 07:22:31 +08:00
										 |  |  | 				$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type', false); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_previous_qsl_type'] = $q->user_previous_qsl_type; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_amsat_status_upload')) { | 
					
						
							| 
									
										
										
										
											2023-01-28 00:24:48 +08:00
										 |  |  | 				$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload', false); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_amsat_status_upload'] = $q->user_amsat_status_upload; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_mastodon_url')) { | 
					
						
							| 
									
										
										
										
											2023-07-06 16:17:20 +08:00
										 |  |  | 				$data['user_mastodon_url'] = $this->input->post('user_mastodon_url', false); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_mastodon_url'] = $q->user_mastodon_url; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_default_band')) { | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 				$data['user_default_band'] = $this->input->post('user_default_band', false); | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 				$data['user_default_band'] = $q->user_default_band; | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_default_confirmation')) { | 
					
						
							|  |  |  | 				$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '') . ($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '') . ($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '') . ($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : ''); | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 				$data['user_default_confirmation'] = $q->user_default_confirmation; | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_column1')) { | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$data['user_column1'] = $this->input->post('user_column1', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_column1'] = $q->user_column1; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_column2')) { | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$data['user_column2'] = $this->input->post('user_column2', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_column2'] = $q->user_column2; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_column3')) { | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$data['user_column3'] = $this->input->post('user_column3', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_column3'] = $q->user_column3; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_column4')) { | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 				$data['user_column4'] = $this->input->post('user_column4', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_column4'] = $q->user_column4; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_column5')) { | 
					
						
							| 
									
										
										
										
											2021-05-07 14:03:25 +08:00
										 |  |  | 				$data['user_column5'] = $this->input->post('user_column5', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_column5'] = $q->user_column5; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_winkey')) { | 
					
						
							| 
									
										
										
										
											2023-08-03 20:59:02 +08:00
										 |  |  | 				$data['user_winkey'] = $this->input->post('user_winkey', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_winkey'] = $q->winkey; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 			$this->load->model('user_options_model'); | 
					
						
							|  |  |  | 			$callbook_type_object = $this->user_options_model->get_options('callbook')->result(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if ($this->input->post('user_callbook_type', true)) { | 
					
						
							|  |  |  | 				$data['user_callbook_type'] = $this->input->post('user_callbook_type', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				if (isset($callbook_type_object[1]->option_value)) { | 
					
						
							|  |  |  | 					$data['user_callbook_type'] = $callbook_type_object[1]->option_value; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					$data['user_callbook_type'] = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Handle user_callbook_username
 | 
					
						
							|  |  |  | 			if ($this->input->post('user_callbook_username', true)) { | 
					
						
							|  |  |  | 				$data['user_callbook_username'] = $this->input->post('user_callbook_username', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				if (isset($callbook_type_object[2]->option_value)) { | 
					
						
							|  |  |  | 					$data['user_callbook_username'] = $callbook_type_object[2]->option_value; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					$data['user_callbook_username'] = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Handle user_callbook_password
 | 
					
						
							|  |  |  | 			if ($this->input->post('user_callbook_password', true)) { | 
					
						
							|  |  |  | 				$data['user_callbook_password'] = $this->input->post('user_callbook_password', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				if (isset($callbook_type_object[0]->option_value)) { | 
					
						
							|  |  |  | 					$data['user_callbook_password'] = $callbook_type_object[0]->option_value; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					$data['user_callbook_password'] = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-12 02:31:23 +08:00
										 |  |  | 			$this->load->model('user_options_model'); | 
					
						
							|  |  |  | 			$hamsat_user_object = $this->user_options_model->get_options('hamsat')->result(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_hamsat_key', true)) { | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 				$data['user_hamsat_key'] = $this->input->post('user_hamsat_key', true); | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2024-03-12 02:15:23 +08:00
										 |  |  | 				// get $q->hamsat_key if its set if not null
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if (isset($hamsat_user_object[0]->option_value)) { | 
					
						
							| 
									
										
										
										
											2024-03-12 02:31:23 +08:00
										 |  |  | 					$data['user_hamsat_key'] = $hamsat_user_object[0]->option_value; | 
					
						
							| 
									
										
										
										
											2024-03-12 02:15:23 +08:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					$data['user_hamsat_key'] = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->input->post('user_hamsat_workable_only')) { | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 				$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only', false); | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if (isset($hamsat_user_object[1]->option_value)) { | 
					
						
							| 
									
										
										
										
											2024-03-12 02:31:23 +08:00
										 |  |  | 					$data['user_hamsat_workable_only'] = $hamsat_user_object[1]->option_value; | 
					
						
							| 
									
										
										
										
											2024-03-12 02:15:23 +08:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					$data['user_hamsat_workable_only'] = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 			// Set defaults
 | 
					
						
							|  |  |  | 			$data['dashboard_upcoming_dx_card'] = false; | 
					
						
							|  |  |  | 			$data['dashboard_qslcard_card'] = false; | 
					
						
							|  |  |  | 			$data['dashboard_eqslcard_card'] = false; | 
					
						
							|  |  |  | 			$data['dashboard_lotw_card'] = false; | 
					
						
							|  |  |  | 			$data['dashboard_vuccgrids_card'] = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$dashboard_options = $this->user_options_model->get_options('dashboard')->result(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			foreach ($dashboard_options as $item) { | 
					
						
							|  |  |  | 				$option_name = $item->option_name; | 
					
						
							|  |  |  | 				$option_key = $item->option_key; | 
					
						
							|  |  |  | 				$option_value = $item->option_value; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 				if ($option_name == 'dashboard_upcoming_dx_card' && $option_key == 'enabled') { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($item->option_value == 'true') { | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 						$data['dashboard_upcoming_dx_card'] = true; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						$data['dashboard_upcoming_dx_card'] = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if ($option_name == 'dashboard_qslcards_card' && $option_key == 'enabled') { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($item->option_value == 'true') { | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 						$data['dashboard_qslcard_card'] = true; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						$data['dashboard_qslcard_card'] = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if ($option_name == 'dashboard_eqslcards_card' && $option_key == 'enabled') { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($item->option_value == 'true') { | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 						$data['dashboard_eqslcard_card'] = true; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						$data['dashboard_eqslcard_card'] = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if ($option_name == 'dashboard_lotw_card' && $option_key == 'enabled') { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($item->option_value == 'true') { | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 						$data['dashboard_lotw_card'] = true; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						$data['dashboard_lotw_card'] = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if ($option_name == 'dashboard_vuccgrids_card' && $option_key == 'enabled') { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($item->option_value == 'true') { | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 						$data['dashboard_vuccgrids_card'] = true; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						$data['dashboard_vuccgrids_card'] = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 			// [MAP Custom] GET user options //
 | 
					
						
							|  |  |  | 			$this->load->model('user_options_model'); | 
					
						
							|  |  |  | 			$options_object = $this->user_options_model->get_options('map_custom')->result(); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if (count($options_object) > 0) { | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 				foreach ($options_object as $row) { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($row->option_name == 'icon') { | 
					
						
							|  |  |  | 						$option_value = json_decode($row->option_value, true); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						foreach ($option_value as $ktype => $vtype) { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 							if ($this->input->post('user_map_' . $row->option_key . '_icon')) { | 
					
						
							|  |  |  | 								$data['user_map_' . $row->option_key . '_' . $ktype] = $this->input->post('user_map_' . $row->option_key . '_' . $ktype, true); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 							} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 								$data['user_map_' . $row->option_key . '_' . $ktype] = $vtype; | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 						$data['user_map_' . $row->option_name . '_' . $row->option_key] = $row->option_value; | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				$data['user_map_qso_icon'] = "fas fa-dot-circle"; | 
					
						
							|  |  |  | 				$data['user_map_qso_color'] = "#FF0000"; | 
					
						
							|  |  |  | 				$data['user_map_station_icon'] = "0"; | 
					
						
							|  |  |  | 				$data['user_map_station_color'] = "#0000FF"; | 
					
						
							|  |  |  | 				$data['user_map_qsoconfirm_icon'] = "0"; | 
					
						
							|  |  |  | 				$data['user_map_qsoconfirm_color'] = "#00AA00"; | 
					
						
							|  |  |  | 				$data['user_map_gridsquare_show'] = "0"; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			$data['map_icon_select'] = array( | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				'station' => array('0', 'fas fa-home', 'fas fa-broadcast-tower', 'fas fa-user', 'fas fa-dot-circle'), | 
					
						
							|  |  |  | 				'qso' => array('fas fa-broadcast-tower', 'fas fa-user', 'fas fa-dot-circle'), | 
					
						
							|  |  |  | 				'qsoconfirm' => array('0', 'fas fa-broadcast-tower', 'fas fa-user', 'fas fa-dot-circle', 'fas fa-check-circle') | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 			$this->load->view('user/edit', $data); | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 			unset($data); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			switch ($this->user_model->edit($this->input->post())) { | 
					
						
							|  |  |  | 					// Check for errors
 | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 				case EUSERNAMEEXISTS: | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$data['username_error'] = 'Username <b>' . $this->input->post('user_name', true) . '</b> already in use!'; | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				case EEMAILEXISTS: | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$data['email_error'] = 'E-mail address <b>' . $this->input->post('user_email', true) . '</b> already in use!'; | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				case EPASSWORDINVALID: | 
					
						
							|  |  |  | 					$data['password_error'] = 'Invalid password!'; | 
					
						
							|  |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					// All okay, return to user screen
 | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 				case OK: | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 					if ($this->session->userdata('user_id') == $this->uri->segment(3)) { // Editing own User? Set cookie!
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 						$cookie = array( | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							'name'   => 'language', | 
					
						
							|  |  |  | 							'value'  => $this->input->post('language', true), | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 							'expire' => time() + 1000, | 
					
						
							| 
									
										
										
										
											2023-08-02 14:37:56 +08:00
										 |  |  | 							'secure' => FALSE | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 						$this->input->set_cookie($cookie); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					if ($this->session->userdata('user_id') == $this->input->post('id', true)) { | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 						 | 
					
						
							|  |  |  | 						// Handle user_callbook_password
 | 
					
						
							| 
									
										
										
										
											2024-10-30 23:13:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 						if (isset($_POST['user_callbook_password']) && !empty($_POST['user_callbook_password'])) { | 
					
						
							| 
									
										
										
										
											2024-10-30 23:13:58 +08:00
										 |  |  | 							 | 
					
						
							|  |  |  | 							// Handle user_callbook_type
 | 
					
						
							|  |  |  | 							if (isset($_POST['user_callbook_type'])) { | 
					
						
							|  |  |  | 								$this->user_options_model->set_option('callbook', 'callbook_type', array('value' => $_POST['user_callbook_type'])); | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								$this->user_options_model->set_option('callbook', 'callbook_type', array('value' => '')); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							 | 
					
						
							|  |  |  | 							// Handle user_callbook_username
 | 
					
						
							|  |  |  | 							if (isset($_POST['user_callbook_username'])) { | 
					
						
							|  |  |  | 								$this->user_options_model->set_option('callbook', 'callbook_username', array('value' => $_POST['user_callbook_username'])); | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								$this->user_options_model->set_option('callbook', 'callbook_username', array('value' => '')); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							 | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 							// Load the encryption library
 | 
					
						
							|  |  |  | 							$this->load->library('encryption'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// Encrypt the password
 | 
					
						
							|  |  |  | 							$encrypted_password = $this->encryption->encrypt($_POST['user_callbook_password']); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// Save the encrypted password
 | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('callbook', 'callbook_password', array('value' => $encrypted_password)); | 
					
						
							| 
									
										
										
										
											2024-10-30 23:13:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							// if callbook type is QRZ
 | 
					
						
							|  |  |  | 							if ($_POST['user_callbook_type'] == 'QRZ') { | 
					
						
							|  |  |  | 								// Lookup using QRZ
 | 
					
						
							|  |  |  | 								$this->load->library('qrz'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								$qrz_session_key = $this->qrz->session($_POST['user_callbook_username'], $_POST['user_callbook_password']); | 
					
						
							|  |  |  | 								$this->session->set_userdata('qrz_session_key', $qrz_session_key); | 
					
						
							|  |  |  | 							} elseif ($_POST['user_callbook_type'] == "HamQTH") { | 
					
						
							|  |  |  | 								$this->load->library('hamqth'); | 
					
						
							|  |  |  | 								$hamqth_session_key = $this->hamqth->session($_POST['user_callbook_username'], $_POST['user_callbook_password']); | 
					
						
							|  |  |  | 								$this->session->set_userdata('hamqth_session_key', $hamqth_session_key); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// Update Session data
 | 
					
						
							|  |  |  | 							$this->session->set_userdata('callbook_type', $_POST['user_callbook_type']); | 
					
						
							|  |  |  | 							$this->session->set_userdata('callbook_username', $_POST['user_callbook_username']); | 
					
						
							|  |  |  | 							$this->session->set_userdata('callbook_password', $encrypted_password); | 
					
						
							| 
									
										
										
										
											2024-10-03 21:46:11 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 						if (isset($_POST['user_dashboard_enable_dxpedition_card'])) { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_upcoming_dx_card', array('enabled' => 'true')); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_upcoming_dx_card', array('enabled' => 'false')); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						if (isset($_POST['user_dashboard_enable_qslcards_card'])) { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_qslcards_card', array('enabled' => 'true')); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_qslcards_card', array('enabled' => 'false')); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						if (isset($_POST['user_dashboard_enable_eqslcards_card'])) { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_eqslcards_card', array('enabled' => 'true')); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_eqslcards_card', array('enabled' => 'false')); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						if (isset($_POST['user_dashboard_enable_lotw_card'])) { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_lotw_card', array('enabled' => 'true')); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_lotw_card', array('enabled' => 'false')); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						if (isset($_POST['user_dashboard_enable_vuccgrids_card'])) { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_vuccgrids_card', array('enabled' => 'true')); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							$this->user_options_model->set_option('dashboard', 'dashboard_vuccgrids_card', array('enabled' => 'false')); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						// [MAP Custom] ADD to user options //
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 						$array_icon = array('station', 'qso', 'qsoconfirm'); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						foreach ($array_icon as $icon) { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 							$data_options['user_map_' . $icon . '_icon'] = xss_clean($this->input->post('user_map_' . $icon . '_icon', true)); | 
					
						
							|  |  |  | 							$data_options['user_map_' . $icon . '_color'] = xss_clean($this->input->post('user_map_' . $icon . '_color', true)); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 						$this->load->model('user_options_model'); | 
					
						
							|  |  |  | 						if (!empty($data_options['user_map_qso_icon'])) { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 							foreach ($array_icon as $icon) { | 
					
						
							|  |  |  | 								$json = json_encode(array('icon' => $data_options['user_map_' . $icon . '_icon'], 'color' => $data_options['user_map_' . $icon . '_color'])); | 
					
						
							|  |  |  | 								$this->user_options_model->set_option('map_custom', 'icon', array($icon => $json)); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 							$this->user_options_model->set_option('map_custom', 'gridsquare', array('show' => xss_clean($this->input->post('user_map_gridsquare_show', true)))); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 							$this->user_options_model->del_option('map_custom', 'icon'); | 
					
						
							|  |  |  | 							$this->user_options_model->del_option('map_custom', 'gridsquare'); | 
					
						
							| 
									
										
										
										
											2023-12-01 01:11:22 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 						$this->session->set_flashdata('success', lang('account_user') . ' ' . $this->input->post('user_name', true) . ' ' . lang('account_word_edited')); | 
					
						
							|  |  |  | 						redirect('user/edit/' . $this->uri->segment(3)); | 
					
						
							| 
									
										
										
										
											2011-08-20 04:14:16 +08:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 						$this->session->set_flashdata('success', lang('account_user') . ' ' . $this->input->post('user_name', true) . ' ' . lang('account_word_edited')); | 
					
						
							| 
									
										
										
										
											2011-08-20 04:14:16 +08:00
										 |  |  | 						redirect('user'); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 					return; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$data['page_title'] = "Edit User"; | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2019-10-06 04:57:44 +08:00
										 |  |  | 			$data['user_name'] = $this->input->post('user_name', true); | 
					
						
							|  |  |  | 			$data['user_email'] = $this->input->post('user_email', true); | 
					
						
							|  |  |  | 			$data['user_password'] = $this->input->post('user_password', true); | 
					
						
							|  |  |  | 			$data['user_type'] = $this->input->post('user_type', true); | 
					
						
							|  |  |  | 			$data['user_firstname'] = $this->input->post('user_firstname', true); | 
					
						
							|  |  |  | 			$data['user_lastname'] = $this->input->post('user_lastname', true); | 
					
						
							|  |  |  | 			$data['user_callsign'] = $this->input->post('user_callsign', true); | 
					
						
							|  |  |  | 			$data['user_locator'] = $this->input->post('user_locator', true); | 
					
						
							|  |  |  | 			$data['user_timezone'] = $this->input->post('user_timezone', true); | 
					
						
							| 
									
										
										
										
											2023-07-07 22:04:19 +08:00
										 |  |  | 			$data['user_stylesheet'] = $this->input->post('user_stylesheet'); | 
					
						
							| 
									
										
										
										
											2022-10-19 22:27:26 +08:00
										 |  |  | 			$data['user_qth_lookup'] = $this->input->post('user_qth_lookup'); | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 			$data['user_sota_lookup'] = $this->input->post('user_sota_lookup'); | 
					
						
							| 
									
										
										
										
											2022-10-19 20:52:43 +08:00
										 |  |  | 			$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup'); | 
					
						
							| 
									
										
										
										
											2023-05-02 03:14:30 +08:00
										 |  |  | 			$data['user_pota_lookup'] = $this->input->post('user_pota_lookup'); | 
					
						
							| 
									
										
										
										
											2021-03-21 04:19:07 +08:00
										 |  |  | 			$data['user_show_notes'] = $this->input->post('user_show_notes'); | 
					
						
							| 
									
										
										
										
											2021-05-05 23:52:42 +08:00
										 |  |  | 			$data['user_column1'] = $this->input->post('user_column1'); | 
					
						
							|  |  |  | 			$data['user_column2'] = $this->input->post('user_column2'); | 
					
						
							|  |  |  | 			$data['user_column3'] = $this->input->post('user_column3'); | 
					
						
							|  |  |  | 			$data['user_column4'] = $this->input->post('user_column4'); | 
					
						
							| 
									
										
										
										
											2021-05-07 14:03:25 +08:00
										 |  |  | 			$data['user_column4'] = $this->input->post('user_column4'); | 
					
						
							|  |  |  | 			$data['user_column5'] = $this->input->post('user_column5'); | 
					
						
							| 
									
										
										
										
											2022-07-03 17:39:05 +08:00
										 |  |  | 			$data['user_show_profile_image'] = $this->input->post('user_show_profile_image'); | 
					
						
							| 
									
										
										
										
											2022-11-25 07:22:31 +08:00
										 |  |  | 			$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type'); | 
					
						
							| 
									
										
										
										
											2023-01-28 00:24:48 +08:00
										 |  |  | 			$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload'); | 
					
						
							| 
									
										
										
										
											2023-07-06 16:17:20 +08:00
										 |  |  | 			$data['user_mastodon_url'] = $this->input->post('user_mastodon_url'); | 
					
						
							| 
									
										
										
										
											2023-10-17 04:39:33 +08:00
										 |  |  | 			$data['user_default_band'] = $this->input->post('user_default_band'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '') . ($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '') . ($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '') . ($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : ''); | 
					
						
							| 
									
										
										
										
											2023-11-01 21:24:13 +08:00
										 |  |  | 			$data['user_qso_end_times'] = $this->input->post('user_qso_end_times'); | 
					
						
							| 
									
										
										
										
											2023-11-05 01:31:46 +08:00
										 |  |  | 			$data['user_quicklog'] = $this->input->post('user_quicklog'); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:29:59 +08:00
										 |  |  | 			$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 			$data['language'] = $this->input->post('language'); | 
					
						
							| 
									
										
										
										
											2023-08-03 20:59:02 +08:00
										 |  |  | 			$data['user_winkey'] = $this->input->post('user_winkey'); | 
					
						
							| 
									
										
										
										
											2024-03-09 15:49:12 +08:00
										 |  |  | 			$data['user_hamsat_key'] = $this->input->post('user_hamsat_key'); | 
					
						
							|  |  |  | 			$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only'); | 
					
						
							| 
									
										
										
										
											2024-03-19 22:38:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$this->load->view('user/edit'); | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function profile() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if (!$this->user_model->authorize(2)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 		$query = $this->user_model->get_by_id($this->session->userdata('user_id')); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		$q = $query->row(); | 
					
						
							|  |  |  | 		$data['page_title'] = "Profile"; | 
					
						
							|  |  |  | 		$data['user_name'] = $q->user_name; | 
					
						
							|  |  |  | 		$data['user_type'] = $q->user_type; | 
					
						
							|  |  |  | 		$data['user_email'] = $q->user_email; | 
					
						
							|  |  |  | 		$data['user_firstname'] = $q->user_firstname; | 
					
						
							|  |  |  | 		$data['user_lastname'] = $q->user_lastname; | 
					
						
							|  |  |  | 		$data['user_callsign'] = $q->user_callsign; | 
					
						
							|  |  |  | 		$data['user_locator'] = $q->user_locator; | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 		$this->load->view('user/profile'); | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-08-20 03:33:37 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-10 22:15:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Deletes a user by their ID. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * This function first loads the 'user_model'. It then checks if the current user has the authorization level of 99. | 
					
						
							|  |  |  | 	 * If not, it sets a flash message and redirects the user to the dashboard. | 
					
						
							|  |  |  | 	 *  | 
					
						
							|  |  |  | 	 * If the user is authorized, it gets the user to be deleted by their ID from the URI segment 3. | 
					
						
							|  |  |  | 	 * It then calls the 'delete' function from the 'user_model' with the user ID as a parameter. | 
					
						
							|  |  |  | 	 *  | 
					
						
							|  |  |  | 	 * If the 'delete' function executes successfully, it sets the HTTP status code to 200. | 
					
						
							|  |  |  | 	 * If the 'delete' function fails, it sets the HTTP status code to 500. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param int $id The ID of the user to delete. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function delete_new($id) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2024-04-10 22:15:54 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if (!$this->user_model->authorize(99)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-04-10 22:15:54 +08:00
										 |  |  | 		$query = $this->user_model->get_by_id($this->uri->segment(3)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// call $this->user_model->delete and if no errors return true
 | 
					
						
							|  |  |  | 		if ($this->user_model->delete($id)) { | 
					
						
							|  |  |  | 			// request responds with a 200 status code and empty content
 | 
					
						
							|  |  |  | 			$this->output->set_status_header(200); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			// request responds with a 500 status code and empty content
 | 
					
						
							|  |  |  | 			$this->output->set_status_header(500); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function delete() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if (!$this->user_model->authorize(99)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 		$query = $this->user_model->get_by_id($this->uri->segment(3)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('id', 'user_id', 'required'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data = $query->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($this->form_validation->run() == FALSE) { | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$this->load->view('user/delete'); | 
					
						
							| 
									
										
										
										
											2019-01-09 23:18:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			if ($this->user_model->delete($data->user_id)) { | 
					
						
							| 
									
										
										
										
											2011-08-20 00:12:13 +08:00
										 |  |  | 				$this->session->set_flashdata('notice', 'User deleted'); | 
					
						
							|  |  |  | 				redirect('user'); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				$this->session->set_flashdata('notice', '<b>Database error:</b> Could not delete user!'); | 
					
						
							|  |  |  | 				redirect('user'); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function login() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2020-05-13 02:01:38 +08:00
										 |  |  | 		// Check our version and run any migrations
 | 
					
						
							|  |  |  | 		$this->load->library('Migration'); | 
					
						
							| 
									
										
										
										
											2024-05-02 04:57:25 +08:00
										 |  |  | 		$this->load->library('encryption'); | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-26 17:37:43 +08:00
										 |  |  | 		$this->migration->current(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2019-10-06 02:28:20 +08:00
										 |  |  | 		$query = $this->user_model->get($this->input->post('user_name', true)); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_name', 'Username', 'required'); | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('user_password', 'Password', 'required'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-25 05:42:36 +08:00
										 |  |  | 		$data['user'] = $query->row(); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 		// Read the cookie remeber_me and log the user in
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($this->input->cookie(config_item('cookie_prefix') . 'remember_me')) { | 
					
						
							| 
									
										
										
										
											2024-05-02 19:12:40 +08:00
										 |  |  | 			try { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				$encrypted_string = $this->input->cookie(config_item('cookie_prefix') . 'remember_me'); | 
					
						
							| 
									
										
										
										
											2024-05-02 19:12:40 +08:00
										 |  |  | 				$decrypted_string = $this->encryption->decrypt($encrypted_string); | 
					
						
							|  |  |  | 				$this->user_model->update_session($decrypted_string); | 
					
						
							|  |  |  | 				$this->user_model->set_last_login($decrypted_string); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				log_message('debug', '[User ID: ' . $decrypted_string . '] Remember Me Login Successful'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 19:12:40 +08:00
										 |  |  | 				redirect('dashboard'); | 
					
						
							|  |  |  | 			} catch (Exception $e) { | 
					
						
							|  |  |  | 				// Something went wrong with the cookie
 | 
					
						
							|  |  |  | 				log_message('error', 'Remember Me Login Failed'); | 
					
						
							|  |  |  | 				$this->session->set_flashdata('error', 'Remember Me Login Failed'); | 
					
						
							|  |  |  | 				redirect('user/login'); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 		if ($this->form_validation->run() == FALSE) { | 
					
						
							| 
									
										
										
										
											2013-03-25 05:31:45 +08:00
										 |  |  | 			$data['page_title'] = "Login"; | 
					
						
							| 
									
										
										
										
											2021-11-08 23:22:17 +08:00
										 |  |  | 			$this->load->view('interface_assets/mini_header', $data); | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 			$this->load->view('user/login'); | 
					
						
							| 
									
										
										
										
											2019-07-09 02:42:03 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->user_model->login() == 1) { | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 				$this->session->set_flashdata('notice', 'User logged in'); | 
					
						
							| 
									
										
										
										
											2013-03-25 05:42:36 +08:00
										 |  |  | 				$this->user_model->update_session($data['user']->user_id); | 
					
						
							| 
									
										
										
										
											2024-01-01 09:08:12 +08:00
										 |  |  | 				$this->user_model->set_last_login($data['user']->user_id); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				$cookie = array( | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					'name'   => 'language', | 
					
						
							|  |  |  | 					'value'  => $data['user']->language, | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					'expire' => time() + 1000, | 
					
						
							| 
									
										
										
										
											2023-08-02 14:37:56 +08:00
										 |  |  | 					'secure' => FALSE | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 				// Create a remember me cookie
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if ($this->input->post('remember_me') == '1') { | 
					
						
							| 
									
										
										
										
											2024-05-02 04:57:25 +08:00
										 |  |  | 					$encrypted_string = $this->encryption->encrypt($data['user']->user_id); | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$cookie = array( | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 						'name'   => 'remember_me', | 
					
						
							|  |  |  | 						'value'  => $encrypted_string, | 
					
						
							|  |  |  | 						'expire' => '1209600', | 
					
						
							|  |  |  | 						'secure' => FALSE | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					$this->input->set_cookie($cookie); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 				redirect('dashboard'); | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2013-03-25 05:31:45 +08:00
										 |  |  | 				$this->session->set_flashdata('error', 'Incorrect username or password!'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 				redirect('user/login'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function logout() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$user_name = $this->session->userdata('user_name'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 21:48:47 +08:00
										 |  |  | 		// Delete remember_me cookie
 | 
					
						
							|  |  |  | 		setcookie('remember_me', '', time() - 3600, '/'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		$this->user_model->clear_session(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		$this->session->set_flashdata('notice', 'User ' . $user_name . ' logged out.'); | 
					
						
							| 
									
										
										
										
											2011-08-18 08:31:15 +08:00
										 |  |  | 		redirect('dashboard'); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Function: forgot_password | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 	 * Allows users to input an email address and a password will be sent to that address. | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function forgot_password() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->helper(array('form', 'url')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('email', 'Email', 'required'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($this->form_validation->run() == FALSE) { | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 			$data['page_title'] = "Forgot Password"; | 
					
						
							|  |  |  | 			$this->load->view('interface_assets/mini_header', $data); | 
					
						
							|  |  |  | 			$this->load->view('user/forgot_password'); | 
					
						
							|  |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 			// Check email address exists
 | 
					
						
							|  |  |  | 			$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 			$check_email = $this->user_model->check_email_address($this->input->post('email', true)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($check_email == TRUE) { | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 				// Generate password reset code 50 characters long
 | 
					
						
							|  |  |  | 				$this->load->helper('string'); | 
					
						
							|  |  |  | 				$reset_code = random_string('alnum', 50); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$this->user_model->set_password_reset_code($this->input->post('email', true), $reset_code); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 				// Send email with reset code
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$this->data['reset_code'] = $reset_code; | 
					
						
							|  |  |  | 				$this->load->library('email'); | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if ($this->optionslib->get_option('emailProtocol') == "smtp") { | 
					
						
							|  |  |  | 					$config = array( | 
					
						
							| 
									
										
										
										
											2022-01-19 22:26:36 +08:00
										 |  |  | 						'protocol' => $this->optionslib->get_option('emailProtocol'), | 
					
						
							| 
									
										
										
										
											2023-11-21 17:22:14 +08:00
										 |  |  | 						'smtp_crypto' => $this->optionslib->get_option('smtpEncryption'), | 
					
						
							| 
									
										
										
										
											2022-01-19 22:26:36 +08:00
										 |  |  | 						'smtp_host' => $this->optionslib->get_option('smtpHost'), | 
					
						
							|  |  |  | 						'smtp_port' => $this->optionslib->get_option('smtpPort'), | 
					
						
							|  |  |  | 						'smtp_user' => $this->optionslib->get_option('smtpUsername'), | 
					
						
							|  |  |  | 						'smtp_pass' => $this->optionslib->get_option('smtpPassword'), | 
					
						
							| 
									
										
										
										
											2023-11-22 21:51:45 +08:00
										 |  |  | 						'crlf' => "\r\n", | 
					
						
							|  |  |  | 						'newline' => "\r\n" | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					); | 
					
						
							| 
									
										
										
										
											2022-01-19 22:26:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$this->email->initialize($config); | 
					
						
							| 
									
										
										
										
											2022-01-19 22:26:36 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 				$message = $this->load->view('email/forgot_password', $this->data,  TRUE); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 15:03:00 +08:00
										 |  |  | 				$this->email->from($this->optionslib->get_option('emailAddress'), $this->optionslib->get_option('emailSenderName')); | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 				$this->email->to($this->input->post('email', true)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$this->email->subject('Cloudlog Account Password Reset'); | 
					
						
							|  |  |  | 				$this->email->message($message); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if (!$this->email->send()) { | 
					
						
							| 
									
										
										
										
											2022-01-19 22:26:36 +08:00
										 |  |  | 					// Redirect to login page with message
 | 
					
						
							|  |  |  | 					$this->session->set_flashdata('warning', 'Email settings are incorrect.'); | 
					
						
							|  |  |  | 					redirect('user/login'); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					// Redirect to login page with message
 | 
					
						
							|  |  |  | 					$this->session->set_flashdata('notice', 'Password Reset Processed.'); | 
					
						
							|  |  |  | 					redirect('user/login'); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2022-01-18 23:29:22 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				// No account found just return to login page
 | 
					
						
							|  |  |  | 				$this->session->set_flashdata('notice', 'Password Reset Processed.'); | 
					
						
							|  |  |  | 				redirect('user/login'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-01 09:44:03 +08:00
										 |  |  | 	// Send an E-Mail to the user. Function is similar to forgot_password()
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function admin_send_passwort_reset() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if (!$this->user_model->authorize(99)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 		$query = $this->user_model->get_by_id($this->uri->segment(3)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('form_validation'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->form_validation->set_rules('id', 'user_id', 'required'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data = $query->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($this->form_validation->run() != FALSE) { | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 			$this->session->set_flashdata('notice', 'Something went wrong! User has no user_id.'); | 
					
						
							|  |  |  | 			redirect('user'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 			// Check email address exists
 | 
					
						
							|  |  |  | 			$this->load->model('user_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$check_email = $this->user_model->check_email_address($data->user_email); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($check_email == TRUE) { | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 				// Generate password reset code 50 characters long
 | 
					
						
							|  |  |  | 				$this->load->helper('string'); | 
					
						
							|  |  |  | 				$reset_code = random_string('alnum', 50); | 
					
						
							|  |  |  | 				$this->user_model->set_password_reset_code(($data->user_email), $reset_code); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// Send email with reset code and first Name of the User
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$this->data['reset_code'] = $reset_code; | 
					
						
							| 
									
										
										
										
											2024-02-08 13:13:03 +08:00
										 |  |  | 				$this->data['user_firstname'] = $data->user_firstname; // We can call the user by their first name in the E-Mail
 | 
					
						
							| 
									
										
										
										
											2024-01-01 19:49:24 +08:00
										 |  |  | 				$this->data['user_callsign'] = $data->user_callsign; | 
					
						
							|  |  |  | 				$this->data['user_name'] = $data->user_name; | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 				$this->load->library('email'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if ($this->optionslib->get_option('emailProtocol') == "smtp") { | 
					
						
							|  |  |  | 					$config = array( | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 						'protocol' => $this->optionslib->get_option('emailProtocol'), | 
					
						
							|  |  |  | 						'smtp_crypto' => $this->optionslib->get_option('smtpEncryption'), | 
					
						
							|  |  |  | 						'smtp_host' => $this->optionslib->get_option('smtpHost'), | 
					
						
							|  |  |  | 						'smtp_port' => $this->optionslib->get_option('smtpPort'), | 
					
						
							|  |  |  | 						'smtp_user' => $this->optionslib->get_option('smtpUsername'), | 
					
						
							|  |  |  | 						'smtp_pass' => $this->optionslib->get_option('smtpPassword'), | 
					
						
							|  |  |  | 						'crlf' => "\r\n", | 
					
						
							|  |  |  | 						'newline' => "\r\n" | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					); | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 					$this->email->initialize($config); | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$message = $this->load->view('email/admin_reset_password', $this->data,  TRUE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$this->email->from($this->optionslib->get_option('emailAddress'), $this->optionslib->get_option('emailSenderName')); | 
					
						
							|  |  |  | 				$this->email->to($data->user_email); | 
					
						
							|  |  |  | 				$this->email->subject('Cloudlog Account Password Reset'); | 
					
						
							|  |  |  | 				$this->email->message($message); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 				if (!$this->email->send()) { | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 					// Redirect to user page with message
 | 
					
						
							| 
									
										
										
										
											2024-01-01 08:30:40 +08:00
										 |  |  | 					$this->session->set_flashdata('danger', lang('admin_email_settings_incorrect')); | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 					redirect('user'); | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					// Redirect to user page with message
 | 
					
						
							| 
									
										
										
										
											2024-01-01 08:30:40 +08:00
										 |  |  | 					$this->session->set_flashdata('success', lang('admin_password_reset_processed')); | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 					redirect('user'); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				// No account found just return to user page
 | 
					
						
							| 
									
										
										
										
											2024-01-01 08:30:40 +08:00
										 |  |  | 				$this->session->set_flashdata('danger', 'Nothing done. No user found.'); | 
					
						
							| 
									
										
										
										
											2024-01-01 08:01:10 +08:00
										 |  |  | 				redirect('user'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	function reset_password($reset_code = NULL) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		$data['reset_code'] = $reset_code; | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 		if ($reset_code != NULL) { | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 			$this->load->helper(array('form', 'url')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$this->load->library('form_validation'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 			$this->form_validation->set_rules('password', 'Password', 'required'); | 
					
						
							|  |  |  | 			$this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required|matches[password]'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			if ($this->form_validation->run() == FALSE) { | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 				$data['page_title'] = "Reset Password"; | 
					
						
							|  |  |  | 				$this->load->view('interface_assets/mini_header', $data); | 
					
						
							|  |  |  | 				$this->load->view('user/reset_password'); | 
					
						
							|  |  |  | 				$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 				// Lets reset the password!
 | 
					
						
							|  |  |  | 				$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2023-08-02 14:34:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 00:14:22 +08:00
										 |  |  | 				$this->user_model->reset_password($this->input->post('password', true), $reset_code); | 
					
						
							|  |  |  | 				$this->session->set_flashdata('notice', 'Password Reset.'); | 
					
						
							|  |  |  | 				redirect('user/login'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			redirect('user/login'); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-10-27 21:18:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-02 20:48:45 +08:00
										 |  |  | 	function check_locator($grid) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		$grid = $this->input->post('user_locator'); | 
					
						
							|  |  |  | 		// Allow empty locator
 | 
					
						
							|  |  |  | 		if (preg_match('/^$/', $grid)) return true; | 
					
						
							|  |  |  | 		// Allow 6-digit locator
 | 
					
						
							|  |  |  | 		if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}$/', $grid)) return true; | 
					
						
							|  |  |  | 		// Allow 4-digit locator
 | 
					
						
							|  |  |  | 		else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true; | 
					
						
							|  |  |  | 		// Allow 4-digit grid line
 | 
					
						
							|  |  |  | 		else if (preg_match('/^[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true; | 
					
						
							|  |  |  | 		// Allow 4-digit grid corner
 | 
					
						
							|  |  |  | 		else if (preg_match('/^[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true; | 
					
						
							|  |  |  | 		// Allow 2-digit locator
 | 
					
						
							|  |  |  | 		else if (preg_match('/^[A-Ra-r]{2}$/', $grid)) return true; | 
					
						
							|  |  |  | 		// Allow 8-digit locator
 | 
					
						
							|  |  |  | 		else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}[0-9]{2}$/', $grid)) return true; | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			$this->form_validation->set_message('check_locator', 'Please check value for grid locator (' . strtoupper($grid) . ').'); | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-04-04 19:17:33 +08:00
										 |  |  | } |