diff --git a/application/controllers/Debug.php b/application/controllers/Debug.php index 397f4f456..2d126c301 100644 --- a/application/controllers/Debug.php +++ b/application/controllers/Debug.php @@ -28,8 +28,8 @@ class Debug extends CI_Controller $footerData['scripts'] = ['assets/js/sections/debug.js']; $data['running_version'] = $this->optionslib->get_option('version'); - $data['latest_release'] = $this->Update_model->wavelog_latest_release(); - if (version_compare($data['latest_release'], $data['running_version'], '>')) { + $data['latest_release'] = $this->optionslib->get_option('latest_release'); + if ($data['latest_release'] && version_compare($data['latest_release'], $data['running_version'], '>')) { $data['newer_version_available'] = true; } else { $data['newer_version_available'] = false; diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 3cd5d4180..9de022838 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -427,5 +427,16 @@ class Update extends CI_Controller { $this->optionslib->update('tle_update', $datetime , 'no'); } + function wavelog_update_check() { + if ($this->config->item('version_check')) { + $this->load->model('Update_model'); + $running_version = $this->optionslib->get_option('version'); + $latest_release = $this->Update_model->wavelog_latest_release(); + if (version_compare($latest_release, $running_version, '>')) { + print __("Newer release available:")." ".$latest_release; + $this->Update_model->set_latest_release($latest_release); + } + } + } } ?> diff --git a/application/models/Update_model.php b/application/models/Update_model.php index d1d45bfc7..d07180ae5 100644 --- a/application/models/Update_model.php +++ b/application/models/Update_model.php @@ -274,4 +274,19 @@ class Update_model extends CI_Model { $latest_tag = $json[0]['tag_name']; return $latest_tag; } + + function set_latest_release($release) { + $this->db->select('option_value'); + $this->db->where('option_name', 'latest_release'); + $query = $this->db->get('options'); + if ($query->num_rows() > 0) { + $this->db->where('option_name', 'latest_release'); + $this->db->update('options', array('option_value' => $release)); + } else { + $data = array( + array('option_name' => "latest_release", 'option_value' => $release, 'autoload' => "yes"), + ); + $this->db->insert_batch('options', $data); + } + } } diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 4d3e130ca..2510cb254 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -58,6 +58,13 @@ function echo_table_col($row, $name) { + session->userdata('user_type') == 99) && $this->config->item('version_check') && $this->optionslib->get_option('latest_release')) { ?> + optionslib->get_option('latest_release'), $this->optionslib->get_option('version'), '>')) { ?> + + +