Partial rollback 8027474f2d remove User_model::add_minimal()

This commit is contained in:
HadleySo
2026-02-21 12:50:37 -06:00
parent 7ffc4b8773
commit a856027574
2 changed files with 72 additions and 77 deletions

View File

@@ -52,23 +52,94 @@ class Header_auth extends CI_Controller
$firstnameHeader = $this->config->item('auth_headers_firstname') ?: '';
if (!empty($firstnameHeader)) {
$firstname = $this->input->server($firstnameHeader, true);
} else {
$firstname = '';
}
$lastnameHeader = $this->config->item('auth_headers_lastname') ?: '';
if (!empty($lastnameHeader)) {
$lastname = $this->input->server($lastnameHeader, true);
} else {
$lastname = '';
}
$callsignHeader = $this->config->item('auth_headers_callsign') ?: '';
if (!empty($callsignHeader)) {
$callsign = $this->input->server($callsignHeader, true);
} else {
$callsign = '';
}
$emailHeader = $this->config->item('auth_headers_email') ?: '';
if (!empty($emailHeader)) {
$email = $this->input->server($emailHeader, true);
} else {
$email = '';
}
$club_id = $this->config->item('auth_header_club_id') ?: '';
$result = $this->user_model->add_minimal($username, $firstname, $lastname, $callsign, $email, $club_id);
$result = $this->user_model->add(
$username,
bin2hex(random_bytes(16)), // password
$email,
3, // $data['user_type'], Anlage auf 3
$firstname,
$lastname,
$callsign,
"", // locator
102, // user_timezone
"M", // measurement
"Y", // dashboard_map
"Y-m-d", // user_date_format
'darkly', // user_stylesheet
'0', // user_qth_lookup
'0', // user_sota_lookup
'0', // user_wwff_lookup
'0', // user_pota_lookup
1, // user_show_notes
'Mode', // user_column1
'RSTS', // user_column2
'RSTR', // user_column3
'Band', // user_column4
'Country', // user_column5
'0', // user_show_profile_image
'0', // user_previous_qsl_type
'0', // user_amsat_status_upload
'', // user_mastodon_url
'ALL', // user_default_band
'QL', // user_default_confirmation
'0', // user_qso_end_times
"Y", // user_qso_db_search_priority
'0', // user_quicklog
'0', // user_quicklog_enter
"en", // 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
0, // user_station_to_qso_tab
'', // user_lotw_name
'', // user_lotw_password
'', // user_eqsl_name
'', // user_eqsl_password
'', // user_clublog_name
'', // user_clublog_password
'0', // user_winkey
"", // on_air_widget_enabled
"", // on_air_widget_display_last_seen
"", // on_air_widget_show_only_most_recent_radio
"", // qso_widget_display_qso_time
"", // dashboard_banner
"", // dashboard_solar
"", // global_oqrs_text
"", // oqrs_grouped_search
"", // oqrs_grouped_search_show_station_name
"", // oqrs_auto_matching
"", // oqrs_direct_auto_matching
"", // user_dxwaterfall_enable
);
switch ($result) {
case EUSERNAMEEXISTS:

View File

@@ -323,82 +323,6 @@ class User_Model extends CI_Model {
}
}
/**
* FUNCTION: bool add_minimal($username, $firstname = null, $lastname = null, $callsign = null, $email = null, $club_id = null)
* Add a user with minimal required fields (username only) with option to add to club as user
*/
function add_minimal($username, $firstname = null, $lastname = null, $callsign = null, $email = null, $club_id = null) {
// Check that the username isn't already used
if(!$this->exists($username)) {
$data = array(
'user_name' => xss_clean($username),
'user_password' => bin2hex(random_bytes(16)), // Random password
'user_email' => xss_clean($email) ?? '',
'user_firstname' => xss_clean($firstname) ?? '',
'user_lastname' => xss_clean($lastname) ?? '',
'user_callsign' => strtoupper(xss_clean($callsign)) ?? '',
'user_type' => 3,
'user_locator' => '',
'user_stylesheet' => 'darkly',
'user_language' => 'english',
'user_timezone' => '1',
'user_date_format' => 'd/m/y',
'user_measurement_base' => 'M',
'user_column1' => 'Mode',
'user_column2' => 'RSTS',
'user_column3' => 'RSTR',
'user_column4' => 'Band',
'user_column5' => 'Country',
'user_qso_end_times' => 0,
'user_show_profile_image' => 0,
'user_qth_lookup' => 0,
'user_sota_lookup' => 0,
'user_wwff_lookup' => 0,
'user_pota_lookup' => 0,
'user_show_notes' => 0,
'user_quicklog' => 0,
'user_quicklog_enter' => 0,
'user_previous_qsl_type' => 0,
'user_default_band' => 'All',
'user_lotw_name' => '',
'user_lotw_password' => '',
'user_eqsl_name' => '',
'user_eqsl_password' => '',
'user_clublog_name' => '',
'user_clublog_password' => '',
'user_amsat_status_upload' => 0,
'user_mastodon_url' => '',
);
// Check the email address isn't in use (if provided)
if($email && $this->exists_by_email($email)) {
return EEMAILEXISTS;
}
// Generate user-slug
if (!$this->load->is_loaded('encryption')) {
$this->load->library('encryption');
}
$user_slug_base = md5($this->encryption->encrypt($username));
$user_slug = substr($user_slug_base, 0, USER_SLUG_LENGTH);
$data['slug'] = $user_slug;
// Add user
$this->db->insert($this->config->item('auth_table'), $data);
$insert_id = $this->db->insert_id();
// Add user to club
if ($club_id && is_numeric($club_id)) {
$this->load->model('club_model');
$this->club_model->alter_member($club_id, $insert_id, 3);
}
return OK;
} else {
return EUSERNAMEEXISTS;
}
}
// FUNCTION: bool edit()
// Edit a user
function edit($fields) {