diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 index 7e95de1..82c311f --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Alle wesentlichen Änderungen an diesem Projekt werden in dieser Datei dokumentiert. +## [1.4.0] - 2026-03-03 + +### Neu +- **Automatisches Entfernen von Cron-Notifications**: Benachrichtigungen für deaktivierte Cronjobs werden automatisch als gelesen markiert und verschwinden aus dem Widget + +### Verbessert +- Deaktivieren eines Cronjobs ermöglicht jetzt das Schließen der zugehörigen "Cron-Job verpasst"-Meldung + ## [1.3.0] - 2026-02-23 ### Neu diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/admin/setup.php b/admin/setup.php old mode 100644 new mode 100755 diff --git a/ajax/action.php b/ajax/action.php old mode 100644 new mode 100755 diff --git a/class/actions_globalnotify.class.php b/class/actions_globalnotify.class.php old mode 100644 new mode 100755 index a7901b9..e122907 --- a/class/actions_globalnotify.class.php +++ b/class/actions_globalnotify.class.php @@ -283,6 +283,11 @@ class ActionsGlobalNotify extends CommonHookActions } dolibarr_set_const($this->db, 'GLOBALNOTIFY_CRON_LASTCHECK', time(), 'chaine', 0, '', $conf->entity); + $notify = new GlobalNotify($this->db); + + // Clean up: Remove notifications for disabled cronjobs + $this->cleanupDisabledCronNotifications($notify); + // Find all stuck cron jobs (processing=1 for more than 30 minutes) $sql = "SELECT rowid, label, module_name, datelastrun, processing FROM ".MAIN_DB_PREFIX."cronjob @@ -295,8 +300,6 @@ class ActionsGlobalNotify extends CommonHookActions return; } - $notify = new GlobalNotify($this->db); - while ($obj = $this->db->fetch_object($resql)) { $module = !empty($obj->module_name) ? strtolower($obj->module_name) : 'cron'; $lastRun = $this->db->jdate($obj->datelastrun); @@ -367,6 +370,57 @@ class ActionsGlobalNotify extends CommonHookActions } } + /** + * Remove cron notifications for disabled cronjobs + * This ensures users can dismiss notifications by disabling the cronjob + * + * @param GlobalNotify $notify GlobalNotify instance + */ + private function cleanupDisabledCronNotifications($notify) + { + global $conf; + + $existing = $notify->getModuleNotifications('cron'); + if (empty($existing)) { + return; + } + + // Get all disabled cronjobs + $disabledJobs = array(); + $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."cronjob WHERE status != 1"; + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $disabledJobs[$obj->rowid] = $obj->label; + } + } + + if (empty($disabledJobs)) { + return; + } + + // Mark notifications for disabled jobs as read + $changed = false; + foreach ($existing as &$notif) { + if (!empty($notif['read'])) { + continue; + } + // Check if notification is about a disabled job + foreach ($disabledJobs as $jobId => $jobLabel) { + if (strpos($notif['message'], $jobLabel) !== false || strpos($notif['title'], $jobLabel) !== false) { + $notif['read'] = true; + $changed = true; + break; + } + } + } + + if ($changed) { + $key = 'GLOBALNOTIFY_CRON'; + dolibarr_set_const($this->db, $key, json_encode($existing), 'chaine', 0, '', $conf->entity); + } + } + /** * Check BankImport module for issues */ diff --git a/class/globalnotify.class.php b/class/globalnotify.class.php old mode 100644 new mode 100755 diff --git a/core/modules/modGlobalNotify.class.php b/core/modules/modGlobalNotify.class.php old mode 100644 new mode 100755 index 9aed673..f0de24e --- a/core/modules/modGlobalNotify.class.php +++ b/core/modules/modGlobalNotify.class.php @@ -42,7 +42,7 @@ class modGlobalNotify extends DolibarrModules $this->descriptionlong = "Provides a unified notification bell in the top bar that collects and displays alerts from any module (cron errors, warnings, action required, etc.)"; $this->editor_name = 'Data IT Solution'; $this->editor_url = 'https://data-it-solution.de'; - $this->version = '1.3.0'; + $this->version = '1.4.0'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'bell'; diff --git a/css/globalnotify.css b/css/globalnotify.css old mode 100644 new mode 100755 diff --git a/js/globalnotify.js b/js/globalnotify.js old mode 100644 new mode 100755 diff --git a/langs/de_DE/globalnotify.lang b/langs/de_DE/globalnotify.lang old mode 100644 new mode 100755 diff --git a/langs/en_US/globalnotify.lang b/langs/en_US/globalnotify.lang old mode 100644 new mode 100755