Fix case when adding new user, make widget url variable in UI conditional to preven php warning

This commit is contained in:
Filip Melík
2025-02-19 20:36:21 +01:00
parent 3f13781ebe
commit 85bc1fa265
3 changed files with 25 additions and 2 deletions

View File

@@ -211,7 +211,8 @@ class User_Model extends CI_Model {
$user_language, $user_hamsat_key, $user_hamsat_workable_only, $user_iota_to_qso_tab, $user_sota_to_qso_tab,
$user_wwff_to_qso_tab, $user_pota_to_qso_tab, $user_sig_to_qso_tab, $user_dok_to_qso_tab,
$user_lotw_name, $user_lotw_password, $user_eqsl_name, $user_eqsl_password, $user_clublog_name, $user_clublog_password,
$user_winkey, $clubstation = 0) {
$user_winkey, $on_air_widget_enabled, $on_air_widget_display_last_seen, $on_air_widget_show_only_most_recent_radio,
$clubstation = 0) {
// Check that the user isn't already used
if(!$this->exists($username)) {
$data = array(
@@ -267,6 +268,15 @@ class User_Model extends CI_Model {
return EEMAILEXISTS;
}
// Generate user-slug
if (!$this->load->is_loaded('encryption')) {
$this->load->library('encryption');
}
$user_slug_base = md5($this->encryption->encrypt($username));
$slug_length = 10;
$user_slug = substr($user_slug_base, 0, $slug_length);
$data['slug'] = $user_slug;
// Add user and insert bandsettings for user
$this->db->insert($this->config->item('auth_table'), $data);
$insert_id = $this->db->insert_id();
@@ -286,6 +296,9 @@ class User_Model extends CI_Model {
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $insert_id . ", 'qso_tab','sig','show',".(xss_clean($user_sig_to_qso_tab ?? 'off') == "on" ? 1 : 0).");");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $insert_id . ", 'qso_tab','dok','show',".(xss_clean($user_dok_to_qso_tab ?? 'off') == "on" ? 1 : 0).");");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $insert_id . ", 'dashboard','show_map','boolean','".xss_clean($fields['user_dashboard_map'] ?? 'Y')."');");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $insert_id . ", 'widget','on_air','enabled','".(xss_clean($on_air_widget_enabled ?? 'false'))."');");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $insert_id . ", 'widget','on_air','display_last_seen','".(xss_clean($on_air_widget_display_last_seen ?? 'false'))."');");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $insert_id . ", 'widget','on_air','display_only_most_recent_radio','".(xss_clean($on_air_widget_show_only_most_recent_radio ?? 'true'))."');");
return OK;
} else {