2011-08-18 01:31:15 +01:00
< ? php if ( ! defined ( 'BASEPATH' )) exit ( 'No direct script access allowed' );
class User extends CI_Controller {
2026-03-18 15:26:31 +01:00
private $pwd_placeholder = '**********' ;
2011-08-18 01:31:15 +01:00
public function index ()
{
2025-01-02 10:22:23 +01:00
$this -> load -> library ( 'form_validation' );
2024-08-16 10:43:40 +02:00
if ( ! $this -> load -> is_loaded ( 'encryption' )) {
$this -> load -> library ( 'encryption' );
}
2024-08-16 10:08:44 +02:00
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2011-08-18 01:31:15 +01:00
$data [ 'results' ] = $this -> user_model -> users ();
2025-01-02 10:22:23 +01:00
$data [ 'clubs' ] = $this -> user_model -> users ( 'is_club' );
$data [ 'clubmode' ] = $this -> config -> item ( 'special_callsign' );
2024-08-16 10:43:40 +02:00
$data [ 'session_uid' ] = $this -> session -> userdata ( 'user_id' );
2011-08-18 01:31:15 +01:00
2024-08-19 21:07:26 +02:00
// Check if impersonating is disabled in the config
if ( $this -> config -> item ( 'disable_impersonate' )) {
$data [ 'disable_impersonate' ] = true ;
} else {
$data [ 'disable_impersonate' ] = false ;
}
2025-01-19 09:44:54 +01:00
if ( $this -> config -> item ( 'max_login_attempts' )) {
$data [ 'maxattempts' ] = $this -> config -> item ( 'max_login_attempts' );
} else {
$data [ 'maxattempts' ] = 3 ;
}
2024-08-17 12:17:16 +02:00
// Get Date format
if ( $this -> session -> userdata ( 'user_date_format' )) {
// If Logged in and session exists
$data [ 'custom_date_format' ] = $this -> session -> userdata ( 'user_date_format' );
} else {
// Get Default date format from /config/wavelog.php
$data [ 'custom_date_format' ] = $this -> config -> item ( 'qso_date_format' );
}
$data [ 'has_flossie' ] = ( $this -> config -> item ( 'encryption_key' ) == 'flossie1234555541' ) ? true : false ;
2025-01-02 10:22:23 +01:00
$footerData = [];
$footerData [ 'scripts' ] = [
2026-02-13 16:58:57 +01:00
'assets/js/sections/user.js' ,
2025-01-02 10:22:23 +01:00
];
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " User Accounts " );
2011-11-04 17:32:03 +00:00
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2024-08-17 09:40:21 +02:00
$this -> load -> view ( 'user/index' );
2025-01-02 10:22:23 +01:00
$this -> load -> view ( 'interface_assets/footer' , $footerData );
}
public function actions_modal () {
$this -> load -> library ( 'encryption' );
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
$data [ 'user_id' ] = $this -> input -> post ( 'user_id' , true ) ? ? '' ;
$modal = $this -> input -> post ( 'modal' , true ) ? ? '' ;
if ( $this -> session -> userdata ( 'user_date_format' )) {
$custom_date_format = $this -> session -> userdata ( 'user_date_format' );
} else {
$custom_date_format = $this -> config -> item ( 'qso_date_format' );
}
2025-01-19 09:44:54 +01:00
if ( $this -> config -> item ( 'max_login_attempts' )) {
$maxattempts = $this -> config -> item ( 'max_login_attempts' );
} else {
$maxattempts = 3 ;
}
2025-01-02 10:22:23 +01:00
if ( $this -> user_model -> exists_by_id ( $data [ 'user_id' ]) && $modal != '' ) {
$user = $this -> user_model -> get_by_id ( $data [ 'user_id' ]) -> row ();
$gettext = new Gettext ;
2026-06-20 10:29:55 -07:00
2026-03-18 17:36:30 -05:00
$data [ 'auth_header_enable' ] = $this -> config -> item ( 'auth_header_enable' ) ? ? false ;
if ( $data [ 'auth_header_enable' ]) {
$this -> config -> load ( 'sso' , true , true );
}
2025-01-02 10:22:23 +01:00
$data [ 'user_name' ] = $user -> user_name ;
$data [ 'user_callsign' ] = $user -> user_callsign ;
$data [ 'user_email' ] = $user -> user_email ;
$data [ 'user_firstname' ] = $user -> user_firstname ;
$data [ 'user_lastname' ] = $user -> user_lastname ;
$data [ 'user_language' ] = $gettext -> find_by ( 'folder' , $user -> user_language )[ 'name_en' ];
$data [ 'is_clubstation' ] = $user -> clubstation == 1 ? true : false ;
2025-01-19 09:44:54 +01:00
$data [ 'is_locked' ] = $user -> login_attempts > $maxattempts ? true : false ;
2025-01-02 10:22:23 +01:00
$data [ 'last_seen' ] = $user -> last_seen ;
$data [ 'custom_date_format' ] = $custom_date_format ;
$data [ 'has_flossie' ] = ( $this -> config -> item ( 'encryption_key' ) == 'flossie1234555541' ) ? true : false ;
2026-03-18 17:36:30 -05:00
$data [ 'auth_header_allow_direct_login' ] = $this -> config -> item ( 'auth_header_allow_direct_login' , 'sso' ) ? ? true ;
2025-01-02 10:22:23 +01:00
$this -> load -> view ( 'user/modals/' . $modal . '_modal' , $data );
} else {
$this -> session -> set_flashdata ( 'error' , __ ( " Invalid User ID or missing modal! " ));
redirect ( 'user' );
}
}
2025-01-19 09:44:54 +01:00
public function unlock ( $uid ) {
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
if ( $this -> user_model -> exists_by_id ( $uid )) {
if ( $this -> user_model -> unlock ( $uid )) {
$this -> session -> set_flashdata ( 'success' , __ ( " User unlocked! " ));
redirect ( 'user' );
} else {
$this -> session -> set_flashdata ( 'error' , __ ( " Failed to unlock user! " ));
redirect ( 'user' );
}
} else {
$this -> session -> set_flashdata ( 'error' , __ ( " User not found! " ));
redirect ( 'dashboard' );
}
}
2025-01-02 10:22:23 +01:00
public function convert () {
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
$user_id = $this -> input -> post ( 'user_id' , true ) ? ? '' ;
$convert_to = $this -> input -> post ( 'convert_to' , true ) ? ? '' ;
2025-01-07 06:49:32 +01:00
if ( $convert_to !== '0' && $convert_to !== '1' ) {
2025-01-02 10:22:23 +01:00
$this -> session -> set_flashdata ( 'error' , __ ( " Invalid Parameter! " ));
redirect ( 'dashboard' );
}
if ( $this -> user_model -> exists_by_id ( $user_id )) {
if ( $this -> user_model -> convert ( $user_id , $convert_to )) {
echo json_encode ( true );
} else {
echo json_encode ( false );
}
} else {
log_message ( 'error' , 'User Conversion - User ID not found: ' . $user_id );
echo json_encode ( false );
}
2011-08-18 01:31:15 +01:00
}
function add () {
2024-08-16 10:08:44 +02:00
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2021-02-26 10:37:43 +01:00
2024-06-06 10:46:12 +02:00
$data [ 'existing_languages' ] = $this -> config -> item ( 'languages' );
2023-08-02 07:06:34 +00:00
2023-07-07 16:04:19 +02:00
$this -> load -> model ( 'bands' );
2011-08-18 01:31:15 +01:00
$this -> load -> library ( 'form_validation' );
2024-07-22 16:16:03 +02:00
$this -> load -> library ( 'Genfunctions' );
2011-08-18 01:31:15 +01:00
2011-08-18 02:27:53 +01:00
$this -> form_validation -> set_rules ( 'user_name' , 'Username' , 'required' );
2025-07-25 10:52:27 +00:00
$this -> form_validation -> set_rules ( 'user_name' , 'Username' , 'required|callback_check_username' );
2011-08-18 02:27:53 +01:00
$this -> form_validation -> set_rules ( 'user_email' , 'E-mail' , 'required' );
2025-10-07 06:38:09 +00:00
$this -> form_validation -> set_rules ( 'user_clublog_name' , 'Clublog Username' , 'valid_email' );
2011-08-18 02:27:53 +01:00
$this -> form_validation -> set_rules ( 'user_password' , 'Password' , 'required' );
$this -> form_validation -> set_rules ( 'user_type' , 'Type' , 'required' );
2011-09-26 20:45:07 +01:00
$this -> form_validation -> set_rules ( 'user_callsign' , 'Callsign' , 'required' );
$this -> form_validation -> set_rules ( 'user_locator' , 'Locator' , 'required' );
2022-10-27 15:18:50 +02:00
$this -> form_validation -> set_rules ( 'user_locator' , 'Locator' , 'callback_check_locator' );
2025-07-25 08:34:03 +00:00
$this -> form_validation -> set_rules ( 'user_email' , 'EMail' , 'required|callback_check_email' );
2025-07-25 10:34:27 +00:00
$this -> form_validation -> set_rules ( 'user_email' , 'EMail' , 'required|valid_email' );
2011-09-27 23:47:25 +01:00
$this -> form_validation -> set_rules ( 'user_timezone' , 'Timezone' , 'required' );
2023-12-17 19:16:23 +01:00
$data [ 'user_add' ] = true ;
$data [ 'user_form_action' ] = site_url ( 'user/add' );
2023-07-07 16:04:19 +02:00
$data [ 'bands' ] = $this -> bands -> get_user_bands ();
2025-01-02 10:22:23 +01:00
$data [ 'clubstation' ] = ( $this -> input -> get ( 'club' ) ? ? '' ) == '1' ? true : false ;
2026-03-18 18:19:34 -05:00
$data [ 'external_account' ] = NULL ;
$data [ 'auth_header_enable' ] = $this -> config -> item ( 'auth_header_enable' ) ? ? false ;
2026-03-18 18:25:58 -05:00
$data [ 'auth_header_allow_direct_login' ] = true ;
$data [ 'auth_header_hide_password_field' ] = false ;
$data [ 'auth_header_locked_data_badge' ] = " Not Visible In Add UI " ;
$data [ 'auth_header_locked_data_tip' ] = " You should not see this message " ;
$data [ 'sso_claim_config' ] = [];
2026-03-18 18:19:34 -05:00
2021-08-09 13:13:41 +02:00
// Get themes list
$data [ 'themes' ] = $this -> user_model -> getThemes ();
2025-01-02 10:22:23 +01:00
$footerData = [];
$footerData [ 'scripts' ] = [
2026-02-13 16:58:57 +01:00
'assets/js/sections/user.js' ,
2025-01-02 10:22:23 +01:00
];
2011-09-27 23:47:25 +01:00
// Get timezones
$data [ 'timezones' ] = $this -> user_model -> timezones ();
2024-06-06 10:46:12 +02:00
$data [ 'user_language' ] = 'english' ;
2011-08-18 01:31:15 +01:00
2025-01-29 20:43:47 +01:00
// Values for the "dashboard last QSO count" selectbox
2025-01-30 07:44:48 +01:00
$data [ 'dashboard_last_qso_count_limit' ] = DASHBOARD_QSOS_COUNT_LIMIT ;
$data [ 'user_dashboard_last_qso_count' ] = DASHBOARD_DEFAULT_QSOS_COUNT ;
2025-01-29 20:43:47 +01:00
2025-01-30 21:09:20 +01:00
// Values for the "QSO page last QSO count" selectbox
$data [ 'qso_page_last_qso_count_limit' ] = QSO_PAGE_QSOS_COUNT_LIMIT ;
$data [ 'user_qso_page_last_qso_count' ] = QSO_PAGE_DEFAULT_QSOS_COUNT ;
2023-08-02 07:06:34 +00:00
if ( $this -> form_validation -> run () == FALSE ) {
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Add User " );
2024-05-13 08:02:10 +00:00
$data [ 'measurement_base' ] = $this -> config -> item ( 'measurement_base' );
2026-03-16 11:04:00 +00:00
$data [ 'csrf_token' ] = $this -> paths -> csrf_generate ( $this -> router -> class . '_' . $this -> router -> method );
2011-11-04 17:32:03 +00:00
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2023-08-02 07:06:34 +00:00
if ( $this -> input -> post ( 'user_name' )) {
2011-08-18 02:27:53 +01: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' );
2025-01-02 10:22:23 +01:00
$data [ 'user_type' ] = $data [ 'clubstation' ] == true ? '3' : $this -> input -> post ( 'user_type' );
$data [ 'user_firstname' ] = $this -> input -> post ( 'user_firstname' ) ? ? '' ;
$data [ 'user_lastname' ] = $this -> input -> post ( 'user_lastname' ) ? ? '' ;
2011-09-26 20:45:07 +01:00
$data [ 'user_callsign' ] = $this -> input -> post ( 'user_callsign' );
$data [ 'user_locator' ] = $this -> input -> post ( 'user_locator' );
2011-09-27 23:47:25 +01:00
$data [ 'user_timezone' ] = $this -> input -> post ( 'user_timezone' );
2025-02-18 08:26:02 +00:00
$data [ 'user_measurement_base' ] = $this -> input -> post ( 'user_measurement_base' ) ? ? 'K' ;
2025-02-17 12:22:57 +00:00
$data [ 'user_dashboard_map' ] = $this -> input -> post ( 'user_dashboard_map' ) ? ? 'Y' ;
2025-04-28 11:46:28 +02:00
$data [ 'user_dashboard_banner' ] = $this -> input -> post ( 'user_dashboard_banner' ) ? ? 'Y' ;
2025-09-23 00:33:52 +02:00
$data [ 'user_dashboard_solar' ] = $this -> input -> post ( 'user_dashboard_solar' ) ? ? 'Y' ;
2025-10-10 03:02:32 +02:00
$data [ 'user_dxwaterfall_enable' ] = $this -> input -> post ( 'user_dxwaterfall_enable' ) ? ? 'N' ;
2023-07-07 16:04:19 +02:00
$data [ 'user_stylesheet' ] = $this -> input -> post ( 'user_stylesheet' );
2022-10-19 16:27:26 +02:00
$data [ 'user_qth_lookup' ] = $this -> input -> post ( 'user_qth_lookup' );
2021-02-26 10:37:43 +01:00
$data [ 'user_sota_lookup' ] = $this -> input -> post ( 'user_sota_lookup' );
2022-10-19 14:52:43 +02:00
$data [ 'user_wwff_lookup' ] = $this -> input -> post ( 'user_wwff_lookup' );
2023-05-01 21:14:30 +02:00
$data [ 'user_pota_lookup' ] = $this -> input -> post ( 'user_pota_lookup' );
2021-03-20 21:19:07 +01:00
$data [ 'user_show_notes' ] = $this -> input -> post ( 'user_show_notes' );
2021-05-05 17:52:42 +02: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 08:03:25 +02:00
$data [ 'user_column5' ] = $this -> input -> post ( 'user_column5' );
2022-07-03 11:39:05 +02:00
$data [ 'user_show_profile_image' ] = $this -> input -> post ( 'user_show_profile_image' );
2022-11-25 00:22:31 +01:00
$data [ 'user_previous_qsl_type' ] = $this -> input -> post ( 'user_previous_qsl_type' );
2023-01-27 17:24:48 +01:00
$data [ 'user_amsat_status_upload' ] = $this -> input -> post ( 'user_amsat_status_upload' );
2023-07-06 08:17:20 +00:00
$data [ 'user_mastodon_url' ] = $this -> input -> post ( 'user_mastodon_url' );
2023-10-16 22:39:33 +02:00
$data [ 'user_default_band' ] = $this -> input -> post ( 'user_default_band' );
2025-08-21 06:29:52 +00: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' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_clublog' ) !== null ? 'C' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_dcl' ) !== null ? 'D' : '' );
2023-11-01 14:24:13 +01:00
$data [ 'user_qso_end_times' ] = $this -> input -> post ( 'user_qso_end_times' );
2025-10-30 15:37:20 +01:00
$data [ 'user_qso_db_search_priority' ] = $this -> input -> post ( 'user_qso_db_search_priority' ) ? ? 'Y' ;
2023-11-04 18:31:46 +01:00
$data [ 'user_quicklog' ] = $this -> input -> post ( 'user_quicklog' );
2023-11-05 12:29:59 +01:00
$data [ 'user_quicklog_enter' ] = $this -> input -> post ( 'user_quicklog_enter' );
2024-03-07 16:11:54 +01: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-22 07:17:55 +01:00
$data [ 'user_iota_to_qso_tab' ] = $this -> input -> post ( 'user_iota_to_qso_tab' );
2024-03-22 07:57:31 +01:00
$data [ 'user_sota_to_qso_tab' ] = $this -> input -> post ( 'user_sota_to_qso_tab' );
2024-03-22 08:06:54 +01:00
$data [ 'user_wwff_to_qso_tab' ] = $this -> input -> post ( 'user_wwff_to_qso_tab' );
2024-03-22 08:15:45 +01:00
$data [ 'user_pota_to_qso_tab' ] = $this -> input -> post ( 'user_pota_to_qso_tab' );
2024-03-22 08:26:26 +01:00
$data [ 'user_sig_to_qso_tab' ] = $this -> input -> post ( 'user_sig_to_qso_tab' );
2024-03-22 08:35:02 +01:00
$data [ 'user_dok_to_qso_tab' ] = $this -> input -> post ( 'user_dok_to_qso_tab' );
2025-12-11 05:44:23 +00:00
$data [ 'user_station_to_qso_tab' ] = $this -> input -> post ( 'user_station_to_qso_tab' );
2026-02-22 09:02:23 +00:00
$data [ 'user_qso_show_map' ] = $this -> input -> post ( 'user_qso_show_map' ) ? ? 1 ;
2024-06-06 10:46:12 +02:00
$data [ 'user_language' ] = $this -> input -> post ( 'user_language' );
2025-07-15 07:03:30 +02:00
$data [ 'global_oqrs_text' ] = $this -> input -> post ( 'global_oqrs_text' ) ? ? '' ;
$data [ 'oqrs_grouped_search' ] = $this -> input -> post ( 'oqrs_grouped_search' ) ? ? 'off' ;
$data [ 'oqrs_grouped_search_show_station_name' ] = $this -> input -> post ( 'oqrs_grouped_search_show_station_name' ) ? ? 'off' ;
2025-07-30 09:56:05 +02:00
$data [ 'oqrs_auto_matching' ] = $this -> input -> post ( 'oqrs_auto_matching' ) ? ? 'on' ;
2025-08-04 11:47:31 +02:00
$data [ 'oqrs_direct_auto_matching' ] = $this -> input -> post ( 'oqrs_direct_auto_matching' ) ? ? 'on' ;
2026-04-16 15:56:57 +00:00
$data [ 'oqrs_delivery_method' ] = $this -> input -> post ( 'oqrs_delivery_method' ) ? ? 'both' ;
2023-12-17 19:16:23 +01:00
$this -> load -> view ( 'user/edit' , $data );
2011-08-18 02:27:53 +01:00
} else {
2023-12-17 19:16:23 +01:00
$this -> load -> view ( 'user/edit' , $data );
2011-08-18 02:27:53 +01:00
}
2025-01-02 10:22:23 +01:00
$this -> load -> view ( 'interface_assets/footer' , $footerData );
2023-08-02 07:06:34 +00:00
} else {
2026-03-16 11:04:00 +00:00
if ( ! $this -> paths -> csrf_verify ( $this -> router -> class . '_' . $this -> router -> method )) {
$this -> session -> set_flashdata ( 'error' , __ ( " Invalid security token " ));
redirect ( 'user/add' );
return ;
}
2021-05-05 17:52:42 +02:00
switch ( $this -> user_model -> add ( $this -> input -> post ( 'user_name' ),
$this -> input -> post ( 'user_password' ),
$this -> input -> post ( 'user_email' ),
$this -> input -> post ( 'user_type' ),
2025-01-02 10:22:23 +01:00
$this -> input -> post ( 'user_firstname' ) ? ? '' ,
$this -> input -> post ( 'user_lastname' ) ? ? '' ,
2021-05-05 17:52:42 +02:00
$this -> input -> post ( 'user_callsign' ),
$this -> input -> post ( 'user_locator' ),
$this -> input -> post ( 'user_timezone' ),
$this -> input -> post ( 'user_measurement_base' ),
2025-02-17 12:22:57 +00:00
$this -> input -> post ( 'user_dashboard_map' ) ? ? 'Y' ,
2021-05-05 17:52:42 +02:00
$this -> input -> post ( 'user_date_format' ),
$this -> input -> post ( 'user_stylesheet' ),
2022-10-19 16:27:26 +02:00
$this -> input -> post ( 'user_qth_lookup' ),
2021-05-05 17:52:42 +02:00
$this -> input -> post ( 'user_sota_lookup' ),
2022-10-19 14:52:43 +02:00
$this -> input -> post ( 'user_wwff_lookup' ),
2023-05-01 21:14:30 +02:00
$this -> input -> post ( 'user_pota_lookup' ),
2021-05-05 17:52:42 +02: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 08:03:25 +02:00
$this -> input -> post ( 'user_column4' ),
2022-04-04 13:17:33 +02:00
$this -> input -> post ( 'user_column5' ),
2022-11-25 00:22:31 +01:00
$this -> input -> post ( 'user_show_profile_image' ),
2023-01-27 17:24:48 +01:00
$this -> input -> post ( 'user_previous_qsl_type' ),
2023-07-06 08:17:20 +00:00
$this -> input -> post ( 'user_amsat_status_upload' ),
2023-07-07 16:04:19 +02:00
$this -> input -> post ( 'user_mastodon_url' ),
2023-10-16 22:39:33 +02:00
$this -> input -> post ( 'user_default_band' ),
2025-08-21 06:29:52 +00: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' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_clublog' ) !== null ? 'C' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_dcl' ) !== null ? 'D' : '' ),
2023-11-01 14:24:13 +01:00
$this -> input -> post ( 'user_qso_end_times' ),
2025-10-30 15:37:20 +01:00
$this -> input -> post ( 'user_qso_db_search_priority' ) ? ? 'Y' ,
2023-11-04 18:31:46 +01:00
$this -> input -> post ( 'user_quicklog' ),
2023-11-05 12:29:59 +01:00
$this -> input -> post ( 'user_quicklog_enter' ),
2024-06-06 10:46:12 +02:00
$this -> input -> post ( 'user_language' ),
2024-03-07 16:11:54 +01:00
$this -> input -> post ( 'user_hamsat_key' ),
2024-03-22 07:17:55 +01:00
$this -> input -> post ( 'user_hamsat_workable_only' ),
2024-03-22 07:57:31 +01:00
$this -> input -> post ( 'user_iota_to_qso_tab' ),
2024-03-22 08:06:54 +01:00
$this -> input -> post ( 'user_sota_to_qso_tab' ),
2024-03-22 08:15:45 +01:00
$this -> input -> post ( 'user_wwff_to_qso_tab' ),
2024-03-22 08:26:26 +01:00
$this -> input -> post ( 'user_pota_to_qso_tab' ),
2024-03-22 08:35:02 +01:00
$this -> input -> post ( 'user_sig_to_qso_tab' ),
2024-05-09 14:08:25 +02:00
$this -> input -> post ( 'user_dok_to_qso_tab' ),
2025-12-11 05:44:23 +00:00
$this -> input -> post ( 'user_station_to_qso_tab' ),
2024-05-09 14:08:25 +02:00
$this -> input -> post ( 'user_lotw_name' ),
$this -> input -> post ( 'user_lotw_password' ),
$this -> input -> post ( 'user_eqsl_name' ),
$this -> input -> post ( 'user_eqsl_password' ),
$this -> input -> post ( 'user_clublog_name' ),
$this -> input -> post ( 'user_clublog_password' ),
2025-01-02 10:22:23 +01:00
$this -> input -> post ( 'user_winkey' ),
2025-02-19 20:36:21 +01:00
$this -> input -> post ( 'on_air_widget_enabled' ),
$this -> input -> post ( 'on_air_widget_display_last_seen' ),
$this -> input -> post ( 'on_air_widget_show_only_most_recent_radio' ),
2026-08-08 08:29:07 +02:00
$this -> input -> post ( 'on_air_widget_display_radio_name' ),
2025-02-27 21:52:19 +01:00
$this -> input -> post ( 'qso_widget_display_qso_time' ),
2025-04-28 11:46:28 +02:00
$this -> input -> post ( 'user_dashboard_banner' ) ? ? 'Y' ,
2025-09-23 00:33:52 +02:00
$this -> input -> post ( 'user_dashboard_solar' ) ? ? 'Y' ,
2025-07-18 15:33:35 +02:00
$this -> input -> post ( 'global_oqrs_text' ) ? ? '' ,
2025-07-15 07:03:30 +02:00
$this -> input -> post ( 'oqrs_grouped_search' ) ? ? 'off' ,
2025-07-30 09:56:05 +02:00
$this -> input -> post ( 'oqrs_grouped_search_show_station_name' ) ? ? 'off' ,
2025-08-04 11:47:31 +02:00
$this -> input -> post ( 'oqrs_auto_matching' ) ? ? 'on' ,
2025-10-27 14:01:59 +01:00
$this -> input -> post ( 'oqrs_direct_auto_matching' ) ? ? 'on' ,
2026-02-22 09:17:10 +00:00
$this -> input -> post ( 'user_dxwaterfall_enable' ) ? ? 'N' ,
2026-02-22 09:02:23 +00:00
$this -> input -> post ( 'user_qso_show_map' ) ? ? 1 ,
2025-10-27 14:01:59 +01:00
$this -> input -> post ( 'clubstation' ) == '1' ? true : false )
2025-07-30 09:56:05 +02:00
) {
2011-08-19 17:12:13 +01:00
// Check for errors
case EUSERNAMEEXISTS :
2025-01-02 10:22:23 +01:00
$data [ 'username_error' ] = sprintf ( __ ( " Username %s already in use! " ), '<b>' . $this -> input -> post ( 'user_name' ) . '</b>' );
2011-08-19 17:12:13 +01:00
break ;
case EEMAILEXISTS :
2025-01-02 10:22:23 +01:00
$data [ 'email_error' ] = sprintf ( __ ( " E-mail %s already in use! " ), '<b>' . $this -> input -> post ( 'user_email' ) . '</b>' );
2011-08-19 17:12:13 +01:00
break ;
case EPASSWORDINVALID :
2025-01-02 10:22:23 +01:00
$data [ 'password_error' ] = __ ( " Invalid Password! " );
2011-08-19 17:12:13 +01:00
break ;
// All okay, return to user screen
case OK :
2025-01-02 10:22:23 +01:00
$this -> session -> set_flashdata ( 'notice' , sprintf ( __ ( " User %s added! " ), '<b>' . $this -> input -> post ( 'user_name' ) . '</b>' ));
2011-08-19 17:12:13 +01:00
redirect ( 'user' );
return ;
2011-08-18 02:27:53 +01:00
}
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Users " );
2026-03-16 11:04:00 +00:00
$data [ 'csrf_token' ] = $this -> paths -> csrf_generate ( $this -> router -> class . '_' . $this -> router -> method );
2011-11-04 17:32:03 +00:00
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2011-08-19 17:12:13 +01: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' );
2025-01-02 10:22:23 +01:00
$data [ 'user_firstname' ] = $this -> input -> post ( 'user_firstname' ) ? ? '' ;
$data [ 'user_lastname' ] = $this -> input -> post ( 'user_lastname' ) ? ? '' ;
2011-09-26 20:45:07 +01:00
$data [ 'user_callsign' ] = $this -> input -> post ( 'user_callsign' );
$data [ 'user_locator' ] = $this -> input -> post ( 'user_locator' );
2023-07-07 16:04:19 +02:00
$data [ 'user_measurement_base' ] = $this -> input -> post ( 'user_measurement_base' );
2025-02-17 12:22:57 +00:00
$data [ 'user_dashboard_map' ] = $this -> input -> post ( 'user_dashboard_map' ) ? ? 'Y' ;
2025-04-28 11:46:28 +02:00
$data [ 'user_dashboard_banner' ] = $this -> input -> post ( 'user_dashboard_banner' ) ? ? 'Y' ;
2025-09-23 00:33:52 +02:00
$data [ 'user_dashboard_solar' ] = $this -> input -> post ( 'user_dashboard_solar' ) ? ? 'Y' ;
2023-07-07 16:04:19 +02:00
$data [ 'user_stylesheet' ] = $this -> input -> post ( 'user_stylesheet' );
2022-10-19 16:27:26 +02:00
$data [ 'user_qth_lookup' ] = $this -> input -> post ( 'user_qth_lookup' );
2021-02-26 10:37:43 +01:00
$data [ 'user_sota_lookup' ] = $this -> input -> post ( 'user_sota_lookup' );
2022-10-19 14:52:43 +02:00
$data [ 'user_wwff_lookup' ] = $this -> input -> post ( 'user_wwff_lookup' );
2023-05-01 21:14:30 +02:00
$data [ 'user_pota_lookup' ] = $this -> input -> post ( 'user_pota_lookup' );
2021-03-20 21:19:07 +01:00
$data [ 'user_show_notes' ] = $this -> input -> post ( 'user_show_notes' );
2021-05-05 17:52:42 +02: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 08:03:25 +02:00
$data [ 'user_column5' ] = $this -> input -> post ( 'user_column5' );
2022-07-03 11:39:05 +02:00
$data [ 'user_show_profile_image' ] = $this -> input -> post ( 'user_show_profile_image' );
2022-11-25 00:22:31 +01:00
$data [ 'user_previous_qsl_type' ] = $this -> input -> post ( 'user_previous_qsl_type' );
2023-01-27 17:24:48 +01:00
$data [ 'user_amsat_status_upload' ] = $this -> input -> post ( 'user_amsat_status_upload' );
2023-07-06 08:17:20 +00:00
$data [ 'user_mastodon_url' ] = $this -> input -> post ( 'user_mastodon_url' );
2023-10-16 22:39:33 +02:00
$data [ 'user_default_band' ] = $this -> input -> post ( 'user_default_band' );
2025-08-21 06:29:52 +00: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' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_clublog' ) !== null ? 'C' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_dcl' ) !== null ? 'D' : '' );
2023-11-01 14:24:13 +01:00
$data [ 'user_qso_end_times' ] = $this -> input -> post ( 'user_qso_end_times' );
2025-10-30 15:37:20 +01:00
$data [ 'user_qso_db_search_priority' ] = $this -> input -> post ( 'user_qso_db_search_priority' ) ? ? 'Y' ;
2023-11-04 18:31:46 +01:00
$data [ 'user_quicklog' ] = $this -> input -> post ( 'user_quicklog' );
2023-11-05 12:29:59 +01:00
$data [ 'user_quicklog_enter' ] = $this -> input -> post ( 'user_quicklog_enter' );
2024-06-06 10:46:12 +02:00
$data [ 'user_language' ] = $this -> input -> post ( 'user_language' );
2025-07-15 07:03:30 +02:00
$data [ 'global_oqrs_text' ] = $this -> input -> post ( 'global_oqrs_text' ) ? ? '' ;
$data [ 'oqrs_grouped_search' ] = $this -> input -> post ( 'oqrs_grouped_search' ) ? ? 'off' ;
$data [ 'oqrs_grouped_search_show_station_name' ] = $this -> input -> post ( 'oqrs_grouped_search_show_station_name' ) ? ? 'off' ;
2025-08-04 11:47:31 +02:00
$data [ 'oqrs_auto_matching' ] = $this -> input -> post ( 'oqrs_auto_matching' ) ? ? 'on' ;
$data [ 'oqrs_direct_auto_matching' ] = $this -> input -> post ( 'oqrs_direct_auto_matching' ) ? ? 'on' ;
2026-04-16 15:56:57 +00:00
$data [ 'oqrs_delivery_method' ] = $this -> input -> post ( 'oqrs_delivery_method' ) ? ? 'both' ;
2025-10-10 03:02:32 +02:00
$data [ 'user_dxwaterfall_enable' ] = $this -> input -> post ( 'user_dxwaterfall_enable' ) ? ? 'N' ;
2023-12-17 19:16:23 +01:00
$this -> load -> view ( 'user/edit' , $data );
2025-01-02 10:22:23 +01:00
$this -> load -> view ( 'interface_assets/footer' , $footerData );
2011-08-18 01:31:15 +01:00
}
}
function edit () {
2024-08-16 10:08:44 +02: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 ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2025-02-28 11:45:33 +01:00
if ( ! clubaccess_check ( 9 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2011-08-18 01:31:15 +01:00
$query = $this -> user_model -> get_by_id ( $this -> uri -> segment ( 3 ));
2021-02-26 10:37:43 +01:00
2024-06-06 10:46:12 +02:00
$data [ 'existing_languages' ] = $this -> config -> item ( 'languages' );
2023-08-02 06:34:12 +00:00
2023-07-07 16:04:19 +02:00
$this -> load -> model ( 'bands' );
2011-08-18 01:31:15 +01:00
$this -> load -> library ( 'form_validation' );
2024-07-22 16:16:03 +02:00
$this -> load -> library ( 'Genfunctions' );
2011-08-18 01:31:15 +01:00
2019-10-05 21:57:44 +01:00
$this -> form_validation -> set_rules ( 'user_name' , 'Username' , 'required|xss_clean' );
2025-07-25 10:52:27 +00:00
$this -> form_validation -> set_rules ( 'user_name' , 'Username' , 'required|callback_check_username' );
2019-10-05 21:57:44 +01:00
$this -> form_validation -> set_rules ( 'user_email' , 'E-mail' , 'required|xss_clean' );
2025-10-07 06:38:09 +00:00
$this -> form_validation -> set_rules ( 'user_clublog_name' , 'Clublog Username' , 'valid_email' );
2011-08-19 20:33:37 +01:00
if ( $this -> session -> userdata ( 'user_type' ) == 99 )
{
2019-10-05 21:57:44 +01:00
$this -> form_validation -> set_rules ( 'user_type' , 'Type' , 'required|xss_clean' );
2011-08-19 20:33:37 +01:00
}
2019-10-05 21:57:44 +01: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 15:18:50 +02:00
$this -> form_validation -> set_rules ( 'user_locator' , 'Locator' , 'callback_check_locator' );
2025-07-25 08:34:03 +00:00
$this -> form_validation -> set_rules ( 'user_email' , 'EMail' , 'required|callback_check_email' );
2025-07-25 10:34:27 +00:00
$this -> form_validation -> set_rules ( 'user_email' , 'EMail' , 'required|valid_email' );
2025-10-07 06:38:09 +00:00
$this -> form_validation -> set_rules ( 'user_clublog_name' , 'Clublog Username' , 'valid_email' );
2011-09-27 23:47:25 +01:00
$this -> form_validation -> set_rules ( 'user_timezone' , 'Timezone' , 'required' );
2011-08-18 01:31:15 +01:00
2025-01-02 10:22:23 +01:00
$data [ 'user_form_action' ] = site_url ( 'user/edit' ) . " / " . $this -> uri -> segment ( 3 );
$data [ 'clubstation' ] = ( $query -> row () -> clubstation == 1 ) ? true : false ;
2023-07-07 16:04:19 +02:00
$data [ 'bands' ] = $this -> bands -> get_user_bands ();
2021-08-09 13:13:41 +02:00
// Get themes list
$data [ 'themes' ] = $this -> user_model -> getThemes ();
2025-01-02 10:22:23 +01:00
$footerData = [];
$footerData [ 'scripts' ] = [
2026-02-13 16:58:57 +01:00
'assets/js/sections/user.js' ,
2025-01-02 10:22:23 +01:00
];
2011-09-27 23:47:25 +01:00
// Get timezones
$data [ 'timezones' ] = $this -> user_model -> timezones ();
2011-08-18 01:31:15 +01:00
2025-01-29 20:43:47 +01:00
// Max value to be present in the "dashboard last QSO count" selectbox
2025-01-30 07:44:48 +01:00
$data [ 'dashboard_last_qso_count_limit' ] = DASHBOARD_QSOS_COUNT_LIMIT ;
2025-01-29 20:43:47 +01:00
2025-01-30 21:09:20 +01:00
// Max value to be present in the "QSO page last QSO count" selectbox
$data [ 'qso_page_last_qso_count_limit' ] = QSO_PAGE_QSOS_COUNT_LIMIT ;
2026-03-18 15:26:31 +01:00
// SSO / OIDC cases
$data [ 'external_account' ] = ! empty ( $query -> row () -> external_account );
$data [ 'auth_header_enable' ] = $this -> config -> item ( 'auth_header_enable' ) ? ? false ;
if ( $data [ 'auth_header_enable' ]) {
// expecting sso.php in the config folder
$this -> config -> load ( 'sso' , true , true );
}
$data [ 'auth_header_allow_direct_login' ] = $this -> config -> item ( 'auth_header_allow_direct_login' , 'sso' ) ? ? true ;
$data [ 'auth_header_hide_password_field' ] = $this -> config -> item ( 'auth_header_hide_password_field' , 'sso' ) ? ? false ;
2026-03-18 18:02:43 -05:00
$data [ 'auth_header_locked_data_badge' ] = $this -> config -> item ( 'auth_header_locked_data_badge' , 'sso' ) ? : 'IdP' ;
$data [ 'auth_header_locked_data_tip' ] = $this -> config -> item ( 'auth_header_locked_data_tip' , 'sso' ) ? : __ ( " Can't be changed. Manage this through your Identity Provider. " );
2026-03-18 15:26:31 +01:00
$data [ 'sso_claim_config' ] = $this -> config -> item ( 'auth_headers_claim_config' , 'sso' ) ? : [];
2025-01-28 18:40:24 +01:00
$data [ 'page_title' ] = __ ( " Edit User " );
2026-07-12 08:51:44 +00:00
// [MAP Custom] GET user options //
$options_object = $this -> user_options_model -> get_options ( 'map_custom' ) -> result ();
if ( count ( $options_object ) > 0 ) {
foreach ( $options_object as $row ) {
if ( $row -> option_name == 'icon' ) {
$option_value = json_decode ( $row -> option_value , true );
foreach ( $option_value as $ktype => $vtype ) {
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 );
} else {
$data [ 'user_map_' . $row -> option_key . '_' . $ktype ] = $vtype ;
}
}
} else {
$data [ 'user_map_' . $row -> option_name . '_' . $row -> option_key ] = $row -> option_value ;
}
}
} 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_unworked_color' ] = " #FF0000 " ;
$data [ 'user_map_gridsquare_show' ] = " 0 " ;
$data [ 'user_map_tile_style' ] = " map-follow " ;
}
$data [ 'map_icon_select' ] = array (
'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' ));
2011-08-18 01:31:15 +01:00
if ( $this -> form_validation -> run () == FALSE )
{
2025-01-29 20:00:27 +01:00
// Prepare data and render the user options view
2011-08-19 20:33:37 +01:00
$q = $query -> row ();
$data [ 'id' ] = $q -> user_id ;
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_name' , true )) {
$data [ 'user_name' ] = $this -> input -> post ( 'user_name' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_name' ] = $q -> user_name ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_email' , true )) {
$data [ 'user_email' ] = $this -> input -> post ( 'user_email' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_email' ] = $q -> user_email ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_password' , true )) {
$data [ 'user_password' ] = $this -> input -> post ( 'user_password' , true );
2011-08-19 20:33:37 +01:00
} else {
2024-05-08 12:53:22 +02:00
if ( $q -> user_password !== '' && $q -> user_password !== null ) {
2026-03-18 15:26:31 +01:00
$data [ 'user_password' ] = $this -> pwd_placeholder ;
2024-05-08 12:53:22 +02:00
} else {
$data [ 'user_password' ] = '' ;
}
2011-08-19 20:33:37 +01:00
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_type' , true )) {
$data [ 'user_type' ] = $this -> input -> post ( 'user_type' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_type' ] = $q -> user_type ;
2011-08-19 17:12:13 +01:00
}
2011-08-19 20:33:37 +01:00
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_callsign' , true )) {
$data [ 'user_callsign' ] = $this -> input -> post ( 'user_callsign' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_callsign' ] = $q -> user_callsign ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_locator' , true )) {
$data [ 'user_locator' ] = $this -> input -> post ( 'user_locator' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_locator' ] = $q -> user_locator ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_firstname' , true )) {
$data [ 'user_firstname' ] = $this -> input -> post ( 'user_firstname' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_firstname' ] = $q -> user_firstname ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_lastname' , true )) {
2020-09-15 17:04:38 +01:00
$data [ 'user_lastname' ] = $this -> input -> post ( 'user_lastname' , true );
2011-08-19 20:33:37 +01:00
} else {
$data [ 'user_lastname' ] = $q -> user_lastname ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_callsign' , true )) {
$data [ 'user_callsign' ] = $this -> input -> post ( 'user_callsign' , true );
2011-09-27 23:47:25 +01:00
} else {
$data [ 'user_callsign' ] = $q -> user_callsign ;
}
2019-10-05 21:57:44 +01:00
if ( $this -> input -> post ( 'user_locator' , true )) {
$data [ 'user_locator' ] = $this -> input -> post ( 'user_locator' , true );
2011-09-27 23:47:25 +01:00
} else {
$data [ 'user_locator' ] = $q -> user_locator ;
}
if ( $this -> input -> post ( 'user_timezone' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_timezone' ] = $this -> input -> post ( 'user_timezone' , true );
2011-09-27 23:47:25 +01:00
} else {
$data [ 'user_timezone' ] = $q -> user_timezone ;
}
2013-02-21 18:31:31 -06:00
if ( $this -> input -> post ( 'user_lotw_name' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_lotw_name' ] = $this -> input -> post ( 'user_lotw_name' , true );
2013-02-21 18:31:31 -06:00
} else {
$data [ 'user_lotw_name' ] = $q -> user_lotw_name ;
}
2019-06-19 14:14:10 +01:00
if ( $this -> input -> post ( 'user_clublog_name' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_clublog_name' ] = $this -> input -> post ( 'user_clublog_name' , true );
2019-06-19 14:14:10 +01:00
} else {
$data [ 'user_clublog_name' ] = $q -> user_clublog_name ;
}
2021-02-26 10:37:43 +01:00
2019-06-19 14:14:10 +01:00
if ( $this -> input -> post ( 'user_clublog_password' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_clublog_password' ] = $this -> input -> post ( 'user_clublog_password' , true );
2019-06-19 14:14:10 +01:00
} else {
2024-05-08 12:53:22 +02:00
if ( $q -> user_clublog_password !== '' && $q -> user_clublog_password !== null ) {
2026-03-18 15:26:31 +01:00
$data [ 'user_clublog_password' ] = $this -> pwd_placeholder ;
2024-05-08 12:53:22 +02:00
} else {
$data [ 'user_clublog_password' ] = '' ;
}
2019-06-19 14:14:10 +01:00
}
2013-02-21 18:31:31 -06:00
if ( $this -> input -> post ( 'user_lotw_password' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_lotw_password' ] = $this -> input -> post ( 'user_lotw_password' , true );
2013-02-21 18:31:31 -06:00
} else {
2024-05-08 12:53:22 +02:00
if ( $q -> user_lotw_password !== '' && $q -> user_lotw_password !== null ) {
2026-03-18 15:26:31 +01:00
$data [ 'user_lotw_password' ] = $this -> pwd_placeholder ;
2024-05-08 12:53:22 +02:00
} else {
$data [ 'user_lotw_password' ] = '' ;
}
2013-02-21 18:31:31 -06:00
}
2021-02-26 10:37:43 +01:00
2013-08-17 09:08:26 -05:00
if ( $this -> input -> post ( 'user_eqsl_name' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_eqsl_name' ] = $this -> input -> post ( 'user_eqsl_name' , true );
2013-08-17 09:08:26 -05:00
} else {
$data [ 'user_eqsl_name' ] = $q -> user_eqsl_name ;
}
2021-02-26 10:37:43 +01:00
2013-08-17 09:08:26 -05:00
if ( $this -> input -> post ( 'user_eqsl_password' )) {
2019-10-05 21:57:44 +01:00
$data [ 'user_eqsl_password' ] = $this -> input -> post ( 'user_eqsl_password' , true );
2013-08-17 09:08:26 -05:00
} else {
2024-05-08 12:53:22 +02:00
if ( $q -> user_eqsl_password !== '' && $q -> user_eqsl_password !== null ) {
2026-03-18 15:26:31 +01:00
$data [ 'user_eqsl_password' ] = $this -> pwd_placeholder ;
2024-05-08 12:53:22 +02:00
} else {
$data [ 'user_eqsl_password' ] = '' ;
}
2013-08-17 09:08:26 -05:00
}
2020-09-14 12:29:02 +02:00
2023-07-07 16:04:19 +02:00
if ( $this -> input -> post ( 'user_measurement_base' )) {
$data [ 'user_measurement_base' ] = $this -> input -> post ( 'user_measurement_base' , true );
} else {
$data [ 'user_measurement_base' ] = $q -> user_measurement_base ;
}
2020-09-15 22:04:47 +01:00
if ( $this -> input -> post ( 'user_date_format' )) {
2023-07-07 16:04:19 +02:00
$data [ 'user_date_format' ] = $this -> input -> post ( 'user_date_format' , true );
} else {
$data [ 'user_date_format' ] = $q -> user_date_format ;
}
2020-09-23 10:59:49 +02:00
2024-06-06 10:46:12 +02:00
if ( $this -> input -> post ( 'user_language' )) {
$data [ 'user_language' ] = $this -> input -> post ( 'user_language' , true );
2023-08-02 06:34:12 +00:00
} else {
2024-06-06 10:46:12 +02:00
$data [ 'user_language' ] = $q -> user_language ;
2023-08-02 06:34:12 +00:00
}
2024-08-16 11:05:43 +02:00
2023-07-07 16:04:19 +02:00
if ( $this -> input -> post ( 'user_stylesheet' )) {
$data [ 'user_stylesheet' ] = $this -> input -> post ( 'user_stylesheet' , true );
} else {
$data [ 'user_stylesheet' ] = $q -> user_stylesheet ;
}
2021-02-26 10:37:43 +01:00
2022-10-19 16:27:26 +02:00
if ( $this -> input -> post ( 'user_qth_lookup' )) {
$data [ 'user_qth_lookup' ] = $this -> input -> post ( 'user_qth_lookup' , true );
} else {
$data [ 'user_qth_lookup' ] = $q -> user_qth_lookup ;
}
2021-02-26 10:37:43 +01:00
if ( $this -> input -> post ( 'user_sota_lookup' )) {
$data [ 'user_sota_lookup' ] = $this -> input -> post ( 'user_sota_lookup' , true );
} else {
$data [ 'user_sota_lookup' ] = $q -> user_sota_lookup ;
}
2022-10-19 14:52:43 +02:00
if ( $this -> input -> post ( 'user_wwff_lookup' )) {
$data [ 'user_wwff_lookup' ] = $this -> input -> post ( 'user_wwff_lookup' , true );
} else {
$data [ 'user_wwff_lookup' ] = $q -> user_wwff_lookup ;
}
2023-05-01 21:14:30 +02:00
if ( $this -> input -> post ( 'user_pota_lookup' )) {
$data [ 'user_pota_lookup' ] = $this -> input -> post ( 'user_pota_lookup' , true );
} else {
$data [ 'user_pota_lookup' ] = $q -> user_pota_lookup ;
}
2021-03-20 21:19:07 +01:00
if ( $this -> input -> post ( 'user_show_notes' )) {
$data [ 'user_show_notes' ] = $this -> input -> post ( 'user_show_notes' , true );
} else {
$data [ 'user_show_notes' ] = $q -> user_show_notes ;
}
2023-11-01 14:24:13 +01:00
if ( $this -> input -> post ( 'user_qso_end_times' )) {
$data [ 'user_qso_end_times' ] = $this -> input -> post ( 'user_qso_end_times' , true );
} else {
$data [ 'user_qso_end_times' ] = $q -> user_qso_end_times ;
}
2023-11-04 18:31:46 +01:00
if ( $this -> input -> post ( 'user_quicklog' )) {
$data [ 'user_quicklog' ] = $this -> input -> post ( 'user_quicklog' , true );
} else {
$data [ 'user_quicklog' ] = $q -> user_quicklog ;
}
2023-11-05 12:29:59 +01:00
if ( $this -> input -> post ( 'user_quicklog_enter' )) {
$data [ 'user_quicklog_enter' ] = $this -> input -> post ( 'user_quicklog_enter' , true );
} else {
$data [ 'user_quicklog_enter' ] = $q -> user_quicklog_enter ;
}
2022-07-03 11:39:05 +02:00
if ( $this -> input -> post ( 'user_show_profile_image' )) {
$data [ 'user_show_profile_image' ] = $this -> input -> post ( 'user_show_profile_image' , false );
2022-04-04 13:17:33 +02:00
} else {
2022-07-03 11:39:05 +02:00
$data [ 'user_show_profile_image' ] = $q -> user_show_profile_image ;
2022-04-04 13:17:33 +02:00
}
2022-11-25 00:22:31 +01:00
if ( $this -> input -> post ( 'user_previous_qsl_type' )) {
$data [ 'user_previous_qsl_type' ] = $this -> input -> post ( 'user_previous_qsl_type' , false );
} else {
$data [ 'user_previous_qsl_type' ] = $q -> user_previous_qsl_type ;
}
2023-01-27 17:24:48 +01:00
if ( $this -> input -> post ( 'user_amsat_status_upload' )) {
$data [ 'user_amsat_status_upload' ] = $this -> input -> post ( 'user_amsat_status_upload' , false );
} else {
$data [ 'user_amsat_status_upload' ] = $q -> user_amsat_status_upload ;
}
2023-07-06 08:17:20 +00:00
if ( $this -> input -> post ( 'user_mastodon_url' )) {
$data [ 'user_mastodon_url' ] = $this -> input -> post ( 'user_mastodon_url' , false );
} else {
$data [ 'user_mastodon_url' ] = $q -> user_mastodon_url ;
}
2023-10-16 22:39:33 +02:00
if ( $this -> input -> post ( 'user_default_band' )) {
$data [ 'user_default_band' ] = $this -> input -> post ( 'user_default_band' , false );
2023-07-07 16:04:19 +02:00
} else {
2023-10-16 22:39:33 +02:00
$data [ 'user_default_band' ] = $q -> user_default_band ;
2023-07-07 16:04:19 +02:00
}
2023-10-16 22:39:33 +02:00
if ( $this -> input -> post ( 'user_default_confirmation' )) {
2025-08-21 06:29:52 +00: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' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_clublog' ) !== null ? 'C' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_dcl' ) !== null ? 'D' : '' );
2023-07-07 16:04:19 +02:00
} else {
2023-10-16 22:39:33 +02:00
$data [ 'user_default_confirmation' ] = $q -> user_default_confirmation ;
2023-07-07 16:04:19 +02:00
}
2021-05-05 17:52:42 +02:00
if ( $this -> input -> post ( 'user_column1' )) {
$data [ 'user_column1' ] = $this -> input -> post ( 'user_column1' , true );
} else {
$data [ 'user_column1' ] = $q -> user_column1 ;
}
if ( $this -> input -> post ( 'user_column2' )) {
$data [ 'user_column2' ] = $this -> input -> post ( 'user_column2' , true );
} else {
$data [ 'user_column2' ] = $q -> user_column2 ;
}
if ( $this -> input -> post ( 'user_column3' )) {
$data [ 'user_column3' ] = $this -> input -> post ( 'user_column3' , true );
} else {
$data [ 'user_column3' ] = $q -> user_column3 ;
}
if ( $this -> input -> post ( 'user_column4' )) {
$data [ 'user_column4' ] = $this -> input -> post ( 'user_column4' , true );
} else {
$data [ 'user_column4' ] = $q -> user_column4 ;
}
2021-05-07 08:03:25 +02:00
if ( $this -> input -> post ( 'user_column5' )) {
$data [ 'user_column5' ] = $this -> input -> post ( 'user_column5' , true );
} else {
$data [ 'user_column5' ] = $q -> user_column5 ;
}
2023-08-03 13:59:02 +01:00
if ( $this -> input -> post ( 'user_winkey' )) {
$data [ 'user_winkey' ] = $this -> input -> post ( 'user_winkey' , true );
} else {
$data [ 'user_winkey' ] = $q -> winkey ;
}
2024-03-07 16:11:54 +01:00
if ( $this -> input -> post ( 'user_hamsat_key' , true )) {
$data [ 'user_hamsat_key' ] = $this -> input -> post ( 'user_hamsat_key' , true );
} else {
2024-05-09 14:24:56 +02:00
$hkey_opt = $this -> user_options_model -> get_options ( 'hamsat' , array ( 'option_name' => 'hamsat_key' , 'option_key' => 'api' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-07 16:34:22 +00:00
if ( count ( $hkey_opt ) > 0 ) {
$data [ 'user_hamsat_key' ] = $hkey_opt [ 0 ] -> option_value ;
} else {
$data [ 'user_hamsat_key' ] = '' ;
}
2024-03-07 16:11:54 +01:00
}
2025-02-17 12:22:57 +00:00
if ( $this -> input -> post ( 'user_dashboard_map' )) {
2026-02-22 09:17:10 +00:00
$data [ 'user_dashboard_map' ] = $this -> input -> post ( 'user_dashboard_map' , true );
2025-02-17 12:22:57 +00:00
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'show_map' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $dkey_opt ) > 0 ) {
$data [ 'user_dashboard_map' ] = $dkey_opt [ 0 ] -> option_value ;
}
}
2025-04-28 11:46:28 +02:00
if ( $this -> input -> post ( 'user_dashboard_banner' )) {
$data [ 'user_dashboard_banner' ] = $this -> input -> post ( 'user_dashboard_banner' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'show_dashboard_banner' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $dkey_opt ) > 0 ) {
$data [ 'user_dashboard_banner' ] = $dkey_opt [ 0 ] -> option_value ;
}
}
2025-09-23 00:33:52 +02:00
// Dashboard solar data information widget
if ( $this -> input -> post ( 'user_dashboard_solar' )) {
$data [ 'user_dashboard_solar' ] = $this -> input -> post ( 'user_dashboard_solar' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'show_dashboard_solar' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $dkey_opt ) > 0 ) {
$data [ 'user_dashboard_solar' ] = $dkey_opt [ 0 ] -> option_value ;
}
}
2026-06-06 14:27:24 +02:00
// Dashboard show expeditions
if ( $this -> input -> post ( 'user_dashboard_show_dxpeditions' ) !== null ) {
$data [ 'user_dashboard_show_dxpeditions' ] = $this -> input -> post ( 'user_dashboard_show_dxpeditions' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'show_dxpeditions' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
2026-06-08 19:28:08 +02:00
$data [ 'user_dashboard_show_dxpeditions' ] = ( count ( $dkey_opt ) > 0 ) ? $dkey_opt [ 0 ] -> option_value : false ;
2026-06-06 14:27:24 +02:00
}
// Dashboard show contests
if ( $this -> input -> post ( 'user_dashboard_show_contests' ) !== null ) {
$data [ 'user_dashboard_show_contests' ] = $this -> input -> post ( 'user_dashboard_show_contests' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'show_contests' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
2026-06-08 19:28:08 +02:00
$data [ 'user_dashboard_show_contests' ] = ( count ( $dkey_opt ) > 0 ) ? $dkey_opt [ 0 ] -> option_value : false ;
2026-06-06 14:27:24 +02:00
}
2026-06-30 10:43:13 +02:00
// Dashboard show KPI statistics
if ( $this -> input -> post ( 'user_dashboard_show_kpi_stats' ) !== null ) {
$data [ 'user_dashboard_show_kpi_stats' ] = $this -> input -> post ( 'user_dashboard_show_kpi_stats' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'show_kpi_stats' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
$data [ 'user_dashboard_show_kpi_stats' ] = ( count ( $dkey_opt ) > 0 ) ? $dkey_opt [ 0 ] -> option_value : '1' ;
}
2025-10-10 03:02:32 +02:00
// DX Waterfall enable option
if ( $this -> input -> post ( 'user_dxwaterfall_enable' )) {
$data [ 'user_dxwaterfall_enable' ] = $this -> input -> post ( 'user_dxwaterfall_enable' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'dxwaterfall' , array ( 'option_name' => 'enable' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $dkey_opt ) > 0 ) {
$data [ 'user_dxwaterfall_enable' ] = $dkey_opt [ 0 ] -> option_value ;
2025-09-23 00:33:52 +02:00
}
}
2024-03-07 16:11:54 +01:00
if ( $this -> input -> post ( 'user_hamsat_workable_only' )) {
$data [ 'user_hamsat_workable_only' ] = $this -> input -> post ( 'user_hamsat_workable_only' , false );
} else {
2024-05-09 14:24:56 +02:00
$hkey_opt = $this -> user_options_model -> get_options ( 'hamsat' , array ( 'option_name' => 'hamsat_key' , 'option_key' => 'workable' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-07 16:34:22 +00:00
if ( count ( $hkey_opt ) > 0 ) {
$data [ 'user_hamsat_workable_only' ] = $hkey_opt [ 0 ] -> option_value ;
}
2024-03-07 16:11:54 +01:00
}
2024-03-22 07:16:04 +01:00
if ( $this -> input -> post ( 'user_iota_to_qso_tab' )) {
$data [ 'user_iota_to_qso_tab' ] = $this -> input -> post ( 'user_iota_to_qso_tab' , false );
} else {
2024-05-09 14:24:56 +02:00
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'iota' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-22 07:16:04 +01:00
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_iota_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
2024-03-22 07:57:31 +01:00
}
}
if ( $this -> input -> post ( 'user_sota_to_qso_tab' )) {
$data [ 'user_sota_to_qso_tab' ] = $this -> input -> post ( 'user_sota_to_qso_tab' , false );
} else {
2024-05-09 14:24:56 +02:00
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'sota' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-22 07:57:31 +01:00
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_sota_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
2024-03-22 08:06:54 +01:00
}
}
if ( $this -> input -> post ( 'user_wwff_to_qso_tab' )) {
$data [ 'user_wwff_to_qso_tab' ] = $this -> input -> post ( 'user_wwff_to_qso_tab' , false );
} else {
2024-05-09 14:24:56 +02:00
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'wwff' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-22 08:06:54 +01:00
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_wwff_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
2024-03-22 08:15:45 +01:00
}
}
if ( $this -> input -> post ( 'user_pota_to_qso_tab' )) {
$data [ 'user_pota_to_qso_tab' ] = $this -> input -> post ( 'user_pota_to_qso_tab' , false );
} else {
2024-05-09 14:24:56 +02:00
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'pota' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-22 08:15:45 +01:00
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_pota_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
2024-03-22 08:26:26 +01:00
}
}
if ( $this -> input -> post ( 'user_sig_to_qso_tab' )) {
$data [ 'user_sig_to_qso_tab' ] = $this -> input -> post ( 'user_sig_to_qso_tab' , false );
} else {
2024-05-09 14:24:56 +02:00
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'sig' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-22 08:26:26 +01:00
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_sig_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
2024-03-22 08:35:02 +01:00
}
}
if ( $this -> input -> post ( 'user_dok_to_qso_tab' )) {
$data [ 'user_dok_to_qso_tab' ] = $this -> input -> post ( 'user_dok_to_qso_tab' , false );
} else {
2024-05-09 14:24:56 +02:00
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'dok' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
2024-03-22 08:35:02 +01:00
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_dok_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
2024-03-22 07:16:04 +01:00
}
}
2025-12-11 05:44:23 +00:00
if ( $this -> input -> post ( 'user_station_to_qso_tab' )) {
$data [ 'user_station_to_qso_tab' ] = $this -> input -> post ( 'user_station_to_qso_tab' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'station' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_station_to_qso_tab' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
2024-03-22 07:16:04 +01:00
2026-02-23 06:55:19 +01:00
if ( $this -> input -> post ( 'user_qso_show_map' )) {
2026-02-22 09:17:10 +00:00
$data [ 'user_qso_show_map' ] = $this -> input -> post ( 'user_qso_show_map' , true );
2026-02-22 09:02:23 +00:00
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'map' , 'option_key' => 'show' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_qso_show_map' ] = $qkey_opt [ 0 ] -> option_value ;
} else {
$data [ 'user_qso_show_map' ] = 1 ; // default: show
}
}
2025-07-15 07:03:30 +02:00
if ( $this -> input -> post ( 'global_oqrs_text' )) {
$data [ 'global_oqrs_text' ] = $this -> input -> post ( 'global_oqrs_text' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'oqrs' , array ( 'option_name' => 'global_oqrs_text' , 'option_key' => 'text' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'global_oqrs_text' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
if ( $this -> input -> post ( 'oqrs_grouped_search' )) {
$data [ 'oqrs_grouped_search' ] = $this -> input -> post ( 'oqrs_grouped_search' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'oqrs' , array ( 'option_name' => 'oqrs_grouped_search' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'oqrs_grouped_search' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
if ( $this -> input -> post ( 'oqrs_grouped_search_show_station_name' )) {
$data [ 'oqrs_grouped_search_show_station_name' ] = $this -> input -> post ( 'oqrs_grouped_search_show_station_name' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'oqrs' , array ( 'option_name' => 'oqrs_grouped_search_show_station_name' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'oqrs_grouped_search_show_station_name' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
2025-07-30 09:56:05 +02:00
if ( $this -> input -> post ( 'oqrs_auto_matching' )) {
$data [ 'oqrs_auto_matching' ] = $this -> input -> post ( 'oqrs_auto_matching' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'oqrs' , array ( 'option_name' => 'oqrs_auto_matching' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'oqrs_auto_matching' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
2025-10-30 15:37:20 +01:00
if ( $this -> input -> post ( 'user_qso_db_search_priority' )) {
$data [ 'user_qso_db_search_priority' ] = $this -> input -> post ( 'user_qso_db_search_priority' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'qso_db_search_priority' , array ( 'option_name' => 'enable' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'user_qso_db_search_priority' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
2025-08-04 11:47:31 +02:00
if ( $this -> input -> post ( 'oqrs_direct_auto_matching' )) {
$data [ 'oqrs_direct_auto_matching' ] = $this -> input -> post ( 'oqrs_direct_auto_matching' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'oqrs' , array ( 'option_name' => 'oqrs_direct_auto_matching' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'oqrs_direct_auto_matching' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
2026-04-16 15:56:57 +00:00
if ( $this -> input -> post ( 'oqrs_delivery_method' )) {
$data [ 'oqrs_delivery_method' ] = $this -> input -> post ( 'oqrs_delivery_method' , false );
} else {
$qkey_opt = $this -> user_options_model -> get_options ( 'oqrs' , array ( 'option_name' => 'oqrs_delivery_method' , 'option_key' => 'setting' ), $this -> uri -> segment ( 3 )) -> result ();
if ( count ( $qkey_opt ) > 0 ) {
$data [ 'oqrs_delivery_method' ] = $qkey_opt [ 0 ] -> option_value ;
}
}
2026-06-20 10:29:55 -07:00
// Station locations linked to active logbook
if ( $this -> input -> post ( 'user_stations_active_log_only' ) !== null ) {
$data [ 'user_stations_active_log_only' ] = $this -> input -> post ( 'user_stations_active_log_only' , false );
} else {
$dkey_opt = $this -> user_options_model -> get_options ( 'stations' , array ( 'option_name' => 'active_log_only' , 'option_key' => 'boolean' ), $this -> uri -> segment ( 3 )) -> result ();
$data [ 'user_stations_active_log_only' ] = ( count ( $dkey_opt ) > 0 ) ? $dkey_opt [ 0 ] -> option_value : false ;
}
2024-05-09 14:24:56 +02:00
$data [ 'user_locations_quickswitch' ] = ( $this -> user_options_model -> get_options ( 'header_menu' , array ( 'option_name' => 'locations_quickswitch' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? 'false' );
$data [ 'user_utc_headermenu' ] = ( $this -> user_options_model -> get_options ( 'header_menu' , array ( 'option_name' => 'utc_headermenu' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? 'false' );
2026-07-01 10:36:40 +02:00
$data [ 'user_quick_theme_switcher' ] = ( $this -> user_options_model -> get_options ( 'header_menu' , array ( 'option_name' => 'quick_theme_switcher' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? 'true' );
2025-01-30 07:44:48 +01:00
$data [ 'user_dashboard_last_qso_count' ] = ( $this -> user_options_model -> get_options ( 'dashboard' , array ( 'option_name' => 'last_qso_count' , 'option_key' => 'count' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? DASHBOARD_DEFAULT_QSOS_COUNT );
2025-01-30 21:09:20 +01:00
$data [ 'user_qso_page_last_qso_count' ] = ( $this -> user_options_model -> get_options ( 'qso_tab' , array ( 'option_name' => 'last_qso_count' , 'option_key' => 'count' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? QSO_PAGE_DEFAULT_QSOS_COUNT );
2025-01-29 20:43:47 +01:00
2025-02-18 23:28:32 +01:00
$data [ 'on_air_widget_enabled' ] = ( $this -> user_options_model -> get_options ( 'widget' , array ( 'option_name' => 'on_air' , 'option_key' => 'enabled' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? " false " );
$data [ 'on_air_widget_display_last_seen' ] = ( $this -> user_options_model -> get_options ( 'widget' , array ( 'option_name' => 'on_air' , 'option_key' => 'display_last_seen' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? " false " );
$data [ 'on_air_widget_show_only_most_recent_radio' ] = ( $this -> user_options_model -> get_options ( 'widget' , array ( 'option_name' => 'on_air' , 'option_key' => 'display_only_most_recent_radio' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? " true " );
2026-08-08 08:29:07 +02:00
$data [ 'on_air_widget_display_radio_name' ] = ( $this -> user_options_model -> get_options ( 'widget' , array ( 'option_name' => 'on_air' , 'option_key' => 'display_radio_name' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? " false " );
2025-02-18 23:28:32 +01:00
$data [ 'on_air_widget_url' ] = site_url ( 'widgets/on_air/' . $q -> slug );
2025-02-27 21:52:19 +01:00
$data [ 'qso_widget_display_qso_time' ] = ( $this -> user_options_model -> get_options ( 'widget' , array ( 'option_name' => 'qso' , 'option_key' => 'display_qso_time' ), $this -> uri -> segment ( 3 )) -> row () -> option_value ? ? " false " );
2026-03-16 11:04:00 +00:00
$data [ 'csrf_token' ] = $this -> paths -> csrf_generate ( $this -> router -> class . '_' . $this -> router -> method );
2025-02-18 23:28:32 +01:00
2023-08-02 06:34:12 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2011-08-19 17:12:13 +01:00
$this -> load -> view ( 'user/edit' , $data );
2025-01-02 10:22:23 +01:00
$this -> load -> view ( 'interface_assets/footer' , $footerData );
2023-08-02 06:34:12 +00:00
} else {
2025-04-28 11:46:28 +02:00
// Data was submitted for saving - save updated options in DB
2026-03-16 11:04:00 +00:00
if ( ! $this -> paths -> csrf_verify ( $this -> router -> class . '_' . $this -> router -> method )) {
$this -> session -> set_flashdata ( 'error' , __ ( " Invalid security token " ));
redirect ( 'user/edit/' . $this -> uri -> segment ( 3 ));
return ;
}
2026-03-18 15:26:31 +01:00
// SSO / OIDC: Override submitted values for fields managed by the IdP
$post_data = $this -> input -> post ();
if ( ! empty ( $query -> row () -> external_account )) {
$post_data [ 'user_name' ] = $query -> row () -> user_name ;
2026-03-18 17:21:41 -05:00
if ( ! ( $this -> config -> item ( 'auth_header_allow_direct_login' , 'sso' ) ? ? true )) {
2026-03-18 15:26:31 +01:00
$post_data [ 'user_password' ] = $this -> pwd_placeholder ; // placeholder → model skips password update
}
}
switch ( $this -> user_model -> edit ( $post_data )) {
2011-08-19 17:12:13 +01:00
// Check for errors
case EUSERNAMEEXISTS :
2019-10-05 19:35:55 +01:00
$data [ 'username_error' ] = 'Username <b>' . $this -> input -> post ( 'user_name' , true ) . '</b> already in use!' ;
2011-08-19 17:12:13 +01:00
break ;
case EEMAILEXISTS :
2019-10-05 19:35:55 +01:00
$data [ 'email_error' ] = 'E-mail address <b>' . $this -> input -> post ( 'user_email' , true ) . '</b> already in use!' ;
2011-08-19 17:12:13 +01:00
break ;
case EPASSWORDINVALID :
$data [ 'password_error' ] = 'Invalid password!' ;
break ;
// All okay, return to user screen
case OK :
2023-08-02 06:34:12 +00:00
if ( $this -> session -> userdata ( 'user_id' ) == $this -> uri -> segment ( 3 )) { // Editing own User? Set cookie!
$cookie = array (
2024-08-13 08:30:54 +02:00
'name' => $this -> config -> item ( 'gettext_cookie' , 'gettext' ),
2024-06-06 10:46:12 +02:00
'value' => $this -> input -> post ( 'user_language' , true ),
2024-08-31 12:34:09 +03:00
'expire' => 1000 ,
2023-08-02 06:37:56 +00:00
'secure' => FALSE
2023-08-02 06:34:12 +00:00
);
$this -> input -> set_cookie ( $cookie );
}
2025-10-27 14:59:48 +01:00
$user_id = $this -> input -> post ( 'id' , true );
// [MAP Custom] ADD to user options //
2025-11-16 13:58:58 +01:00
$array_icon = array ( 'station' , 'qso' , 'qsoconfirm' , 'unworked' );
2025-10-27 14:59:48 +01:00
foreach ( $array_icon as $icon ) {
$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 ));
}
if ( ! empty ( $data_options [ 'user_map_qso_icon' ])) {
2023-11-30 18:11:22 +01:00
foreach ( $array_icon as $icon ) {
2025-10-27 14:59:48 +01:00
$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 ), $user_id );
2023-11-30 18:11:22 +01:00
}
2025-10-27 14:59:48 +01:00
$this -> user_options_model -> set_option ( 'map_custom' , 'gridsquare' , array ( 'show' => xss_clean ( $this -> input -> post ( 'user_map_gridsquare_show' , true ))), $user_id );
2026-07-02 14:12:33 +08:00
$this -> user_options_model -> set_option ( 'map_custom' , 'tile' , array ( 'style' => xss_clean ( $this -> input -> post ( 'user_map_tile_style' , true ))), $user_id );
2025-10-27 14:59:48 +01:00
} else {
2025-10-27 15:37:56 +01:00
$this -> user_options_model -> del_option ( 'map_custom' , 'icon' , null , $user_id );
$this -> user_options_model -> del_option ( 'map_custom' , 'gridsquare' , null , $user_id );
2026-07-02 14:12:33 +08:00
$this -> user_options_model -> del_option ( 'map_custom' , 'tile' , null , $user_id );
2025-10-27 14:59:48 +01:00
}
$this -> user_options_model -> set_option ( 'header_menu' , 'locations_quickswitch' , array ( 'boolean' => xss_clean ( $this -> input -> post ( 'user_locations_quickswitch' , true ))), $user_id );
$this -> user_options_model -> set_option ( 'header_menu' , 'utc_headermenu' , array ( 'boolean' => xss_clean ( $this -> input -> post ( 'user_utc_headermenu' , true ))), $user_id );
2026-07-01 10:36:40 +02:00
$this -> user_options_model -> set_option ( 'header_menu' , 'quick_theme_switcher' , array ( 'boolean' => xss_clean ( $this -> input -> post ( 'user_quick_theme_switcher' , true ))), $user_id );
2025-07-15 07:03:30 +02:00
2025-10-27 14:59:48 +01:00
$this -> user_options_model -> set_option ( 'oqrs' , 'global_oqrs_text' , array ( 'text' => $this -> input -> post ( 'global_oqrs_text' , true )), $user_id );
$this -> user_options_model -> set_option ( 'oqrs' , 'oqrs_grouped_search' , array ( 'boolean' => $this -> input -> post ( 'oqrs_grouped_search' , true )), $user_id );
$this -> user_options_model -> set_option ( 'oqrs' , 'oqrs_grouped_search_show_station_name' , array ( 'boolean' => $this -> input -> post ( 'oqrs_grouped_search_show_station_name' , true )), $user_id );
$this -> user_options_model -> set_option ( 'oqrs' , 'oqrs_auto_matching' , array ( 'boolean' => $this -> input -> post ( 'oqrs_auto_matching' , true )), $user_id );
$this -> user_options_model -> set_option ( 'oqrs' , 'oqrs_direct_auto_matching' , array ( 'boolean' => $this -> input -> post ( 'oqrs_direct_auto_matching' , true )), $user_id );
2026-04-16 15:56:57 +00:00
$this -> user_options_model -> set_option ( 'oqrs' , 'oqrs_delivery_method' , array ( 'setting' => $this -> input -> post ( 'oqrs_delivery_method' , true ) ? ? 'both' ), $user_id );
2026-06-08 10:28:44 +02:00
$this -> user_options_model -> set_option ( 'dashboard' , 'show_dxpeditions' , array ( 'boolean' => ( $this -> input -> post ( 'user_dashboard_show_dxpeditions' ) == '1' ? '1' : '0' )), $user_id );
$this -> user_options_model -> set_option ( 'dashboard' , 'show_contests' , array ( 'boolean' => ( $this -> input -> post ( 'user_dashboard_show_contests' ) == '1' ? '1' : '0' )), $user_id );
2026-06-30 10:43:13 +02:00
$this -> user_options_model -> set_option ( 'dashboard' , 'show_kpi_stats' , array ( 'boolean' => ( $this -> input -> post ( 'user_dashboard_show_kpi_stats' ) == '1' ? '1' : '0' )), $user_id );
2026-06-20 10:29:55 -07:00
$this -> user_options_model -> set_option ( 'stations' , 'active_log_only' , array ( 'boolean' => ( $this -> input -> post ( 'user_stations_active_log_only' ) == '1' ? '1' : '0' )), $user_id );
2025-07-15 07:03:30 +02:00
2025-10-27 14:59:48 +01:00
if ( $this -> session -> userdata ( 'user_id' ) == $user_id ) {
2024-11-19 02:10:32 +01:00
$this -> session -> set_flashdata ( 'success' , sprintf ( __ ( " User %s edited " ), $this -> input -> post ( 'user_name' , true )));
2020-12-07 13:53:01 +00:00
redirect ( 'user/edit/' . $this -> uri -> segment ( 3 ));
2011-08-19 21:14:16 +01:00
} else {
2024-11-19 02:10:32 +01:00
$this -> session -> set_flashdata ( 'success' , sprintf ( __ ( " User %s edited " ), $this -> input -> post ( 'user_name' , true )));
2011-08-19 21:14:16 +01:00
redirect ( 'user' );
}
2011-08-19 17:12:13 +01:00
return ;
}
2011-11-04 17:32:03 +00:00
2026-03-16 11:04:00 +00:00
$data [ 'csrf_token' ] = $this -> paths -> csrf_generate ( $this -> router -> class . '_' . $this -> router -> method );
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2019-10-05 21:57:44 +01: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 16:04:19 +02:00
$data [ 'user_stylesheet' ] = $this -> input -> post ( 'user_stylesheet' );
2022-10-19 16:27:26 +02:00
$data [ 'user_qth_lookup' ] = $this -> input -> post ( 'user_qth_lookup' );
2021-02-26 10:37:43 +01:00
$data [ 'user_sota_lookup' ] = $this -> input -> post ( 'user_sota_lookup' );
2022-10-19 14:52:43 +02:00
$data [ 'user_wwff_lookup' ] = $this -> input -> post ( 'user_wwff_lookup' );
2023-05-01 21:14:30 +02:00
$data [ 'user_pota_lookup' ] = $this -> input -> post ( 'user_pota_lookup' );
2021-03-20 21:19:07 +01:00
$data [ 'user_show_notes' ] = $this -> input -> post ( 'user_show_notes' );
2021-05-05 17:52:42 +02: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 08:03:25 +02:00
$data [ 'user_column4' ] = $this -> input -> post ( 'user_column4' );
$data [ 'user_column5' ] = $this -> input -> post ( 'user_column5' );
2022-07-03 11:39:05 +02:00
$data [ 'user_show_profile_image' ] = $this -> input -> post ( 'user_show_profile_image' );
2022-11-25 00:22:31 +01:00
$data [ 'user_previous_qsl_type' ] = $this -> input -> post ( 'user_previous_qsl_type' );
2023-01-27 17:24:48 +01:00
$data [ 'user_amsat_status_upload' ] = $this -> input -> post ( 'user_amsat_status_upload' );
2023-07-06 08:17:20 +00:00
$data [ 'user_mastodon_url' ] = $this -> input -> post ( 'user_mastodon_url' );
2023-10-16 22:39:33 +02:00
$data [ 'user_default_band' ] = $this -> input -> post ( 'user_default_band' );
2025-08-21 06:29:52 +00: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' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_clublog' ) !== null ? 'C' : '' ) . ( $this -> input -> post ( 'user_default_confirmation_dcl' ) !== null ? 'D' : '' );
2023-11-01 14:24:13 +01:00
$data [ 'user_qso_end_times' ] = $this -> input -> post ( 'user_qso_end_times' );
2023-11-04 18:31:46 +01:00
$data [ 'user_quicklog' ] = $this -> input -> post ( 'user_quicklog' );
2023-11-05 12:29:59 +01:00
$data [ 'user_quicklog_enter' ] = $this -> input -> post ( 'user_quicklog_enter' );
2024-02-09 11:05:28 +01:00
$data [ 'user_locations_quickswitch' ] = $this -> input -> post ( 'user_locations_quickswitch' , true );
2024-05-05 14:56:11 +02:00
$data [ 'user_utc_headermenu' ] = $this -> input -> post ( 'user_utc_headermenu' , true );
2026-07-01 10:36:40 +02:00
$data [ 'user_quick_theme_switcher' ] = $this -> input -> post ( 'user_quick_theme_switcher' , true );
2024-06-06 10:46:12 +02:00
$data [ 'user_language' ] = $this -> input -> post ( 'user_language' );
2023-08-03 13:59:02 +01:00
$data [ 'user_winkey' ] = $this -> input -> post ( 'user_winkey' );
2024-03-07 16:11:54 +01:00
$data [ 'user_hamsat_key' ] = $this -> input -> post ( 'user_hamsat_key' );
$data [ 'user_hamsat_workable_only' ] = $this -> input -> post ( 'user_hamsat_workable_only' );
2025-01-29 20:43:47 +01:00
$data [ 'user_dashboard_last_qso_count' ] = $this -> input -> post ( 'user_dashboard_last_qso_count' , true );
2025-01-30 21:09:20 +01:00
$data [ 'user_qso_page_last_qso_count' ] = $this -> input -> post ( 'user_qso_page_last_qso_count' , true );
2025-02-18 23:28:32 +01:00
$data [ 'on_air_widget_enabled' ] = $this -> input -> post ( 'on_air_widget_enabled' , true );
$data [ 'on_air_widget_display_last_seen' ] = $this -> input -> post ( 'on_air_widget_display_last_seen' , true );
$data [ 'on_air_widget_show_only_most_recent_radio' ] = $this -> input -> post ( 'on_air_widget_show_only_most_recent_radio' , true );
2026-08-08 08:29:07 +02:00
$data [ 'on_air_widget_display_radio_name' ] = $this -> input -> post ( 'on_air_widget_display_radio_name' , true );
2025-02-27 21:52:19 +01:00
$data [ 'qso_widget_display_qso_time' ] = $this -> input -> post ( 'qso_widget_display_qso_time' , true );
2025-07-15 07:03:30 +02:00
$data [ 'global_oqrs_text' ] = $this -> input -> post ( 'global_oqrs_text' , true );
$data [ 'oqrs_grouped_search' ] = $this -> input -> post ( 'oqrs_grouped_search' , true );
$data [ 'oqrs_grouped_search_show_station_name' ] = $this -> input -> post ( 'oqrs_grouped_search_show_station_name' , true );
2025-07-30 09:56:05 +02:00
$data [ 'oqrs_auto_matching' ] = $this -> input -> post ( 'oqrs_auto_matching' , true );
2025-08-04 11:47:31 +02:00
$data [ 'oqrs_direct_auto_matching' ] = $this -> input -> post ( 'oqrs_direct_auto_matching' , true );
2026-04-16 15:56:57 +00:00
$data [ 'oqrs_delivery_method' ] = $this -> input -> post ( 'oqrs_delivery_method' , true );
2025-10-30 15:37:20 +01:00
$data [ 'user_qso_db_search_priority' ] = $this -> input -> post ( 'user_qso_db_search_priority' , true );
2025-01-30 21:09:20 +01:00
2026-07-12 08:51:44 +00:00
$this -> load -> view ( 'user/edit' , $data );
$this -> load -> view ( 'interface_assets/footer' , $footerData );
2011-08-18 01:31:15 +01:00
}
2011-08-19 17:12:13 +01:00
}
2011-08-19 20:33:37 +01:00
function profile () {
2024-08-16 10:08:44 +02:00
if ( ! $this -> user_model -> authorize ( 2 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2011-08-19 20:33:37 +01:00
$query = $this -> user_model -> get_by_id ( $this -> session -> userdata ( 'user_id' ));
2024-02-09 11:05:28 +01:00
$q = $query -> row ();
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Profile " );
2024-02-09 11:05:28 +01:00
$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-04 17:32:03 +00:00
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2011-11-04 17:32:03 +00:00
$this -> load -> view ( 'user/profile' );
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/footer' );
2011-08-19 20:33:37 +01:00
}
2011-08-19 17:12:13 +01:00
function delete () {
2024-08-16 10:08:44 +02:00
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2011-08-19 17:12:13 +01: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 ();
2025-11-14 02:12:16 +01:00
$data -> page_title = __ ( " Delete User " );
2011-08-19 17:12:13 +01:00
2026-03-16 11:32:57 +01:00
if ( $this -> form_validation -> run () == FALSE ) {
$data -> csrf_token = $this -> paths -> csrf_generate ( $this -> router -> class . '_' . $this -> router -> method );
2011-11-04 17:32:03 +00:00
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2011-11-04 17:32:03 +00:00
$this -> load -> view ( 'user/delete' );
2019-01-09 15:18:46 +00:00
$this -> load -> view ( 'interface_assets/footer' );
2026-03-16 11:32:57 +01:00
} else {
if ( ! $this -> paths -> csrf_verify ( $this -> router -> class . '_' . $this -> router -> method )) {
2026-03-16 08:41:50 +00:00
$this -> session -> set_flashdata ( 'error' , __ ( " Invalid security token " ));
redirect ( 'user' );
return ;
}
2026-03-16 11:32:57 +01:00
if ( $this -> user_model -> delete ( $data -> user_id )) {
2025-11-14 02:12:16 +01:00
$this -> session -> set_flashdata ( 'notice' , __ ( " User deleted " ));
2011-08-19 17:12:13 +01:00
redirect ( 'user' );
} else {
2025-11-14 02:12:16 +01:00
$this -> session -> set_flashdata ( 'notice' , '<b>' . __ ( " Database error: " ) . '</b> ' . __ ( " Could not delete user! " ));
2011-08-19 17:12:13 +01:00
redirect ( 'user' );
}
2011-08-18 01:31:15 +01:00
}
}
2026-06-14 15:19:02 +02:00
/*
* FUNCTION : theme_switch
*
* Lightweight JSON endpoint used by the header theme switcher . Validates the
* requested theme against the themes table , then updates the current user ' s
* stylesheet in both the DB and the session . Any logged - in user may change
* their own theme — no need to open the profile / settings page .
*/
public function theme_switch () {
header ( 'Content-Type: application/json' );
if ( ! $this -> user_model -> authorize ( 2 )) {
echo json_encode ( array ( 'status' => 'error' , 'message' => __ ( " You're not allowed to do that! " )));
return ;
}
$foldername = $this -> input -> post ( 'theme' , true );
if ( $foldername === null || $foldername === '' ) {
echo json_encode ( array ( 'status' => 'error' , 'message' => 'No theme selected.' ));
return ;
}
// Only trust foldernames that actually exist in the themes table
$this -> load -> model ( 'Themes_model' );
$valid = false ;
foreach ( $this -> Themes_model -> getThemes () as $t ) {
if ( $t -> foldername === $foldername ) {
$valid = true ;
break ;
}
}
if ( ! $valid ) {
echo json_encode ( array ( 'status' => 'error' , 'message' => 'Unknown theme.' ));
return ;
}
$user_id = $this -> session -> userdata ( 'user_id' );
if ( $this -> user_model -> set_user_stylesheet ( $user_id , $foldername )) {
$this -> session -> set_userdata ( 'user_stylesheet' , $foldername );
echo json_encode ( array ( 'status' => 'success' , 'foldername' => $foldername ));
} else {
echo json_encode ( array ( 'status' => 'error' , 'message' => 'Could not save theme.' ));
}
}
2024-07-21 17:47:19 +02:00
function login ( $firstlogin = false ) {
2025-01-02 10:22:23 +01:00
// Due the fact there was a new session generated, we need to get flash messages from a temporary cookie
$tmpdata = json_decode ( $this -> input -> cookie ( config_item ( 'cookie_prefix' ) . 'tmp_msg' ) ? ? '' ) ? ? false ;
if ( $tmpdata ) {
$this -> session -> set_flashdata ( $tmpdata [ 0 ], $tmpdata [ 1 ]);
$this -> input -> set_cookie ( 'tmp_msg' , '' , - 3600 , '' );
}
2020-05-12 19:01:38 +01:00
// Check our version and run any migrations
2024-07-11 14:17:38 +02:00
if ( ! $this -> load -> is_loaded ( 'Migration' )) {
$this -> load -> library ( 'Migration' );
}
if ( ! $this -> load -> is_loaded ( 'Encryption' )) {
$this -> load -> library ( 'Encryption' );
}
2021-02-26 10:37:43 +01:00
$this -> migration -> current ();
2024-07-21 17:47:19 +02:00
if ( $firstlogin == true ) {
$this -> session -> set_flashdata ( 'success' , __ ( " Congrats! Wavelog was successfully installed. You can now login for the first time. " ));
}
2019-10-05 19:28:20 +01:00
$query = $this -> user_model -> get ( $this -> input -> post ( 'user_name' , true ));
2011-08-18 01:31:15 +01: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-24 16:42:36 -05:00
$data [ 'user' ] = $query -> row ();
2011-11-04 17:32:03 +00:00
2024-07-11 14:17:38 +02:00
// Read the cookie keep_login and allow the login
2025-01-02 10:22:23 +01:00
if ( $this -> input -> cookie ( config_item ( 'cookie_prefix' ) . 'keep_login' ) || $this -> input -> cookie ( config_item ( 'cookie_prefix' ) . 're_login' )) {
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
try {
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
if ( $this -> config -> item ( 'encryption_key' ) == 'flossie1234555541' ) {
throw new Exception ( " Encryption Key is still default. Change config['encryption_key'] to another value then flossie... " );
}
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
// process the incoming string
2025-01-02 10:22:23 +01:00
$incoming_string = $this -> input -> cookie ( config_item ( 'cookie_prefix' ) . 'keep_login' ) ? ? $this -> input -> cookie ( config_item ( 'cookie_prefix' ) . 're_login' );
2024-07-11 17:04:57 +02:00
$i_str_parts_a = explode ( base64_encode ( $this -> config -> item ( 'base_url' )), $incoming_string );
$uid = base64_decode ( $i_str_parts_a [ 1 ]);
$a = $i_str_parts_a [ 0 ];
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
// process the string to compare with
$compare_string = $this -> user_model -> keep_cookie_hash ( $uid );
$i_str_parts_b = explode ( base64_encode ( $this -> config -> item ( 'base_url' )), $compare_string );
$b = $i_str_parts_b [ 0 ];
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
$user = $this -> user_model -> get_by_id ( $uid ) -> row ();
$user_type = $user -> user_type ;
2024-07-11 14:17:38 +02:00
2025-01-02 10:22:23 +01:00
// direct login to clubstations are not allowed, especially not with a keeplogin cookie
if ( $user -> clubstation == 1 ) {
log_message ( 'debug' , " User ID: [ $uid ] Login rejected because of a external clubstation login attempt with a modified cookie. Attack? " );
$this -> session -> set_flashdata ( 'error' , __ ( " This is not allowed! " ));
2025-09-27 10:41:13 +00:00
$this -> output -> set_header ( 'X-Login-Status: failed' );
$this -> output -> _display ();
2025-01-02 10:22:23 +01:00
redirect ( 'user/login' );
}
2024-07-11 17:04:57 +02:00
// compare both strings the hard way and log in if they match
if ( $this -> user_model -> check_keep_hash ( $a , $b )) {
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
// check if maintenance mode is active or the user is an admin
if ( ENVIRONMENT != 'maintenance' || $user_type == 99 ) {
2024-07-11 14:17:38 +02:00
2024-07-11 17:04:57 +02:00
// if everything is fine we can log in the user
$this -> user_model -> update_session ( $uid );
$this -> user_model -> set_last_seen ( $uid );
2025-01-02 10:22:23 +01:00
log_message ( 'info' , " User ID: [ $uid ] logged in successfully with 'Keep Login'. " );
$this -> input -> set_cookie ( 're_login' , '' , - 3600 , '' ); // delete re_login cookie in case this was a re-login from a clubstation or impersonated user
2024-07-11 17:04:57 +02:00
redirect ( 'dashboard' );
2024-07-11 14:17:38 +02:00
} else {
2024-07-11 17:04:57 +02:00
2024-07-11 14:17:38 +02:00
// user not allowed to log in
2024-07-11 17:04:57 +02:00
log_message ( 'debug' , " User ID: [ $uid ] Login rejected because of an active maintenance mode (and he is no admin). " );
2024-07-11 14:17:38 +02:00
// Delete keep_login cookie
2024-09-02 14:25:23 +02:00
$this -> input -> set_cookie ( 'keep_login' , '' , - 3600 , '' );
2025-01-02 10:22:23 +01:00
$this -> input -> set_cookie ( 're_login' , '' , - 3600 , '' );
2024-07-11 17:04:57 +02:00
2024-07-11 14:17:38 +02:00
redirect ( 'user/login' );
}
2024-07-11 17:04:57 +02:00
} else {
// user not allowed to log in
log_message ( 'debug' , " User ID: [ $uid ] Login rejected because of non matching hash key ('Keep Login'). " );
2024-07-11 14:17:38 +02:00
// Delete keep_login cookie
2024-09-02 14:25:23 +02:00
$this -> input -> set_cookie ( 'keep_login' , '' , - 3600 , '' );
2025-01-02 10:22:23 +01:00
$this -> input -> set_cookie ( 're_login' , '' , - 3600 , '' );
2024-07-11 14:17:38 +02:00
$this -> session -> set_flashdata ( 'error' , __ ( " Login failed. Try again. " ));
2025-11-13 21:11:22 +01:00
$this -> output -> set_header ( 'X-Login-Status: failed' );
2025-09-27 10:41:13 +00:00
$this -> output -> _display ();
2024-07-11 14:17:38 +02:00
redirect ( 'user/login' );
}
2024-07-11 17:04:57 +02:00
} catch ( Exception $e ) {
// Something went wrong with the cookie
2026-07-11 17:33:34 +02:00
log_message ( 'error' , " User ID: [ " . ( $uid ? ? 'unknown' ) . " ]; 'Keep Login' failed. Cookie deleted. Message: " . $e );
2024-07-11 17:04:57 +02:00
// Delete keep_login cookie
2024-09-02 14:25:23 +02:00
$this -> input -> set_cookie ( 'keep_login' , '' , - 3600 , '' );
2025-01-02 10:22:23 +01:00
$this -> input -> set_cookie ( 're_login' , '' , - 3600 , '' );
2025-11-13 21:11:22 +01:00
$this -> output -> set_header ( 'X-Login-Status: failed' );
2024-07-11 17:04:57 +02:00
$this -> session -> set_flashdata ( 'error' , __ ( " Login failed. Try again. " ));
2025-09-27 10:41:13 +00:00
$this -> output -> _display ();
2024-07-11 17:04:57 +02:00
redirect ( 'user/login' );
}
2024-08-16 11:05:43 +02:00
2024-07-11 14:17:38 +02:00
}
2023-08-02 06:34:12 +00:00
if ( $this -> form_validation -> run () == FALSE ) {
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Login " );
2024-07-11 14:17:38 +02:00
$data [ 'https_check' ] = $this -> https_check ();
2026-03-18 15:26:31 +01:00
2026-03-08 12:53:52 +01:00
$data [ 'auth_header_enable' ] = $this -> config -> item ( 'auth_header_enable' ) ? ? false ;
2026-03-18 15:26:31 +01:00
if ( $data [ 'auth_header_enable' ]) {
// expecting sso.php in the config folder
$this -> config -> load ( 'sso' , true , true );
}
$data [ 'auth_header_text' ] = $this -> config -> item ( 'auth_header_text' , 'sso' ) ? : '' ;
$data [ 'hide_login_form' ] = ( $data [ 'auth_header_enable' ] && ! ( $this -> config -> item ( 'auth_header_allow_direct_login' , 'sso' ) ? ? true ));
2021-11-08 15:22:17 +00:00
$this -> load -> view ( 'interface_assets/mini_header' , $data );
2011-11-04 17:32:03 +00:00
$this -> load -> view ( 'user/login' );
2019-07-08 19:42:03 +01:00
$this -> load -> view ( 'interface_assets/footer' );
2023-08-02 06:34:12 +00:00
} else {
2025-01-02 10:22:23 +01:00
$login_attempt = $this -> user_model -> login ();
if ( $login_attempt === 1 ) {
2013-03-24 16:42:36 -05:00
$this -> user_model -> update_session ( $data [ 'user' ] -> user_id );
2023-08-02 06:34:12 +00:00
$cookie = array (
2024-08-13 08:30:54 +02:00
'name' => $this -> config -> item ( 'gettext_cookie' , 'gettext' ),
2024-06-06 10:46:12 +02:00
'value' => $data [ 'user' ] -> user_language ,
2024-08-31 12:34:09 +03:00
'expire' => 1000 ,
2023-08-02 06:37:56 +00:00
'secure' => FALSE
2023-08-02 06:34:12 +00:00
);
$this -> input -> set_cookie ( $cookie );
2024-07-11 14:17:38 +02:00
// Create a keep_login cookie
if ( $this -> input -> post ( 'keep_login' ) == '1' ) {
$encrypted_string = $this -> user_model -> keep_cookie_hash ( $data [ 'user' ] -> user_id );
$cookie = array (
'name' => 'keep_login' ,
'value' => $encrypted_string ,
2024-09-02 14:25:23 +02:00
'expire' => 2592000 , // 30 days
2024-07-11 17:43:31 +02:00
'secure' => TRUE ,
'httponly' => TRUE
2024-07-11 14:17:38 +02:00
);
$this -> input -> set_cookie ( $cookie );
}
$this -> user_model -> set_last_seen ( $data [ 'user' ] -> user_id );
2011-08-18 01:31:15 +01:00
redirect ( 'dashboard' );
2025-04-28 11:46:28 +02:00
2025-01-02 10:22:23 +01:00
} else if ( $login_attempt === 2 ) {
$this -> session -> set_flashdata ( 'warning' , __ ( " You can't login to a clubstation directly. Use your personal account instead. " ));
redirect ( 'user/login' );
2025-01-13 09:13:15 +00:00
} else if ( $login_attempt === 3 ) {
2025-01-20 16:31:42 +01:00
$this -> session -> set_flashdata ( 'warning' , __ ( " Your account is locked, due to too many failed login-attempts. Please reset your password. " ));
2025-01-13 09:13:15 +00:00
redirect ( 'user/login' );
2011-08-18 01:31:15 +01:00
} else {
2024-02-25 14:14:18 +01:00
if ( ENVIRONMENT == 'maintenance' ) {
2024-06-09 20:40:03 +02:00
$this -> session -> set_flashdata ( 'notice' , __ ( " Sorry. This instance is currently in maintenance mode. If this message appears unexpectedly or keeps showing up, please contact an administrator. Only administrators are currently allowed to log in. " ));
2024-02-25 14:14:18 +01:00
redirect ( 'user/login' );
} else {
2024-06-09 20:40:03 +02:00
$this -> session -> set_flashdata ( 'error' , __ ( " Incorrect username or password! " ));
2025-09-27 10:41:13 +00:00
$this -> output -> set_header ( 'X-Login-Status: failed' );
$this -> output -> _display ();
2024-02-25 14:14:18 +01:00
redirect ( 'user/login' );
}
2011-08-18 01:31:15 +01:00
}
}
}
2026-05-07 23:25:11 -05:00
function logout ( $custom_message = null , $hard_logout = true , $enable_idp = true ) {
2011-08-18 01:31:15 +01:00
$user_name = $this -> session -> userdata ( 'user_name' );
2024-07-11 14:17:38 +02:00
// Delete keep_login cookie
2025-01-02 10:22:23 +01:00
if ( $hard_logout ) {
$this -> input -> set_cookie ( 're_login' , '' , - 3600 , '' );
$this -> input -> set_cookie ( 'keep_login' , '' , - 3600 , '' );
}
2024-07-11 14:17:38 +02:00
2011-08-18 01:31:15 +01:00
$this -> user_model -> clear_session ();
2025-04-28 11:46:28 +02:00
2025-01-02 10:22:23 +01:00
if ( $custom_message != null && is_array ( $custom_message )) {
$this -> input -> set_cookie ( 'tmp_msg' , json_encode ([ $custom_message [ 0 ], $custom_message [ 1 ]]), 10 , '' );
} else {
$this -> input -> set_cookie ( 'tmp_msg' , json_encode ([ 'notice' , sprintf ( __ ( " User %s logged out. " ), $user_name )]), 10 , '' );
}
2025-04-28 11:46:28 +02:00
2026-05-07 23:25:11 -05:00
if ( $this -> config -> item ( 'auth_header_enable' ) && $enable_idp ) {
2026-03-18 15:26:31 +01:00
$this -> config -> load ( 'sso' , true , true );
$logout = $this -> config -> item ( 'auth_header_url_logout' , 'sso' ) ? : null ;
if ( $logout !== null ) {
redirect ( $logout );
}
2026-03-08 23:28:03 +01:00
}
2024-07-11 14:17:38 +02:00
redirect ( 'user/login' );
2011-08-18 01:31:15 +01:00
}
2022-01-18 15:29:22 +00:00
2025-01-03 09:28:07 +01:00
/**
* First Login Wizard
2025-04-28 11:46:28 +02:00
*
2025-01-03 09:28:07 +01:00
* Form Data to create the first station location
*/
function firstlogin_wizard_form () {
if ( ! $this -> user_model -> authorize ( 3 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'station_name' , __ ( " Station Name " ), 'required' );
$this -> form_validation -> set_rules ( 'station_callsign' , __ ( " Station Callsign " ), 'required' );
$this -> form_validation -> set_rules ( 'station_dxcc' , __ ( " Station DXCC " ), 'required' );
$this -> form_validation -> set_rules ( 'station_cqz' , __ ( " Station CQ Zone " ), 'required' );
$this -> form_validation -> set_rules ( 'station_ituz' , __ ( " Station ITU Zone " ), 'required' );
$this -> form_validation -> set_rules ( 'station_locator' , __ ( " Station Locator " ), 'required' );
$stationdata = [
'user_id' => $this -> session -> userdata ( 'user_id' ),
'station_name' => $this -> input -> post ( 'station_name' , true ),
2025-11-14 17:36:40 +01:00
'station_callsign' => str_replace ( 'Ø' , '0' , trim ( $this -> input -> post ( 'station_callsign' , true ))),
2025-01-03 09:28:07 +01:00
'station_dxcc' => $this -> input -> post ( 'station_dxcc' , true ),
'station_cqz' => $this -> input -> post ( 'station_cqz' , true ),
'station_ituz' => $this -> input -> post ( 'station_ituz' , true ),
'station_locator' => $this -> input -> post ( 'station_locator' , true ),
];
if ( ! $this -> check_locator ( $stationdata [ 'station_locator' ])) {
2025-05-02 15:37:54 +02:00
$this -> session -> set_flashdata ( 'fl_wiz_error' , sprintf ( __ ( " Please check value for grid locator (%s) " ), strtoupper ( $stationdata [ 'station_locator' ])));
2025-01-03 09:28:07 +01:00
redirect ( 'dashboard' );
}
if ( $this -> form_validation -> run () == FALSE ) {
redirect ( 'dashboard' ); // Redirect to dashboard if form validation fails to show the wizard again
} else {
if ( $this -> user_model -> firstlogin_wizard ( $stationdata )) {
$this -> session -> set_flashdata ( 'success' , sprintf ( __ ( " Station created successfully! Welcome to Wavelog! To complete your station setup, click %shere%s. " ), '<a href="' . site_url ( 'stationsetup' ) . '"><u>' , '</u></a>' ));
redirect ( 'dashboard' );
} else {
$this -> session -> set_flashdata ( 'error' , __ ( " Station setup failed! Please set up your station manually. " ));
redirect ( 'stationsetup' );
}
}
}
2022-01-18 15:29:22 +00:00
/**
* Function : forgot_password
2023-08-02 06:34:12 +00:00
*
2022-01-18 15:29:22 +00:00
* Allows users to input an email address and a password will be sent to that address .
2023-08-02 06:34:12 +00:00
*
2022-01-18 15:29:22 +00:00
*/
function forgot_password () {
2024-07-11 21:43:58 +02:00
if ( file_exists ( '.demo' )) {
2022-01-18 15:29:22 +00:00
2024-07-11 21:43:58 +02:00
$this -> session -> set_flashdata ( 'error' , __ ( " Password Reset is disabled on the Demo! " ));
redirect ( 'user/login' );
2022-01-18 15:29:22 +00:00
2024-07-11 21:43:58 +02:00
} else {
2024-08-16 11:05:43 +02:00
2024-07-11 21:43:58 +02:00
$this -> load -> helper ( array ( 'form' , 'url' ));
2022-01-18 15:29:22 +00:00
2024-07-11 21:43:58 +02:00
$this -> load -> library ( 'form_validation' );
2023-08-02 06:34:12 +00:00
2024-07-11 21:43:58 +02:00
$this -> form_validation -> set_rules ( 'email' , 'Email' , 'required' );
2025-07-25 10:34:27 +00:00
$this -> form_validation -> set_rules ( 'email' , 'Email' , 'required|valid_email' );
2022-01-18 15:29:22 +00:00
2024-07-11 21:43:58 +02:00
if ( $this -> form_validation -> run () == FALSE )
{
$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' );
}
else
{
// Check email address exists
2024-10-28 11:03:20 +01:00
$email = $this -> input -> post ( 'email' , TRUE );
2022-01-18 15:29:22 +00:00
2024-10-28 11:03:20 +01:00
$check_email = $this -> user_model -> check_email_address ( $email );
2023-08-02 06:34:12 +00:00
2024-07-11 21:43:58 +02:00
if ( $check_email == TRUE ) {
// Generate password reset code 50 characters long
$this -> load -> helper ( 'string' );
$reset_code = random_string ( 'alnum' , 50 );
2022-01-18 15:29:22 +00:00
2024-10-28 11:03:20 +01:00
$this -> user_model -> set_password_reset_code ( $email , $reset_code );
2022-01-18 16:14:22 +00:00
2024-07-11 21:43:58 +02:00
// Send email with reset code
2022-01-19 14:26:36 +00:00
2024-07-11 21:43:58 +02:00
$this -> data [ 'reset_code' ] = $reset_code ;
$this -> load -> library ( 'email' );
if ( $this -> optionslib -> get_option ( 'emailProtocol' ) == " smtp " ) {
$config = Array (
'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 "
);
2022-01-19 14:26:36 +00:00
2024-07-11 21:43:58 +02:00
$this -> email -> initialize ( $config );
}
2022-01-18 15:29:22 +00:00
2024-10-28 11:03:20 +01:00
$message = $this -> email -> load ( 'email/forgot_password' , $this -> data , $this -> user_model -> get_by_email ( $email ) -> row () -> user_language );
2022-01-18 15:29:22 +00:00
2024-07-11 21:43:58 +02:00
$this -> email -> from ( $this -> optionslib -> get_option ( 'emailAddress' ), $this -> optionslib -> get_option ( 'emailSenderName' ));
2024-10-28 11:03:20 +01:00
$this -> email -> to ( $email );
2022-01-18 15:29:22 +00:00
2024-10-28 13:01:59 +01:00
$this -> email -> subject ( $message [ 'subject' ]);
$this -> email -> message ( $message [ 'body' ]);
2024-07-11 21:43:58 +02:00
if ( ! $this -> email -> send ())
{
// 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-19 14:26:36 +00:00
} else {
2024-07-11 21:43:58 +02:00
// No account found just return to login page
2024-06-09 20:40:03 +02:00
$this -> session -> set_flashdata ( 'notice' , __ ( " Password Reset Processed. " ));
2022-01-19 14:26:36 +00:00
redirect ( 'user/login' );
}
2022-01-18 15:29:22 +00:00
}
}
}
2024-01-01 01:01:10 +01:00
2024-01-04 14:34:40 +01:00
// Send an E-Mail to the user. Function is similar to forgot_password() but will be called by an AJAX
public function admin_send_password_reset () {
header ( 'Content-Type: application/json' );
2024-08-16 11:05:43 +02:00
2024-01-04 13:00:37 +01:00
if ( $this -> input -> is_ajax_request ()) { // just additional, to make sure request is from ajax
if ( $this -> input -> post ( 'submit_allowed' )) {
2024-01-01 01:01:10 +01:00
2024-01-04 14:34:40 +01:00
2024-08-16 10:08:44 +02:00
if ( ! $this -> user_model -> authorize ( 99 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
$query = $this -> user_model -> get_by_id ( $this -> input -> post ( 'user_id' ));
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
$this -> load -> library ( 'form_validation' );
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
$this -> form_validation -> set_rules ( 'id' , 'user_id' , 'required' );
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
$data = $query -> row ();
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
if ( $this -> form_validation -> run () != FALSE )
{
$this -> session -> set_flashdata ( 'notice' , 'Something went wrong! User has no user_id.' );
redirect ( 'user' );
2024-01-01 01:01:10 +01:00
}
2024-01-04 13:00:37 +01:00
else
{
// Check email address exists
$check_email = $this -> user_model -> check_email_address ( $data -> user_email );
2026-03-18 17:36:30 -05:00
// Is local login allowed
$auth_header_enable = $this -> config -> item ( 'auth_header_enable' ) ? ? false ;
if ( $auth_header_enable ) {
$this -> config -> load ( 'sso' , true , true );
}
$auth_header_allow_direct_login = $this -> config -> item ( 'auth_header_allow_direct_login' , 'sso' ) ? ? true ;
if ( $check_email == TRUE && $auth_header_allow_direct_login ) {
2024-01-04 13:00:37 +01: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 ;
$this -> data [ 'user_firstname' ] = $data -> user_firstname ; // We can call the user by his first name in the E-Mail
$this -> data [ 'user_callsign' ] = $data -> user_callsign ;
$this -> data [ 'user_name' ] = $data -> user_name ;
$this -> load -> library ( 'email' );
if ( $this -> optionslib -> get_option ( 'emailProtocol' ) == " smtp " ) {
$config = Array (
'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 "
);
$this -> email -> initialize ( $config );
}
2024-01-01 01:01:10 +01:00
2024-10-28 10:50:32 +01:00
$message = $this -> email -> load ( 'email/admin_reset_password' , $this -> data , $data -> user_language );
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
$this -> email -> from ( $this -> optionslib -> get_option ( 'emailAddress' ), $this -> optionslib -> get_option ( 'emailSenderName' ));
$this -> email -> to ( $data -> user_email );
2024-10-28 13:01:59 +01:00
$this -> email -> subject ( $message [ 'subject' ]);
$this -> email -> message ( $message [ 'body' ]);
2024-01-01 01:01:10 +01:00
2024-01-04 13:00:37 +01:00
if ( ! $this -> email -> send ())
{
2024-01-04 14:34:40 +01:00
echo json_encode ( false );
2024-01-04 13:00:37 +01:00
} else {
2024-01-04 14:34:40 +01:00
echo json_encode ( true );
2024-01-04 13:00:37 +01:00
}
} else {
2024-01-04 14:34:40 +01:00
echo json_encode ( false );
2024-01-04 13:00:37 +01:00
}
2024-01-01 01:01:10 +01:00
}
}
}
}
2022-01-18 16:14:22 +00:00
2024-08-16 09:06:14 +02:00
function reset_password ( $reset_code = NULL ) {
2022-01-18 16:14:22 +00:00
$data [ 'reset_code' ] = $reset_code ;
if ( $reset_code != NULL ) {
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
2023-08-02 06:34:12 +00:00
2022-01-18 16:14:22 +00:00
$this -> form_validation -> set_rules ( 'password' , 'Password' , 'required' );
$this -> form_validation -> set_rules ( 'password_confirm' , 'Password Confirmation' , 'required|matches[password]' );
2023-08-02 06:34:12 +00:00
2022-01-18 16:14:22 +00:00
if ( $this -> form_validation -> run () == FALSE )
{
2024-06-08 11:01:59 +02:00
$data [ 'page_title' ] = __ ( " Reset Password " );
2022-01-18 16:14:22 +00:00
$this -> load -> view ( 'interface_assets/mini_header' , $data );
$this -> load -> view ( 'user/reset_password' );
$this -> load -> view ( 'interface_assets/footer' );
}
else
{
// Lets reset the password!
2023-08-02 06:34:12 +00:00
2022-01-18 16:14:22 +00: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 15:18:50 +02:00
2025-07-25 10:52:27 +00:00
function check_username ( $username ) {
2025-08-03 06:38:51 +00:00
if ( ! ( $this -> user_model -> authorize ( 99 )) && ( $this -> session -> userdata ( 'user_name' ) != $username ) && ( $this -> user_model -> exists ( $username ) > 0 )) {
2025-07-25 10:52:27 +00:00
$this -> form_validation -> set_message ( 'check_username' , sprintf ( __ ( " Couldn't set account to this username. Please try another one than \" %s \" . " ), $username ));
return FALSE ;
} else {
return TRUE ;
}
}
2025-07-25 08:34:03 +00:00
function check_email ( $mail ) {
if (( $this -> session -> userdata ( 'user_email' ) != $mail ) && ( $this -> user_model -> exists_by_email ( $mail ) > 0 )) {
2025-07-25 12:28:22 +02:00
$this -> form_validation -> set_message ( 'check_email' , sprintf ( __ ( " Couldn't set account to this email. Please try another address than \" %s \" . " ), $mail ));
2025-07-25 08:34:03 +00:00
return FALSE ;
} else {
return TRUE ;
}
}
2025-01-03 09:28:07 +01:00
function check_locator ( $grid = '' ) {
if ( empty ( $grid )) {
$grid = $this -> input -> post ( 'locator' , TRUE );
}
2024-08-16 09:06:14 +02:00
// Allow empty locator
2025-07-15 07:03:30 +02:00
if ( preg_match ( '/^$/' , $grid ? ? '' )) return true ;
2025-05-02 13:30:41 +02:00
$this -> load -> library ( 'Qra' );
if ( $this -> qra -> validate_grid ( $grid )) {
return true ;
} else {
2025-05-02 14:26:16 +02:00
$this -> form_validation -> set_message ( 'check_locator' , sprintf ( __ ( " Please check value for grid locator (%s) " ), strtoupper ( $grid )));
2024-08-16 09:06:14 +02:00
return false ;
}
2024-07-11 14:17:38 +02:00
}
2024-08-16 09:06:14 +02:00
function https_check () {
2025-10-10 21:48:44 +02:00
if ( isset ( $_SERVER [ 'HTTPS' ]) && strtolower ( $_SERVER [ 'HTTPS' ]) === 'on' ) {
2024-08-16 09:06:14 +02:00
return true ;
}
2025-10-10 21:48:44 +02:00
if ( ! empty ( $_SERVER [ 'HTTP_X_FORWARDED_PROTO' ]) && strtolower ( $_SERVER [ 'HTTP_X_FORWARDED_PROTO' ]) === 'https' ) {
2024-08-16 09:06:14 +02:00
return true ;
}
2025-10-10 21:48:44 +02:00
if ( ! empty ( $_SERVER [ 'HTTP_X_FORWARDED_SSL' ]) && strtolower ( $_SERVER [ 'HTTP_X_FORWARDED_SSL' ]) === 'on' ) {
2024-08-16 09:06:14 +02:00
return true ;
}
return false ;
2024-07-11 14:17:38 +02:00
}
2024-08-16 09:06:14 +02:00
2024-08-16 20:36:39 +02:00
public function impersonate () {
2024-08-16 09:06:14 +02:00
2024-08-19 21:07:26 +02:00
// Check if impersonating is disabled in the config
if ( $this -> config -> item ( 'disable_impersonate' )) {
2025-01-02 10:22:23 +01:00
$this -> session -> set_flashdata ( 'error' , sprintf ( __ ( " You currently can't impersonate another user. You need to set %s to %s in your config.php! " ), " 'disable_impersonate' " , " 'false' " ));
redirect ( 'dashboard' );
2024-08-19 21:07:26 +02:00
}
2024-08-19 20:35:56 +02:00
// Load the encryption library
if ( ! $this -> load -> is_loaded ( 'encryption' )) {
$this -> load -> library ( 'encryption' );
}
2025-01-02 10:22:23 +01:00
2024-08-19 20:35:56 +02:00
// Precheck: If the encryption key is still default, we can't impersonate another user for security reasons
2024-08-16 11:24:07 +02:00
if ( $this -> config -> item ( 'encryption_key' ) == 'flossie1234555541' ) {
2024-08-17 12:17:16 +02:00
$this -> session -> set_flashdata ( 'error' , __ ( " You currently can't impersonate another user. Please change the encryption_key in your config.php file first! " ));
2024-08-16 11:24:07 +02:00
redirect ( 'dashboard' );
}
2024-08-19 20:35:56 +02:00
// Prepare the hash
$raw_hash = $this -> encryption -> decrypt ( $this -> input -> post ( 'hash' , TRUE ) ? ? '' );
if ( ! $raw_hash ) {
$this -> session -> set_flashdata ( 'error' , __ ( " Invalid Hash " ));
redirect ( 'dashboard' );
}
$hash_parts = explode ( '/' , $raw_hash );
$source_uid = $hash_parts [ 0 ];
$target_uid = $hash_parts [ 1 ];
$timestamp = $hash_parts [ 2 ];
/**
* Security Checks
*/
// make sure the timestamp is not too old
if ( time () - $timestamp > 600 ) { // 10 minutes
$this -> session -> set_flashdata ( 'error' , __ ( " The impersonation hash is too old. Please try again. " ));
redirect ( 'dashboard' );
2024-08-16 09:06:14 +02:00
}
2025-04-28 11:46:28 +02:00
// is the source user still logged in?
2024-08-19 20:35:56 +02:00
// We fetch the source user from database to also make sure the user exists. We could use source_uid directly, but this is more secure
if ( $this -> session -> userdata ( 'user_id' ) != $this -> user_model -> get_by_id ( $source_uid ) -> row () -> user_id ) {
$this -> session -> set_flashdata ( 'error' , __ ( " You can't impersonate another user while you're not logged in as the source user " ));
redirect ( 'dashboard' );
2024-08-16 10:43:40 +02:00
}
2024-08-19 20:35:56 +02:00
// in addition to the check if the user is logged in, we also can check if the session id matches the cookie
if ( $this -> session -> session_id != $this -> input -> cookie ( $this -> config -> item ( 'sess_cookie_name' ), TRUE )) {
$this -> session -> set_flashdata ( 'error' , __ ( " There was a problem with your session. Please try again. " ));
redirect ( 'dashboard' );
}
2024-08-16 09:06:14 +02:00
2024-08-19 20:35:56 +02:00
// make sure the target user exists
$target_user = $this -> user_model -> get_by_id ( $target_uid ) -> row ();
if ( ! $target_user ) {
$this -> session -> set_flashdata ( 'error' , __ ( " The requested user to impersonate does not exist " ));
2024-08-16 09:06:14 +02:00
redirect ( 'dashboard' );
}
2025-01-02 10:22:23 +01:00
// before we can impersonate a user, we need to make sure the current user is allowed to do so
$clubswitch = $this -> input -> post ( 'clubswitch' , TRUE ) ? ? '' ;
$custom_sessiondata = [];
2024-08-19 20:35:56 +02:00
$source_user = $this -> user_model -> get_by_id ( $source_uid ) -> row ();
2025-01-02 10:22:23 +01:00
if ( $clubswitch == 1 ) {
$this -> load -> model ( 'club_model' );
if ( ! $this -> club_model -> club_authorize ( 3 , $target_uid , $source_uid ) || ! $this -> user_model -> authorize ( 3 )) {
$this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " ));
redirect ( 'dashboard' );
} else {
$targetclub = array_filter ( $this -> session -> userdata ( 'available_clubstations' ), function ( $club ) use ( $target_uid ) {
return $club -> user_id == $target_uid ;
});
$p_level = ! empty ( $targetclub ) ? reset ( $targetclub ) -> p_level : null ;
if ( $p_level != null ) {
$custom_sessiondata [ 'p_level' ] = $p_level ;
} else {
$this -> session -> set_flashdata ( 'error' , __ ( " Could not determine the correct permission level for the clubstation. Try again after re-login. " ));
redirect ( 'dashboard' );
}
}
} else {
if ( ! $source_user || ! $this -> user_model -> authorize ( 99 )) {
$this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " ));
2025-04-28 11:46:28 +02:00
redirect ( 'dashboard' );
2025-01-02 10:22:23 +01:00
} else {
$custom_sessiondata [ 'p_level' ] = 99 ; // if the user is an admin he also should have full rights in the clubstations
}
2024-08-19 20:35:56 +02:00
}
2025-01-02 10:22:23 +01:00
$custom_sessiondata [ 'src_call' ] = $source_user -> user_callsign ;
$custom_sessiondata [ 'src_user_type' ] = $source_user -> user_type ;
$custom_sessiondata [ 'src_hash' ] = $this -> input -> post ( 'hash' , TRUE ) ? ? '' ;
2024-08-19 20:35:56 +02:00
/**
* Impersonate the user
*/
2024-08-17 08:40:32 +02:00
// Update the session with the new user_id
2024-08-19 20:35:56 +02:00
// TODO: Find a solution for sessiondata 'radio', so a user would be able to use e.g. his own radio while impersonating another user
2024-08-17 08:40:32 +02:00
// Due the fact that the user is now impersonating another user, he can't use his default radio anymore
2025-01-02 10:22:23 +01:00
$this -> session -> set_userdata ( 'source_uid' , $source_uid );
2025-04-28 11:46:28 +02:00
$this -> user_model -> update_session ( $target_uid , null , true , $custom_sessiondata );
2024-08-17 11:35:30 +02:00
// Redirect to the dashboard, the user should now be logged in as the other user
2024-08-16 09:06:14 +02:00
redirect ( 'dashboard' );
2024-07-11 14:17:38 +02:00
}
2025-01-02 10:22:23 +01:00
public function stop_impersonate_modal () {
if ( ! $this -> user_model -> authorize ( 3 )) { $this -> session -> set_flashdata ( 'error' , __ ( " You're not allowed to do that! " )); redirect ( 'dashboard' ); }
$this -> load -> view ( 'user/modals/stop_impersonate_modal' );
}
public function stop_impersonate () {
// there is no source_uid, there is probably something fishy going on. So we clear the session at this point
$source_uid = $this -> session -> userdata ( 'source_uid' ) ? ? false ;
$post_chk = $this -> input -> post ( 'stopImpersonate' , TRUE ) ? ? false ;
if ( ! $source_uid || $post_chk != 1 ) {
$this -> logout ([ 'error' , __ ( " Ups.. Something went wrong. Try to log back in. " )]);
exit ;
}
// is the current user a clubstation we need to check if the source user was allowed to impersonate the clubstation
$club = $this -> user_model -> get_by_id ( $this -> session -> userdata ( 'user_id' )) -> row ();
$current_is_club = $club -> clubstation == 1 ? true : false ;
$source_user = $this -> user_model -> get_by_id ( $source_uid ) -> row ();
if ( $current_is_club ) {
$this -> load -> model ( 'club_model' );
if ( ! $this -> club_model -> club_authorize ( 3 , $this -> session -> userdata ( 'user_id' ), $source_uid )) {
$this -> logout ([ 'error' , __ ( " Ups.. Something went wrong. Try to log back in. " )]);
exit ;
}
} else {
// if the current user is not a clubstation, we need to check if the source user was allowed to impersonate the current user (has to be an admin)
if ( $source_user -> user_type != 99 ) {
$this -> logout ([ 'error' , __ ( " Ups.. Something went wrong. Try to log back in. " )]);
exit ;
}
}
// Validate the impersonate hash
$this -> load -> library ( 'encryption' );
$raw_hash = $this -> encryption -> decrypt ( $this -> session -> userdata ( 'cd_src_hash' ) ? ? false );
if ( ! $raw_hash ) {
$this -> logout ([ 'error' , __ ( " Ups.. Something went wrong. Try to log back in. " )]);
exit ;
}
$hash_parts = explode ( '/' , $raw_hash );
$src_in_hash = $hash_parts [ 0 ];
$tgt_in_hash = $hash_parts [ 1 ];
$timestamp = $hash_parts [ 2 ];
if ( $src_in_hash != $source_uid || $tgt_in_hash != $this -> session -> userdata ( 'user_id' )) {
$this -> logout ([ 'error' , __ ( " Ups.. Something went wrong. Try to log back in. " )]);
exit ;
}
// The timestamp can't be older then 2 hours
if ( time () - $timestamp > 7200 ) {
$this -> logout ([ 'notice' , __ ( " The ability to return quickly has been disabled after the security hash expired. Please log in again. " )]);
exit ;
}
// Create a keep login cookie which will be used to log back in as the source user
$encrypted_string = $this -> user_model -> keep_cookie_hash ( $source_uid );
$cookie = array (
'name' => 're_login' , // we use a different cookie name to avoid conflicts with the regular keep_login cookie
'value' => $encrypted_string ,
'expire' => 20 , // seconds should be enough
'secure' => FALSE ,
'httponly' => TRUE
);
$this -> input -> set_cookie ( $cookie );
// log out on the regular way
2025-02-18 20:22:44 +01:00
$msg = [ 'notice' , sprintf ( __ ( " You have been logged out of the account %s. Welcome back, %s, to your personal account! " ), $club -> user_callsign , $source_user -> user_callsign )];
2026-05-07 23:25:11 -05:00
$this -> logout ( $msg , false , false );
2025-01-02 10:22:23 +01:00
}
2022-04-04 13:17:33 +02:00
}