From 75a4870ad90eeb2d492ef6aa256a5c38ef26cbf9 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Tue, 15 Sep 2020 22:04:47 +0100 Subject: [PATCH] [Users] Made Date Format defineable in the user profile and changed all the code in the system to follow selection --- application/config/migration.php | 2 +- application/controllers/User.php | 6 ++++++ .../050_add_dateformat_to_users.php | 20 +++++++++++++++++++ application/models/User_model.php | 2 ++ application/views/dashboard/index.php | 16 ++++++++++++++- application/views/dayswithqso/index.php | 18 +++++++++++++++-- application/views/timeline/index.php | 14 ++++++++++++- application/views/user/edit.php | 13 +++++++++++- application/views/view_log/partial/log.php | 13 ++++++++++-- .../views/view_log/partial/log_ajax.php | 13 ++++++++++-- application/views/view_log/qso.php | 17 ++++++++++++++-- 11 files changed, 122 insertions(+), 12 deletions(-) create mode 100644 application/migrations/050_add_dateformat_to_users.php diff --git a/application/config/migration.php b/application/config/migration.php index 2522a204..73ae30f1 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'] = 49; +$config['migration_version'] = 50; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/User.php b/application/controllers/User.php index 129b6904..00c9d59b 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -235,6 +235,12 @@ class User extends CI_Controller { $data['user_measurement_base'] = $q->user_measurement_base; } + + if($this->input->post('user_date_format')) { + $data['user_date_format'] = $this->input->post('user_date_format', true); + } else { + $data['user_date_format'] = $q->user_date_format; + } $this->load->view('user/edit', $data); $this->load->view('interface_assets/footer'); diff --git a/application/migrations/050_add_dateformat_to_users.php b/application/migrations/050_add_dateformat_to_users.php new file mode 100644 index 00000000..764be2aa --- /dev/null +++ b/application/migrations/050_add_dateformat_to_users.php @@ -0,0 +1,20 @@ +dbforge->add_column('users', $fields); + } + + public function down() + { + $this->dbforge->drop_column('users', 'user_date_format'); + } +} \ No newline at end of file diff --git a/application/models/User_model.php b/application/models/User_model.php index 30c4ffee..e751f308 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -148,6 +148,7 @@ class User_Model extends CI_Model { 'user_eqsl_name' => xss_clean($fields['user_eqsl_name']), 'user_clublog_name' => xss_clean($fields['user_clublog_name']), 'user_measurement_base' => xss_clean($fields['user_measurement_base']), + 'user_date_format' => xss_clean($fields['user_date_format']), ); // Check to see if the user is allowed to change user levels @@ -253,6 +254,7 @@ class User_Model extends CI_Model { 'radio' => isset($_COOKIE["radio"])?$_COOKIE["radio"]:"", 'station_profile_id' => isset($_COOKIE["station_profile_id"])?$_COOKIE["station_profile_id"]:"", 'user_measurement_base' => $u->row()->user_measurement_base, + 'user_date_format' => $u->row()->user_date_format, ); $this->session->set_userdata($userdata); diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index bc4e7f05..2cb62260 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -51,7 +51,21 @@ $i = 0; foreach ($last_five_qsos->result() as $row) { ?> '; ?> - COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?> + + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + + ?> + + COL_TIME_ON); echo date($custom_date_format, $timestamp); ?> config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> COL_TIME_ON); echo date('H:i', $timestamp); ?> diff --git a/application/views/dayswithqso/index.php b/application/views/dayswithqso/index.php index fc905ab8..13c8e9e3 100644 --- a/application/views/dayswithqso/index.php +++ b/application/views/dayswithqso/index.php @@ -32,6 +32,18 @@

Longest streak with QSOs in the log

A maximum of the 10 longest streaks are shown!

+ + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + ?> + '; @@ -45,8 +57,10 @@ foreach ($streaks as $streak) { echo ''; echo ''; - echo ''; - echo ''; + $beginstreak_newdate = strtotime($streak['beginstreak']); + echo ''; + $endstreak_newdate = strtotime($streak['endstreak']); + echo ''; echo ''; } diff --git a/application/views/timeline/index.php b/application/views/timeline/index.php index cd9e64de..2374cd03 100644 --- a/application/views/timeline/index.php +++ b/application/views/timeline/index.php @@ -29,6 +29,17 @@ + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + ?> + '; foreach ($dxcc_timeline_array as $line) { + $date_as_timestamp = strtotime($line->date); echo ' - + result() as $row) { ?> - + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + ?> '; ?> - + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> diff --git a/application/views/view_log/partial/log_ajax.php b/application/views/view_log/partial/log_ajax.php index 0c41b062..b1830c77 100644 --- a/application/views/view_log/partial/log_ajax.php +++ b/application/views/view_log/partial/log_ajax.php @@ -25,9 +25,18 @@ result() as $row) { ?> - + session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + ?> COL_PRIMARY_KEY .'">'; ?> - + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 2d8a554c..f35d47b9 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -12,11 +12,24 @@
' . $streak['highstreak'] . '' . $streak['beginstreak'] . '' . $streak['endstreak'] . '' . date($custom_date_format, $beginstreak_newdate) . '' . date($custom_date_format, $endstreak_newdate) . '
' . $i-- . '' . $line->date . '' . date($custom_date_format, $date_as_timestamp) . ' ' . $line->prefix . ' ' . $line->col_country . ' '; diff --git a/application/views/user/edit.php b/application/views/user/edit.php index 21f6d013..80f40b5e 100644 --- a/application/views/user/edit.php +++ b/application/views/user/edit.php @@ -133,9 +133,20 @@ +
+ + + Select how you would like dates shown when logged into your account. +
+
- diff --git a/application/views/view_log/partial/log.php b/application/views/view_log/partial/log.php index 1483d904..272e3944 100644 --- a/application/views/view_log/partial/log.php +++ b/application/views/view_log/partial/log.php @@ -25,9 +25,18 @@
COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?>COL_TIME_ON); echo date($custom_date_format, $timestamp); ?> COL_TIME_ON); echo date('H:i', $timestamp); ?>
COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?>COL_TIME_ON); echo date($custom_date_format, $timestamp); ?> COL_TIME_ON); echo date('H:i', $timestamp); ?>
+ session->userdata('user_date_format')) { + // If Logged in and session exists + $custom_date_format = $this->session->userdata('user_date_format'); + } else { + // Get Default date format from /config/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + + ?> + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> - + - +
Date/Time: COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); $timestamp = strtotime($row->COL_TIME_ON); echo " at ".date('H:i', $timestamp); ?>COL_TIME_ON); echo date($custom_date_format, $timestamp); $timestamp = strtotime($row->COL_TIME_ON); echo " at ".date('H:i', $timestamp); ?> COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?>COL_TIME_ON); echo date($custom_date_format, $timestamp); ?>