From de5c65c121a707fb1cb065e7b722cbaba9b6f0c2 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Fri, 7 May 2021 08:03:25 +0200 Subject: [PATCH] [User selectable columns] Added a fifth column, used only in logbook view. Also fixed a bug when adding user accounts. --- application/config/migration.php | 2 +- application/controllers/User.php | 13 +++++++++- application/language/english/account_lang.php | 1 + .../migrations/070_add_fifth_column.php | 25 +++++++++++++++++++ application/models/User_model.php | 7 +++++- application/views/user/add.php | 15 +++++++++++ application/views/user/edit.php | 13 ++++++++++ .../views/view_log/partial/log_ajax.php | 17 ++++++++++--- 8 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 application/migrations/070_add_fifth_column.php diff --git a/application/config/migration.php b/application/config/migration.php index 82ace1a0..5b216f92 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 69; +$config['migration_version'] = 70; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/User.php b/application/controllers/User.php index ef8908c6..976ea38e 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -70,6 +70,7 @@ class User extends CI_Controller { $data['user_column2'] = $this->input->post('user_column2'); $data['user_column3'] = $this->input->post('user_column3'); $data['user_column4'] = $this->input->post('user_column4'); + $data['user_column5'] = $this->input->post('user_column5'); $this->load->view('user/add', $data); } else { $this->load->view('user/add', $data); @@ -95,7 +96,8 @@ class User extends CI_Controller { $this->input->post('user_column1'), $this->input->post('user_column2'), $this->input->post('user_column3'), - $this->input->post('user_column4'))) { + $this->input->post('user_column4'), + $this->input->post('user_column5'))) { // Check for errors case EUSERNAMEEXISTS: $data['username_error'] = 'Username '.$this->input->post('user_name').' already in use!'; @@ -131,6 +133,7 @@ class User extends CI_Controller { $data['user_column2'] = $this->input->post('user_column2'); $data['user_column3'] = $this->input->post('user_column3'); $data['user_column4'] = $this->input->post('user_column4'); + $data['user_column5'] = $this->input->post('user_column5'); $this->load->view('user/add', $data); $this->load->view('interface_assets/footer'); } @@ -323,6 +326,12 @@ class User extends CI_Controller { $data['user_column4'] = $q->user_column4; } + if($this->input->post('user_column5')) { + $data['user_column5'] = $this->input->post('user_column5', true); + } else { + $data['user_column5'] = $q->user_column5; + } + $this->load->view('user/edit', $data); $this->load->view('interface_assets/footer'); } @@ -370,6 +379,8 @@ class User extends CI_Controller { $data['user_column2'] = $this->input->post('user_column2'); $data['user_column3'] = $this->input->post('user_column3'); $data['user_column4'] = $this->input->post('user_column4'); + $data['user_column4'] = $this->input->post('user_column4'); + $data['user_column5'] = $this->input->post('user_column5'); $this->load->view('user/edit'); $this->load->view('interface_assets/footer'); } diff --git a/application/language/english/account_lang.php b/application/language/english/account_lang.php index 22c1f3e7..7db5d0ed 100644 --- a/application/language/english/account_lang.php +++ b/application/language/english/account_lang.php @@ -7,3 +7,4 @@ $lang['account_column1_text'] = 'Choose column 1'; $lang['account_column2_text'] = 'Choose column 2'; $lang['account_column3_text'] = 'Choose column 3'; $lang['account_column4_text'] = 'Choose column 4'; +$lang['account_column5_text'] = 'Choose column 5 (only for logbook)'; diff --git a/application/migrations/070_add_fifth_column.php b/application/migrations/070_add_fifth_column.php new file mode 100644 index 00000000..745469c7 --- /dev/null +++ b/application/migrations/070_add_fifth_column.php @@ -0,0 +1,25 @@ +dbforge->add_column('users', $fields); + } + + public function down() + { + $this->dbforge->drop_column('users', 'user_column5'); + } +} diff --git a/application/models/User_model.php b/application/models/User_model.php index 6d5f07c4..0652d707 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -96,7 +96,9 @@ class User_Model extends CI_Model { // FUNCTION: bool add($username, $password, $email, $type) // Add a user - function add($username, $password, $email, $type, $firstname, $lastname, $callsign, $locator, $timezone, $measurement, $user_date_format, $user_stylesheet, $user_sota_lookup, $user_show_notes) { + function add($username, $password, $email, $type, $firstname, $lastname, $callsign, $locator, $timezone, + $measurement, $user_date_format, $user_stylesheet, $user_sota_lookup, $user_show_notes, + $user_column1, $user_column2, $user_column3, $user_column4, $user_column5) { // Check that the user isn't already used if(!$this->exists($username)) { $data = array( @@ -118,6 +120,7 @@ class User_Model extends CI_Model { 'user_column2' => xss_clean($user_column2), 'user_column3' => xss_clean($user_column3), 'user_column4' => xss_clean($user_column4), + 'user_column5' => xss_clean($user_column5), ); // Check the password is valid @@ -165,6 +168,7 @@ class User_Model extends CI_Model { 'user_column2' => xss_clean($fields['user_column2']), 'user_column3' => xss_clean($fields['user_column3']), 'user_column4' => xss_clean($fields['user_column4']), + 'user_column5' => xss_clean($fields['user_column5']), ); // Check to see if the user is allowed to change user levels @@ -278,6 +282,7 @@ class User_Model extends CI_Model { 'user_column2' => $u->row()->user_column2, 'user_column3' => $u->row()->user_column3, 'user_column4' => $u->row()->user_column4, + 'user_column5' => $u->row()->user_column5, ); $this->session->set_userdata($userdata); diff --git a/application/views/user/add.php b/application/views/user/add.php index 74aadd86..7157053f 100644 --- a/application/views/user/add.php +++ b/application/views/user/add.php @@ -191,6 +191,21 @@ + + +
+ + +
diff --git a/application/views/user/edit.php b/application/views/user/edit.php index 641c6bc4..3b879e71 100644 --- a/application/views/user/edit.php +++ b/application/views/user/edit.php @@ -378,6 +378,19 @@ +
+ + +
diff --git a/application/views/view_log/partial/log_ajax.php b/application/views/view_log/partial/log_ajax.php index dd46a581..ee0a92c4 100644 --- a/application/views/view_log/partial/log_ajax.php +++ b/application/views/view_log/partial/log_ajax.php @@ -55,9 +55,20 @@ case 'Band': echo $this->lang->line('gen_hamradio_band'); break; } echo ''; - ?> - lang->line('general_word_country'); ?> - config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> + echo ''; + switch($this->session->userdata('user_column5')==""?'Country':$this->session->userdata('user_column5')) { + case 'Mode': echo $this->lang->line('gen_hamradio_mode'); break; + case 'RSTS': echo $this->lang->line('gen_hamradio_rsts'); break; + case 'RSTR': echo $this->lang->line('gen_hamradio_rstr'); break; + case 'Country': echo $this->lang->line('general_word_country'); break; + case 'IOTA': echo $this->lang->line('gen_hamradio_iota'); break; + case 'State': echo $this->lang->line('gen_hamradio_state'); break; + case 'Grid': echo $this->lang->line('gen_hamradio_gridsquare'); break; + case 'Band': echo $this->lang->line('gen_hamradio_band'); break; + } + echo ''; + + if(($this->config->item('use_auth')) && ($this->session->userdata('user_type') >= 2)) { ?> QSL session->userdata('user_eqsl_name') != "") { ?> eQSL