* * GlobalNotify Admin Setup Page */ // Load Dolibarr environment $res = 0; if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; dol_include_once('/globalnotify/class/globalnotify.class.php'); /** * @var Conf $conf * @var DoliDB $db * @var Translate $langs * @var User $user */ $langs->loadLangs(array("admin", "globalnotify@globalnotify")); // Access control if (!$user->admin) { accessforbidden(); } $action = GETPOST('action', 'aZ09'); /* * Actions */ if ($action == 'clearall') { // Clear all notifications $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name LIKE 'GLOBALNOTIFY_%'"; $db->query($sql); setEventMessages("Alle Benachrichtigungen gelöscht", null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } if ($action == 'resetcronjobs') { // Reset all stuck cron jobs $sql = "UPDATE ".MAIN_DB_PREFIX."cronjob SET processing = 0 WHERE processing = 1"; $resql = $db->query($sql); $affected = $db->affected_rows($resql); setEventMessages("{$affected} Cron-Jobs zurückgesetzt", null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } /* * View */ $page_name = "GlobalNotify - ".$langs->trans("Settings"); llxHeader('', $page_name); print load_fiche_titre($page_name, '', 'title_setup'); // Get all notifications $notify = new GlobalNotify($db); $allNotifications = $notify->getAllNotifications(0, false); // All, including read // Get stuck cron jobs $sql = "SELECT rowid, label, module_name, datelastrun, processing, status FROM ".MAIN_DB_PREFIX."cronjob WHERE status = 1 ORDER BY processing DESC, label"; $resql = $db->query($sql); print '
| Cron-Job | '; print 'Modul | '; print 'Status | '; print 'Letzter Lauf | '; print '
|---|---|---|---|
| '.$obj->label.' | '; print ''.($obj->module_name ?: '-').' | '; print ''; if ($obj->processing) { print 'HÄNGT'; } else { print 'OK'; } print ' | '; print ''.dol_print_date($db->jdate($obj->datelastrun), 'dayhour').' | '; print '
| Benachrichtigungen ('.count($allNotifications).') | '; print 'Modul | '; print 'Typ | '; print 'Datum | '; print 'Status | '; print '
|---|---|---|---|---|
| Keine Benachrichtigungen | ||||
| ';
print ''.dol_escape_htmltag($notif['title']).' '; print ''.dol_escape_htmltag($notif['message']).''; if (!empty($notif['action_url'])) { print ' '.$notif['action_label'].''; } print ' | ';
print ''.$notif['module'].' | '; print ''; $typeLabels = array( 'error' => 'Fehler', 'warning' => 'Warnung', 'info' => 'Info', 'success' => 'Erfolg', 'action' => 'Aktion', ); print $typeLabels[$notif['type']] ?? $notif['type']; print ' | '; print ''.dol_print_date($notif['created'], 'dayhour').' | '; print ''; if (!empty($notif['read'])) { print 'Gelesen'; } else { print 'Ungelesen'; } print ' | '; print '