[Users] Made Date Format defineable in the user profile and changed all the code in the system to follow selection

pull/617/head
Peter Goodhall 2020-09-15 22:04:47 +01:00
rodzic 5bab5dab14
commit 75a4870ad9
11 zmienionych plików z 122 dodań i 12 usunięć

Wyświetl plik

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to. | be upgraded / downgraded to.
| |
*/ */
$config['migration_version'] = 49; $config['migration_version'] = 50;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

Wyświetl plik

@ -235,6 +235,12 @@ class User extends CI_Controller {
$data['user_measurement_base'] = $q->user_measurement_base; $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('user/edit', $data);
$this->load->view('interface_assets/footer'); $this->load->view('interface_assets/footer');

Wyświetl plik

@ -0,0 +1,20 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_add_dateformat_to_users extends CI_Migration {
public function up()
{
$fields = array(
'user_date_format varchar(15) DEFAULT \'d/m/y\'',
);
$this->dbforge->add_column('users', $fields);
}
public function down()
{
$this->dbforge->drop_column('users', 'user_date_format');
}
}

Wyświetl plik

@ -148,6 +148,7 @@ class User_Model extends CI_Model {
'user_eqsl_name' => xss_clean($fields['user_eqsl_name']), 'user_eqsl_name' => xss_clean($fields['user_eqsl_name']),
'user_clublog_name' => xss_clean($fields['user_clublog_name']), 'user_clublog_name' => xss_clean($fields['user_clublog_name']),
'user_measurement_base' => xss_clean($fields['user_measurement_base']), '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 // 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"]:"", 'radio' => isset($_COOKIE["radio"])?$_COOKIE["radio"]:"",
'station_profile_id' => isset($_COOKIE["station_profile_id"])?$_COOKIE["station_profile_id"]:"", 'station_profile_id' => isset($_COOKIE["station_profile_id"])?$_COOKIE["station_profile_id"]:"",
'user_measurement_base' => $u->row()->user_measurement_base, 'user_measurement_base' => $u->row()->user_measurement_base,
'user_date_format' => $u->row()->user_date_format,
); );
$this->session->set_userdata($userdata); $this->session->set_userdata($userdata);

Wyświetl plik

