mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
add qso widget configuration into settings
This commit is contained in:
@@ -34,11 +34,6 @@ class Widgets extends CI_Controller {
|
||||
$data['theme'] = "default";
|
||||
}
|
||||
|
||||
// should we show time?
|
||||
// TODO
|
||||
$data['show_time'] = (($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time')));
|
||||
$data['show_time'] = true;
|
||||
|
||||
// determine text size
|
||||
$text_size = $this->input->get('text_size', true) ?? 1;
|
||||
$data['text_size_class'] = $this->prepare_text_size_css_class($text_size);
|
||||
@@ -57,7 +52,6 @@ class Widgets extends CI_Controller {
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('logbooks_model');
|
||||
if($this->logbooks_model->public_slug_exists($logbook_slug)) {
|
||||
// Load the public view
|
||||
|
||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
|
||||
if($logbook_id != false)
|
||||
@@ -73,6 +67,11 @@ class Widgets extends CI_Controller {
|
||||
show_404(__("Unknown Public Page."));
|
||||
}
|
||||
|
||||
// Get widget settings
|
||||
$user_id = $this->logbooks_model->user_id_from_logbook_slug($logbook_slug);
|
||||
$widget_options = $this->get_qso_widget_options($user_id);
|
||||
|
||||
$data['show_time'] = $widget_options->display_qso_time;
|
||||
$data['last_qsos_list'] = $this->logbook_model->get_last_qsos($qso_count, $logbooks_locations_array);
|
||||
|
||||
$this->load->view('widgets/qsos', $data);
|
||||
@@ -221,6 +220,38 @@ class Widgets extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and prepare user options for QSO widget
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
private function get_qso_widget_options($user_id) {
|
||||
$raw_widget_options = $this->user_options_model->get_options('widget', null, $user_id)->result_array();
|
||||
|
||||
// default values
|
||||
$options = new \stdClass();
|
||||
$options->display_qso_time = false;
|
||||
|
||||
if ($raw_widget_options === null) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
foreach ($raw_widget_options as $opt_data) {
|
||||
if ($opt_data["option_name"] !== 'qso') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = $opt_data["option_key"];
|
||||
$value = $opt_data["option_value"];
|
||||
|
||||
if ($key === "display_qso_time") {
|
||||
$options->display_qso_time = $value === "true";
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and prepare user options for on air widget
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user