add interval for external update-check; add parameter 'force' to Froxlor.checkUpdate() API call; fix session/language update when changing language
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -254,6 +254,7 @@ if ($page == 'overview') {
|
||||
'id' => $userinfo['adminid'],
|
||||
'def_language' => $def_language
|
||||
])->update();
|
||||
CurrentUser::setField('language', $def_language);
|
||||
} catch (Exception $e) {
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ if ($page == 'overview') {
|
||||
'id' => $userinfo['customerid'],
|
||||
'def_language' => $def_language
|
||||
])->update();
|
||||
CurrentUser::setField('language', $def_language);
|
||||
} catch (Exception $e) {
|
||||
Response::dynamicError($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
}
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
|
||||
Update::showUpdateStep("Cleaning up old files");
|
||||
$to_clean = array(
|
||||
"install/lib",
|
||||
@@ -134,6 +133,7 @@ if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
$system_distribution = isset($_POST['system_distribution']) ? $_POST['system_distribution'] : '';
|
||||
Settings::AddNew("system.distribution", $system_distribution);
|
||||
Settings::AddNew("system.update_channel", 'stable');
|
||||
Settings::AddNew("system.updatecheck_data", '');
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Update::showUpdateStep("Adjusting existing settings");
|
||||
@@ -152,9 +152,5 @@ if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
Settings::Set('panel.standardlanguage', $lang_map[Settings::Get('panel_standardlanguage')] ?? 'en');
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
|
||||
if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
Update::showUpdateStep("Updating from 0.10.99 to 0.11.0-dev1", false);
|
||||
Froxlor::updateToVersion('0.11.0-dev1');
|
||||
}
|
||||
Froxlor::updateToVersion('0.11.0-dev1');
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ use Froxlor\Database\Database;
|
||||
use Froxlor\Database\IntegrityCheck;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Install\AutoUpdate;
|
||||
use Froxlor\Install\Update;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\SImExporter;
|
||||
use Froxlor\System\Cronjob;
|
||||
@@ -49,9 +50,13 @@ use ReflectionMethod;
|
||||
class Froxlor extends ApiCommand
|
||||
{
|
||||
|
||||
const UPDATE_CHECK_INTERVAL = 21600; // 6 hrs
|
||||
|
||||
/**
|
||||
* checks whether there is a newer version of froxlor available
|
||||
*
|
||||
* @param bool $force optional, force live update-check
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @throws Exception
|
||||
@@ -60,50 +65,62 @@ class Froxlor extends ApiCommand
|
||||
{
|
||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
|
||||
|
||||
// log our actions
|
||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] checking for updates");
|
||||
$uc_data = Update::getUpdateCheckData();
|
||||
|
||||
// check for new version
|
||||
$aucheck = AutoUpdate::checkVersion();
|
||||
$force_ucheck = $this->getBoolParam('force', true, 0);
|
||||
$response = $uc_data['data'];
|
||||
|
||||
if ($aucheck == 1) {
|
||||
// anzeige über version-status mit ggfls. formular
|
||||
// zum update schritt #1 -> download
|
||||
$text = 'There is a newer ' . (Settings::Get('system.update_channel') == 'testing' ? 'testing ' : '') . 'version available: "' . AutoUpdate::getFromResult('version') . '" (Your current version is: ' . $this->version . ')';
|
||||
return $this->response([
|
||||
'isnewerversion' => (int) !AutoUpdate::getFromResult('has_latest'),
|
||||
'version' => $this->version,
|
||||
'message' => $text,
|
||||
'link' => AutoUpdate::getFromResult('url'),
|
||||
'additional_info' => AutoUpdate::getFromResult('info')
|
||||
]);
|
||||
} else if ($aucheck < 0 || $aucheck > 1) {
|
||||
// errors
|
||||
if ($aucheck < 0) {
|
||||
$errmsg = AutoUpdate::getLastError();
|
||||
} else {
|
||||
if ($aucheck == 3) {
|
||||
$errmsg = lng('error.customized_version');
|
||||
if (empty($uc_data) || $uc_data['ts'] + self::UPDATE_CHECK_INTERVAL < time() || $uc_data['channel'] != Settings::Get('system.update_channel') || $force_ucheck) {
|
||||
// log our actions
|
||||
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] checking for updates");
|
||||
|
||||
// check for new version
|
||||
$aucheck = AutoUpdate::checkVersion();
|
||||
|
||||
$response = [];
|
||||
if ($aucheck == 1) {
|
||||
// anzeige über version-status mit ggfls. formular
|
||||
// zum update schritt #1 -> download
|
||||
$text = lng('update.uc_newinfo', [(Settings::Get('system.update_channel') == 'testing' ? 'testing ' : ''), AutoUpdate::getFromResult('version'), $this->version]);
|
||||
$response = [
|
||||
'isnewerversion' => (int) !AutoUpdate::getFromResult('has_latest'),
|
||||
'version' => $this->version,
|
||||
'message' => $text,
|
||||
'link' => AutoUpdate::getFromResult('url'),
|
||||
'additional_info' => AutoUpdate::getFromResult('info')
|
||||
];
|
||||
} else if ($aucheck < 0 || $aucheck > 1) {
|
||||
// errors
|
||||
if ($aucheck < 0) {
|
||||
$errmsg = AutoUpdate::getLastError();
|
||||
} else {
|
||||
$errmsg = lng('error.autoupdate_' . $aucheck);
|
||||
if ($aucheck == 3) {
|
||||
$errmsg = lng('error.customized_version');
|
||||
} else {
|
||||
$errmsg = lng('error.autoupdate_' . $aucheck);
|
||||
}
|
||||
}
|
||||
$response = [
|
||||
'isnewerversion' => 0,
|
||||
'version' => $this->version,
|
||||
'message' => '',
|
||||
'link' => '',
|
||||
'additional_info' => $errmsg
|
||||
];
|
||||
} else {
|
||||
$response = [
|
||||
'isnewerversion' => 0,
|
||||
'version' => $this->version,
|
||||
'message' => '',
|
||||
'link' => '',
|
||||
'additional_info' => lng('update.noupdatesavail', [(Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '')])
|
||||
];
|
||||
}
|
||||
return $this->response([
|
||||
'isnewerversion' => 0,
|
||||
'version' => $this->version,
|
||||
'message' => '',
|
||||
'link' => '',
|
||||
'additional_info' => $errmsg
|
||||
]);
|
||||
} else {
|
||||
return $this->response([
|
||||
'isnewerversion' => 0,
|
||||
'version' => $this->version,
|
||||
'message' => '',
|
||||
'link' => '',
|
||||
'additional_info' => lng('update.noupdatesavail', [(Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '')])
|
||||
]);
|
||||
|
||||
Update::storeUpdateCheckData($response);
|
||||
}
|
||||
|
||||
return $this->response($response);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Froxlor\Install;
|
||||
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Settings;
|
||||
|
||||
class Update
|
||||
{
|
||||
@@ -106,4 +107,24 @@ class Update
|
||||
|
||||
return Froxlor::versionCompare2($current_version, $version_to_check) == -1;
|
||||
}
|
||||
|
||||
public static function storeUpdateCheckData(array $response)
|
||||
{
|
||||
$data = [
|
||||
'ts' => time(),
|
||||
'channel' => Settings::Get('system.update_channel'),
|
||||
'data' => $response
|
||||
];
|
||||
Settings::Set('system.updatecheck_data', json_encode($data));
|
||||
}
|
||||
|
||||
public static function getUpdateCheckData()
|
||||
{
|
||||
$uc_data = Settings::Get('system.updatecheck_data');
|
||||
if (!empty($uc_data)) {
|
||||
$data = json_decode($uc_data, true);
|
||||
return $data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,5 +119,6 @@ class Language
|
||||
public static function setLanguage(string $string)
|
||||
{
|
||||
self::$requestedLanguage = $string;
|
||||
self::$lng = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2116,6 +2116,7 @@ Vielen Dank, Ihr Administrator',
|
||||
],
|
||||
'noupdatesavail' => 'Die genutzte %sVersion von Froxlor ist aktuell.',
|
||||
'description' => 'Aktualisierung der froxlor Datenbank',
|
||||
'uc_newinfo' => 'Eine neuere %sVersion ist verfügbar: "%s" (Aktuell installierte Version: %s)',
|
||||
],
|
||||
'usersettings' => [
|
||||
'custom_notes' => [
|
||||
|
||||
@@ -2501,6 +2501,7 @@ Yours sincerely, your administrator',
|
||||
],
|
||||
'noupdatesavail' => 'You already have the latest %sversion of Froxlor installed.',
|
||||
'description' => 'Running database updates for your froxlor installation',
|
||||
'uc_newinfo' => 'There is a newer %sversion available: "%s" (Your current version is: %s)',
|
||||
],
|
||||
'usersettings' => [
|
||||
'custom_notes' => [
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<form id="search" method="post">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="fa fa-search text-muted"></i>
|
||||
<input title="search" type="search" class="search-input" placeholder="Search for ...">
|
||||
<input title="search" type="search" class="search-input" placeholder="{{ lng('panel.search') }}...">
|
||||
</div>
|
||||
<div class="search-results-box" style="display:none;">
|
||||
<div class="search-results list-group-flush"></div>
|
||||
|
||||
Reference in New Issue
Block a user