mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 02:14:13 +00:00
turn version check config around so users don't need to add the config item
This commit is contained in:
@@ -695,4 +695,16 @@ $config['disable_impersonate'] = false;
|
||||
|
|
||||
*/
|
||||
|
||||
$config['cron_allow_insecure'] = false;
|
||||
$config['cron_allow_insecure'] = false;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Update / version check
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
| This config switch disables the check for newer releases on github and
|
||||
| hides the banner to admin users if a newer release as published.
|
||||
| Default ON.
|
||||
*/
|
||||
|
||||
$config['disable_version_check'] = false;
|
||||
@@ -31,7 +31,7 @@ class Debug extends CI_Controller
|
||||
$data['latest_release'] = $this->optionslib->get_option('latest_release');
|
||||
|
||||
$data['newer_version_available'] = false;
|
||||
if ($this->config->item('version_check')) {
|
||||
if (!$this->config->item('disable_version_check') ?? false) {
|
||||
$this->Update_model->update_check(true);
|
||||
if ($data['latest_release'] && version_compare($data['latest_release'], $data['running_version'], '>')) {
|
||||
$data['newer_version_available'] = true;
|
||||
|
||||
@@ -427,7 +427,11 @@ class Update extends CI_Controller {
|
||||
$this->optionslib->update('tle_update', $datetime , 'no');
|
||||
}
|
||||
|
||||
function wavelog_update_check() {
|
||||
function version_check() {
|
||||
// set the last run in cron table for the correct cron id
|
||||
$this->load->model('cron_model');
|
||||
$this->cron_model->set_last_run($this->router->class . '_' . $this->router->method);
|
||||
|
||||
$this->load->model('Update_model');
|
||||
$this->Update_model->update_check();
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Migration_add_version_check_to_cron extends CI_Migration {
|
||||
public function up() {
|
||||
if ($this->chk4cron('version_check') == 0) {
|
||||
if ($this->chk4cron('update_version_check') == 0) {
|
||||
$data = array(
|
||||
array(
|
||||
'id' => 'version_check',
|
||||
'id' => 'update_version_check',
|
||||
'enabled' => '0',
|
||||
'status' => 'pending',
|
||||
'description' => 'Check for new Wavelog releases',
|
||||
'function' => 'index.php/update/wavelog_update_check',
|
||||
'function' => 'index.php/update/version_check',
|
||||
'expression' => '45 4 * * *',
|
||||
'last_run' => null,
|
||||
'next_run' => null
|
||||
@@ -20,8 +20,8 @@ class Migration_add_version_check_to_cron extends CI_Migration {
|
||||
}
|
||||
|
||||
public function down() {
|
||||
if ($this->chk4cron('version_check') > 0) {
|
||||
$this->db->query("delete from cron where id='version_check'");
|
||||
if ($this->chk4cron('update_version_check') > 0) {
|
||||
$this->db->query("delete from cron where id='update_version_check'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -291,14 +291,18 @@ class Update_model extends CI_Model {
|
||||
}
|
||||
|
||||
function update_check($silent = false) {
|
||||
if ($this->config->item('version_check')) {
|
||||
if (!$this->config->item('disable_version_check') ?? false) {
|
||||
$running_version = $this->optionslib->get_option('version');
|
||||
$latest_release = $this->wavelog_latest_release();
|
||||
$this->set_latest_release($latest_release);
|
||||
if (version_compare($latest_release, $running_version, '>')) {
|
||||
if (!$silent) {
|
||||
print __("Newer release available:")." ".$latest_release;
|
||||
}
|
||||
$this->set_latest_release($latest_release);
|
||||
} else {
|
||||
if (!$silent) {
|
||||
print __("You are running the latest version.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ function echo_table_col($row, $name) {
|
||||
<?= __("You need to upgrade your PHP version. Minimum version is 7.4. Your version is") . ' ' . PHP_VERSION . '.';?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if(($this->session->userdata('user_type') == 99) && $this->config->item('version_check') && $this->optionslib->get_option('latest_release')) { ?>
|
||||
<?php if(($this->session->userdata('user_type') == 99) && !($this->config->item('disable_version_check') ?? false) && $this->optionslib->get_option('latest_release')) { ?>
|
||||
<?php if (version_compare($this->optionslib->get_option('latest_release'), $this->optionslib->get_option('version'), '>')) { ?>
|
||||
<div class="alert alert-success" role="alert" style="margin-top: 1rem;">
|
||||
<?= sprintf(_pgettext("Dashboard Warning", "A new version of Wavelog has been published. See: %s."), "<a href=\"https://github.com/wavelog/wavelog/releases/tag/".$this->optionslib->get_option('latest_release')."\" target=\"_blank\">Release ".$this->optionslib->get_option('latest_release')."</a>"); ?>
|
||||
<?= sprintf(_pgettext("Dashboard Warning", "A new version of Wavelog has been published. See: %s."), "<a href=\"https://github.com/wavelog/wavelog/releases/tag/".$this->optionslib->get_option('latest_release')."\" target=\"_blank\"><u>Release ".$this->optionslib->get_option('latest_release')."</u></a>"); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
@@ -702,9 +702,9 @@ $config['cron_allow_insecure'] = false;
|
||||
| Update / version check
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
| This config switch enabled the check for newer releases on github and
|
||||
| displays a banner to admin users if a newer release as published.
|
||||
| Default on.
|
||||
| This config switch disables the check for newer releases on github and
|
||||
| hides the banner to admin users if a newer release as published.
|
||||
| Default ON.
|
||||
*/
|
||||
|
||||
$config['version_check'] = true;
|
||||
$config['disable_version_check'] = false;
|
||||
|
||||
Reference in New Issue
Block a user