diff --git a/core/ajax/update.ajax.php b/core/ajax/update.ajax.php
index 6e138c8d91..27e626bf9a 100644
--- a/core/ajax/update.ajax.php
+++ b/core/ajax/update.ajax.php
@@ -65,6 +65,7 @@
if (init('action') == 'checkAllUpdate') {
unautorizedInDemo();
update::checkAllUpdate();
+ update::refreshUpdateMessage();
ajax::success();
}
@@ -81,6 +82,7 @@
}
$update->doUpdate();
if ($update->getType() != 'core') {
+ update::refreshUpdateMessage();
log::add('update', 'alert', __("Launch cron dependancy plugins", __FILE__));
try {
$cron = cron::byClassAndFunction('plugin', 'checkDeamon');
@@ -124,6 +126,7 @@
throw new Exception(__('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id'));
}
$update->checkUpdate();
+ update::refreshUpdateMessage();
ajax::success();
}
diff --git a/core/class/jeedom.class.php b/core/class/jeedom.class.php
index 4fbe7170e3..2f1f466fad 100644
--- a/core/class/jeedom.class.php
+++ b/core/class/jeedom.class.php
@@ -1223,21 +1223,7 @@ public static function cronHourly() {
//Check for updates every 24h according to config
if (config::byKey('update::autocheck', 'core', 1) == 1 && (config::byKey('update::lastCheck') == '' || (strtotime('now') - strtotime(config::byKey('update::lastCheck'))) > (23 * 3600) || strtotime('now') < strtotime(config::byKey('update::lastCheck')))) {
update::checkAllUpdate();
- $updates = update::byStatus('update');
- if (count($updates) > 0) {
- $toUpdate = '';
- foreach ($updates as $update) {
- if ($update->getConfiguration('doNotUpdate', 0) == 0) {
- $toUpdate .= $update->getLogicalId() . ',';
- }
- }
- if ($toUpdate != '') {
- //set $_logicalId so update function can remove such messages. Bypassed by message::save to notify different updates instead of new occurence.
- $msg = __('De nouvelles mises à jour sont disponibles', __FILE__) . ' : ' . trim($toUpdate, ',');
- $action = '' . __('Centre de mise à jour', __FILE__) . '';
- message::add('update', $msg, $action, 'newUpdate');
- }
- }
+ update::refreshUpdateMessage();
}
} catch (\Throwable $e) {
log::add('jeedom', 'error', log::exception($e));
diff --git a/core/class/update.class.php b/core/class/update.class.php
index ffbde4fb6f..8e88d234c2 100644
--- a/core/class/update.class.php
+++ b/core/class/update.class.php
@@ -143,6 +143,27 @@ public static function updateAll($_filter = '') {
}
}
+ public static function refreshUpdateMessage() {
+ $toUpdate = [];
+ foreach (self::byStatus('update') as $update) {
+ if ($update->getConfiguration('doNotUpdate', 0) == 0) {
+ $toUpdate[] = $update->getLogicalId();
+ }
+ }
+ if (!empty($toUpdate)) {
+ $msg = __('De nouvelles mises à jour sont disponibles', __FILE__) . ' : ' . implode(', ', $toUpdate);
+ $action = '' . __('Centre de mise à jour', __FILE__) . '';
+ foreach (message::byPlugin(__CLASS__) as $updateMessage) {
+ if ($updateMessage->getMessage() !== $msg) {
+ $updateMessage->remove();
+ }
+ }
+ message::add(__CLASS__, $msg, $action, 'newUpdate');
+ } else {
+ message::removeAll(__CLASS__);
+ }
+ }
+
public static function byId($_id) {
$values = array(
'id' => $_id,
diff --git a/install/update.php b/install/update.php
index d828647034..f702960061 100644
--- a/install/update.php
+++ b/install/update.php
@@ -348,9 +348,9 @@
}
echo "[PROGRESS][90]\n";
try {
- message::removeAll('update', 'newUpdate');
echo "Check update\n";
update::checkAllUpdate();
+ update::refreshUpdateMessage();
echo "OK\n";
} catch (Exception $ex) {
echo "***ERROR*** " . $ex->getMessage() . "\n";