@ -51,7 +51,21 @@
$i = 0; $i = 0;
foreach ($last_five_qsos->result() as $row) { ?> foreach ($last_five_qsos->result() as $row) { ?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?> <?php echo '<tr class="tr'.($i & 1).'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?></td>
<?php
// Get Date format
if($this->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');
}
?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> <?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<?php } else { ?> <?php } else { ?>

Wyświetl plik

@ -32,6 +32,18 @@
<canvas id="myChartDiff" width="400" height="150"></canvas> <canvas id="myChartDiff" width="400" height="150"></canvas>
<h2>Longest streak with QSOs in the log</h2> <h2>Longest streak with QSOs in the log</h2>
<p>A maximum of the 10 longest streaks are shown!</p> <p>A maximum of the 10 longest streaks are shown!</p>
<?php
// Get Date format
if($this->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');
}
?>
<?php <?php
if (is_array($streaks)) { if (is_array($streaks)) {
echo '<div id="streaks" class="table-responsive"><table class="qsotable table table-bordered table-hover table-striped table-condensed">'; echo '<div id="streaks" class="table-responsive"><table class="qsotable table table-bordered table-hover table-striped table-condensed">';
@ -45,8 +57,10 @@
foreach ($streaks as $streak) { foreach ($streaks as $streak) {
echo '<tr>'; echo '<tr>';
echo '<td style=\'text-align: center\'>' . $streak['highstreak'] . '</td>'; echo '<td style=\'text-align: center\'>' . $streak['highstreak'] . '</td>';
echo '<td style=\'text-align: center\'>' . $streak['beginstreak'] . '</td>'; $beginstreak_newdate = strtotime($streak['beginstreak']);
echo '<td style=\'text-align: center\'>' . $streak['endstreak'] . '</td>'; echo '<td style=\'text-align: center\'>' . date($custom_date_format, $beginstreak_newdate) . '</td>';
$endstreak_newdate = strtotime($streak['endstreak']);
echo '<td style=\'text-align: center\'>' . date($custom_date_format, $endstreak_newdate) . '</td>';
echo '</tr>'; echo '</tr>';
} }

Wyświetl plik

@ -29,6 +29,17 @@
</fieldset> </fieldset>
</form> </form>
<?php
// Get Date format
if($this->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');
}
?>
<?php <?php
$i = count($dxcc_timeline_array); $i = count($dxcc_timeline_array);
if ($dxcc_timeline_array) { if ($dxcc_timeline_array) {
@ -47,9 +58,10 @@
<tbody>'; <tbody>';
foreach ($dxcc_timeline_array as $line) { foreach ($dxcc_timeline_array as $line) {
$date_as_timestamp = strtotime($line->date);
echo '<tr> echo '<tr>
<td>' . $i-- . '</td> <td>' . $i-- . '</td>
<td>' . $line->date . '</td> <td>' . date($custom_date_format, $date_as_timestamp) . '</td>
<td>' . $line->prefix . '</td> <td>' . $line->prefix . '</td>
<td>' . $line->col_country . '</td> <td>' . $line->col_country . '</td>
<td>'; <td>';

Wyświetl plik

@ -133,9 +133,20 @@
<?php echo form_dropdown('user_timezone', $timezones, $user_timezone); ?> <?php echo form_dropdown('user_timezone', $timezones, $user_timezone); ?>
</div> </div>
<div class="form-group">
<label for="SelectDateFormat">Date Format</label>
<select name="user_date_format" class="form-control" id="SelectDateFormat" aria-describedby="SelectDateFormatHelp">
<option value="d/m/y" <?php if($user_date_format == "d/m/y") { echo "selected=\"selected\""; } ?>><?php echo date('d/m/y'); ?></option>
<option value="d/m/Y" <?php if($user_date_format == "d/m/Y") { echo "selected=\"selected\""; } ?>><?php echo date('d/m/Y'); ?></option>
<option value="m/d/y" <?php if($user_date_format == "m/d/y") { echo "selected=\"selected\""; } ?>><?php echo date('m/d/y'); ?></option>
<option value="m/d/Y" <?php if($user_date_format == "m/d/Y") { echo "selected=\"selected\""; } ?>><?php echo date('m/d/Y'); ?></option>
</select>
<small id="SelectDateFormatHelp" class="form-text text-muted">Select how you would like dates shown when logged into your account.</small>
</div>
<div class="form-group"> <div class="form-group">
<label for="user_measurement_base">Measurement preference</label> <label for="user_measurement_base">Measurement preference</label>
<select class="custom-select" id="user_measurement_base" name="user_measurement_base" required> <select class="custom-select" id="user_measurement_base" name="user_measurement_base" aria-describedby="user_measurement_base_Help" required>
<option value='K' <?php if($user_measurement_base == "K") { echo "selected=\"selected\""; } ?>>Kilometers</option> <option value='K' <?php if($user_measurement_base == "K") { echo "selected=\"selected\""; } ?>>Kilometers</option>
<option value='M' <?php if($user_measurement_base == "M") { echo "selected=\"selected\""; } ?>>Miles</option> <option value='M' <?php if($user_measurement_base == "M") { echo "selected=\"selected\""; } ?>>Miles</option>
<option value='N' <?php if($user_measurement_base == "N") { echo "selected=\"selected\""; } ?>>Nautical miles</option> <option value='N' <?php if($user_measurement_base == "N") { echo "selected=\"selected\""; } ?>>Nautical miles</option>

Wyświetl plik

@ -25,9 +25,18 @@
</tr> </tr>
<?php $i = 0; foreach ($results->result() as $row) { ?> <?php $i = 0; foreach ($results->result() as $row) { ?>
<?php
// Get Date format
if($this->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');
}
?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?> <?php echo '<tr class="tr'.($i & 1).'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> <?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<?php } ?> <?php } ?>

Wyświetl plik

@ -25,9 +25,18 @@
</tr> </tr>
<?php $i = 0; foreach ($results->result() as $row) { ?> <?php $i = 0; foreach ($results->result() as $row) { ?>
<?php
// Get Date format
if($this->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');
}
?>
<?php echo '<tr class="tr'.($i & 1).'" id ="qso_'. $row->COL_PRIMARY_KEY .'">'; ?> <?php echo '<tr class="tr'.($i & 1).'" id ="qso_'. $row->COL_PRIMARY_KEY .'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> <?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<?php } ?> <?php } ?>

Wyświetl plik

@ -12,11 +12,24 @@
<table width="100%"> <table width="100%">
<tr> <tr>
<?php
// Get Date format
if($this->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');
}
?>
<td>Date/Time:</td> <td>Date/Time:</td>
<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> <?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); $timestamp = strtotime($row->COL_TIME_ON); echo " at ".date('H:i', $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); $timestamp = strtotime($row->COL_TIME_ON); echo " at ".date('H:i', $timestamp); ?></td>
<?php } else { ?> <?php } else { ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($this->config->item('qso_date_format'), $timestamp); ?></td> <td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td>
<?php } ?> <?php } ?>
</tr> </tr>