Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/ajax/update.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
if (init('action') == 'checkAllUpdate') {
unautorizedInDemo();
update::checkAllUpdate();
update::refreshUpdateMessage();
ajax::success();
}

Expand All @@ -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');
Expand Down Expand Up @@ -124,6 +126,7 @@
throw new Exception(__('Aucune correspondance pour l\'ID :', __FILE__) . ' ' . init('id'));
}
$update->checkUpdate();
update::refreshUpdateMessage();
ajax::success();
}

Expand Down
16 changes: 1 addition & 15 deletions core/class/jeedom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<a href="/index.php?v=d&p=update">' . __('Centre de mise à jour', __FILE__) . '</a>';
message::add('update', $msg, $action, 'newUpdate');
}
}
update::refreshUpdateMessage();
}
} catch (\Throwable $e) {
log::add('jeedom', 'error', log::exception($e));
Expand Down
21 changes: 21 additions & 0 deletions core/class/update.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<a href="/index.php?v=d&p=update">' . __('Centre de mise à jour', __FILE__) . '</a>';
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,
Expand Down
2 changes: 1 addition & 1 deletion install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading