new features
This commit is contained in:
parent
9fcd228eb2
commit
a73358d2f1
9 changed files with 538 additions and 2 deletions
|
|
@ -80,6 +80,21 @@ h2 { margin-top: 1.4em; }
|
|||
|
||||
a { color: var(--link); }
|
||||
|
||||
/* Aktuelle Mitteilung auf der Startseite (große Schrift) */
|
||||
.announcement {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.6em;
|
||||
font-weight: 700;
|
||||
color: var(--pitch-dark);
|
||||
background: #fffbe6;
|
||||
border: 2px solid var(--gold);
|
||||
border-left: 8px solid var(--gold);
|
||||
border-radius: 8px;
|
||||
padding: 0.8em 1em;
|
||||
margin: 0 0 1.5em;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
/* Sprungziele (#round-…, #playerid_…) nicht unter der fixierten Navigation verstecken */
|
||||
[id] { scroll-margin-top: 90px; }
|
||||
a:hover { color: var(--pitch-dark); }
|
||||
|
|
@ -126,6 +141,23 @@ a:hover { color: var(--pitch-dark); }
|
|||
|
||||
.nav-user { margin-left: auto; }
|
||||
|
||||
/* Menüpunkt "Fragen": animiertes Leuchten bei neuen Fragen/Antworten */
|
||||
@keyframes nav-glow {
|
||||
0%, 100% {
|
||||
box-shadow: 0 0 0 rgba(242, 194, 48, 0);
|
||||
background-color: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 12px 3px rgba(242, 194, 48, 0.9);
|
||||
background-color: rgba(242, 194, 48, 0.45);
|
||||
color: #3d2d00;
|
||||
}
|
||||
}
|
||||
.site-nav a.is-glowing {
|
||||
animation: nav-glow 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Dropdowns in der Navigation (Administration, Info, Spielermenü) */
|
||||
.nav-dropdown { position: relative; display: inline-block; }
|
||||
.nav-dropdown-content {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use App\Models\Quota;
|
|||
use App\Models\Roundmail;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Team;
|
||||
use App\Models\Question;
|
||||
|
||||
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
$page = $_GET['page'] ?? null;
|
||||
|
|
@ -49,6 +50,7 @@ if ($page === 'reminder') {
|
|||
$appUrl = getenv('APP_URL') ?: ((!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost'));
|
||||
// Aufräumen läuft bei jedem Aufruf, auch wenn keine Erinnerung fällig ist
|
||||
echo Roundmail::deleteOldReminders() . " alte Erinnerungen gelöscht.\n";
|
||||
echo Question::deleteOld() . " alte Fragen/Antworten gelöscht.\n";
|
||||
echo Roundmail::sendReminder($appUrl) . "\n";
|
||||
} catch (\Throwable $e) {
|
||||
http_response_code(500);
|
||||
|
|
@ -323,6 +325,24 @@ if ($page === 'reminder') {
|
|||
}
|
||||
$moneyRanking = $result ? Ranking::moneyRanking($result, true) : [];
|
||||
require __DIR__ . '/../src/Views/admin/accounts.php';
|
||||
} elseif ($page === 'admin_message') {
|
||||
// Aktuelle Mitteilung für die Startseite (nur Admins)
|
||||
Auth::requireLogin();
|
||||
Auth::requireAdmin();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
Setting::setMessage($_POST['message'] ?? '');
|
||||
$_SESSION['admin_message'] = 'Die aktuelle Mitteilung wurde gespeichert.';
|
||||
header('Location: /index.php?page=admin_message');
|
||||
exit;
|
||||
}
|
||||
|
||||
$flashMessage = $_SESSION['admin_message'] ?? null;
|
||||
$error = $_SESSION['admin_error'] ?? null;
|
||||
unset($_SESSION['admin_message'], $_SESSION['admin_error']);
|
||||
$currentMessage = Setting::getMessage();
|
||||
|
||||
require __DIR__ . '/../src/Views/admin/message.php';
|
||||
} elseif ($page === 'settings') {
|
||||
// Eigene Spielerdaten (Legacy UsersController::useredit / storeUserEdit)
|
||||
Auth::requireLogin();
|
||||
|
|
@ -848,10 +868,76 @@ if ($page === 'reminder') {
|
|||
http_response_code(500);
|
||||
echo "<p style='color:red;'>Fehler: " . htmlspecialchars($e->getMessage()) . "</p>";
|
||||
}
|
||||
} elseif ($page === 'questions') {
|
||||
// Fragen an die Admins (Legacy: kein direkter Vorgänger, neu für 2027)
|
||||
Auth::requireLogin();
|
||||
$user = Auth::user();
|
||||
$isAdmin = (bool)$user['admin'];
|
||||
|
||||
$message = $_SESSION['questions_message'] ?? null;
|
||||
$error = $_SESSION['questions_error'] ?? null;
|
||||
unset($_SESSION['questions_message'], $_SESSION['questions_error']);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['action'] ?? '';
|
||||
$redirect = '/index.php?page=questions';
|
||||
|
||||
if ($action === 'ask') {
|
||||
$questionText = trim($_POST['question'] ?? '');
|
||||
if ($questionText === '') {
|
||||
$_SESSION['questions_error'] = 'Bitte gib eine Frage ein.';
|
||||
} else {
|
||||
Question::create((int)$user['id'], $questionText);
|
||||
$_SESSION['questions_message'] = 'Deine Frage wurde an die Admins gesendet.';
|
||||
}
|
||||
} elseif ($action === 'answer') {
|
||||
if (!$isAdmin) {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
$questionId = (int)($_POST['id'] ?? 0);
|
||||
$answerText = trim($_POST['answer'] ?? '');
|
||||
$question = Question::findById($questionId);
|
||||
if (!$question) {
|
||||
$_SESSION['questions_error'] = 'Frage nicht gefunden.';
|
||||
} elseif ($question['answer'] !== null) {
|
||||
$_SESSION['questions_error'] = 'Die Frage wurde bereits beantwortet.';
|
||||
} elseif ($answerText === '') {
|
||||
$_SESSION['questions_error'] = 'Bitte gib eine Antwort ein.';
|
||||
$redirect .= '&answer_id=' . $questionId;
|
||||
} else {
|
||||
Question::answer($questionId, $answerText, (int)$user['id']);
|
||||
$_SESSION['questions_message'] = 'Antwort wurde gespeichert.';
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ' . $redirect);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Beim Ansehen werden die eigenen Antworten (und für Admins auch die
|
||||
// offenen Fragen) als gesehen markiert.
|
||||
Question::markAnswersSeen((int)$user['id']);
|
||||
if ($isAdmin) {
|
||||
Question::markQuestionsSeen();
|
||||
}
|
||||
|
||||
$questions = $isAdmin ? Question::findAllForAdmin() : Question::findByUser((int)$user['id']);
|
||||
|
||||
$answerQuestion = null;
|
||||
if ($isAdmin && isset($_GET['answer_id'])) {
|
||||
$answerQuestion = Question::findById((int)$_GET['answer_id']);
|
||||
if (!$answerQuestion || $answerQuestion['answer'] !== null) {
|
||||
$answerQuestion = null;
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../src/Views/questions.php';
|
||||
} elseif ($page === 'home') {
|
||||
Auth::requireLogin();
|
||||
try {
|
||||
$currentSeason = Season::getCurrent();
|
||||
$message = Setting::getMessage();
|
||||
|
||||
if ($currentSeason) {
|
||||
$rounds = [];
|
||||
|
|
|
|||
174
tippspiel/src/Models/Question.php
Normal file
174
tippspiel/src/Models/Question.php
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Core\Database;
|
||||
|
||||
/**
|
||||
* Fragen der Spieler an die Admins inklusive der Antworten.
|
||||
* Beantwortete Fragen werden für den fragenden Spieler, offene Fragen für die
|
||||
* Admins als "neu" markiert, bis sie auf der Fragenseite angesehen wurden.
|
||||
*/
|
||||
class Question {
|
||||
|
||||
/** Fragen und Antworten werden nach so vielen Jahren automatisch gelöscht */
|
||||
const RETENTION_YEARS = 1;
|
||||
|
||||
/**
|
||||
* Legt eine neue Frage an.
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $question
|
||||
* @return int ID
|
||||
*/
|
||||
public static function create($userId, $question) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"INSERT INTO questions (user_id, question, question_date, created_at, updated_at)
|
||||
VALUES (?, ?, NOW(), NOW(), NOW())"
|
||||
);
|
||||
$stmt->execute([(int)$userId, $question]);
|
||||
return (int)$db->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Fragen eines Spielers, neueste zuerst.
|
||||
*
|
||||
* @param int $userId
|
||||
* @return array
|
||||
*/
|
||||
public static function findByUser($userId) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT * FROM questions WHERE user_id = ? ORDER BY question_date DESC, id DESC"
|
||||
);
|
||||
$stmt->execute([(int)$userId]);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Fragen für die Admin-Ansicht (offene zuerst), mit Name des Fragestellers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function findAllForAdmin() {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT q.*, COALESCE(u.name, '?') AS user_name
|
||||
FROM questions q
|
||||
LEFT JOIN users u ON u.id = q.user_id
|
||||
ORDER BY (q.answer IS NULL) DESC, q.question_date DESC, q.id DESC"
|
||||
);
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array|false
|
||||
*/
|
||||
public static function findById($id) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT q.*, COALESCE(u.name, '?') AS user_name
|
||||
FROM questions q
|
||||
LEFT JOIN users u ON u.id = q.user_id
|
||||
WHERE q.id = ?"
|
||||
);
|
||||
$stmt->execute([(int)$id]);
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Beantwortet eine Frage und markiert die Antwort für den Spieler als neu.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $answer
|
||||
* @param int $adminId
|
||||
* @return bool
|
||||
*/
|
||||
public static function answer($id, $answer, $adminId) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"UPDATE questions
|
||||
SET answer = ?, answer_date = NOW(), answered_by = ?, answer_seen = 0, updated_at = NOW()
|
||||
WHERE id = ?"
|
||||
);
|
||||
return $stmt->execute([$answer, (int)$adminId, (int)$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt es für einen Spieler eine noch nicht angesehene Antwort?
|
||||
*
|
||||
* @param int $userId
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasNewAnswer($userId) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT COUNT(*) FROM questions WHERE user_id = ? AND answer IS NOT NULL AND answer_seen = 0"
|
||||
);
|
||||
$stmt->execute([(int)$userId]);
|
||||
return (int)$stmt->fetchColumn() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt es eine noch nicht von einem Admin angesehene offene Frage?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasNewQuestion() {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT COUNT(*) FROM questions WHERE answer IS NULL AND question_seen = 0"
|
||||
);
|
||||
$stmt->execute();
|
||||
return (int)$stmt->fetchColumn() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Markiert alle beantworteten Fragen eines Spielers als angesehen.
|
||||
*
|
||||
* @param int $userId
|
||||
* @return int
|
||||
*/
|
||||
public static function markAnswersSeen($userId) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"UPDATE questions SET answer_seen = 1, updated_at = NOW()
|
||||
WHERE user_id = ? AND answer IS NOT NULL AND answer_seen = 0"
|
||||
);
|
||||
$stmt->execute([(int)$userId]);
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Markiert alle offenen Fragen als von Admins angesehen.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function markQuestionsSeen() {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"UPDATE questions SET question_seen = 1, updated_at = NOW()
|
||||
WHERE answer IS NULL AND question_seen = 0"
|
||||
);
|
||||
$stmt->execute();
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht Fragen (und damit ihre Antworten), die älter als RETENTION_YEARS Jahre sind.
|
||||
*
|
||||
* @return int Anzahl gelöschter Fragen
|
||||
*/
|
||||
public static function deleteOld() {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"DELETE FROM questions
|
||||
WHERE question_date < CURDATE() - INTERVAL " . (int)self::RETENTION_YEARS . " YEAR"
|
||||
);
|
||||
$stmt->execute();
|
||||
return $stmt->rowCount();
|
||||
}
|
||||
}
|
||||
|
|
@ -42,4 +42,39 @@ class Setting {
|
|||
$stmt = $db->prepare("UPDATE settings SET registration_open = ?, updated_at = NOW() WHERE id = ?");
|
||||
return $stmt->execute([$open ? 1 : 0, $settingsId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktuelle Mitteilung für die Startseite (leer = keine Mitteilung).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getMessage() {
|
||||
$db = Database::getConnection();
|
||||
$value = $db->query("SELECT message FROM settings ORDER BY id LIMIT 1")->fetchColumn();
|
||||
return $value === false ? '' : (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt (oder löscht) die aktuelle Mitteilung für die Startseite.
|
||||
*
|
||||
* @param string $message
|
||||
* @return bool
|
||||
*/
|
||||
public static function setMessage($message) {
|
||||
$db = Database::getConnection();
|
||||
$message = trim((string)$message);
|
||||
$settingsId = $db->query("SELECT id FROM settings ORDER BY id LIMIT 1")->fetchColumn();
|
||||
|
||||
if ($settingsId === false) {
|
||||
$current = Season::getCurrent();
|
||||
$stmt = $db->prepare(
|
||||
"INSERT INTO settings (current_season_id, registration_open, message, created_at, updated_at)
|
||||
VALUES (?, ?, ?, NOW(), NOW())"
|
||||
);
|
||||
return $stmt->execute([$current ? (int)$current['id'] : 0, 1, $message]);
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("UPDATE settings SET message = ?, updated_at = NOW() WHERE id = ?");
|
||||
return $stmt->execute([$message, $settingsId]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
34
tippspiel/src/Views/admin/message.php
Normal file
34
tippspiel/src/Views/admin/message.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
$pageTitle = 'Aktuelle Mitteilung';
|
||||
require __DIR__ . '/../partials/header.php';
|
||||
?>
|
||||
|
||||
<h1>Aktuelle Mitteilung</h1>
|
||||
|
||||
<?php if (!empty($flashMessage)): ?>
|
||||
<p style="color: green;"><?php echo htmlspecialchars($flashMessage); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($error)): ?>
|
||||
<p style="color: red;"><?php echo htmlspecialchars($error); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p>Die Mitteilung erscheint in großer Schrift oben auf der Startseite. Leer lassen und speichern entfernt die Mitteilung.</p>
|
||||
|
||||
<form method="post" action="/index.php?page=admin_message" class="message-form">
|
||||
<div class="form-group">
|
||||
<label for="message">Mitteilung:</label>
|
||||
<textarea id="message" name="message" rows="8"><?php echo htmlspecialchars($currentMessage); ?></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.message-form { max-width: 760px; }
|
||||
.message-form .form-group { margin-bottom: 1rem; }
|
||||
.message-form label { display: block; font-weight: bold; margin-bottom: 0.3rem; }
|
||||
.message-form textarea { width: 100%; box-sizing: border-box; font-size: 1.2em; }
|
||||
</style>
|
||||
|
||||
<?php require __DIR__ . '/../partials/footer.php'; ?>
|
||||
|
|
@ -7,6 +7,10 @@ require __DIR__ . '/partials/header.php';
|
|||
|
||||
<h1>Willkommen bei Tippspiel 2027</h1>
|
||||
|
||||
<?php if (!empty($message)): ?>
|
||||
<div class="announcement"><?php echo nl2br(htmlspecialchars($message)); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2>Abgeschlossene Runden:</h2>
|
||||
<?php if ($currentSeason): ?>
|
||||
<p>Saison: <strong><?php echo htmlspecialchars($currentSeason['name']); ?></strong></p>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,16 @@
|
|||
<?php $pageTitle = $pageTitle ?? 'Tippspiel 2027'; ?>
|
||||
<?php
|
||||
$pageTitle = $pageTitle ?? 'Tippspiel 2027';
|
||||
|
||||
// Leucht-Hinweis am Menüpunkt "Fragen", wenn eine neue Antwort oder (für
|
||||
// Admins) eine neue Frage vorliegt.
|
||||
$questionsGlow = false;
|
||||
if (App\Core\Auth::check()) {
|
||||
$questionsGlow = App\Models\Question::hasNewAnswer((int)App\Core\Auth::id());
|
||||
if (App\Core\Auth::isAdmin()) {
|
||||
$questionsGlow = $questionsGlow || App\Models\Question::hasNewQuestion();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
|
|
@ -14,9 +26,10 @@
|
|||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
</head>
|
||||
<body class="<?php echo htmlspecialchars($bodyClass ?? ''); ?>">
|
||||
<?php if (App\Core\Auth::check()): ?>
|
||||
<nav class="site-nav">
|
||||
<a href="/" class="brand"><span class="brand-ball">⚽</span> Tippspiel <span class="brand-year">2027</span></a>
|
||||
<a href="/">Start</a>
|
||||
<a href="/index.php?page=questions"<?php if ($questionsGlow): ?> class="is-glowing"<?php endif; ?>>Fragen</a>
|
||||
<?php if (App\Core\Auth::isAdmin()): $registrationOpen = App\Models\Setting::isRegistrationOpen(); ?>
|
||||
<span class="nav-dropdown">
|
||||
<a href="#" onclick="return false;">Administration</a>
|
||||
|
|
@ -26,6 +39,7 @@
|
|||
<a href="/index.php?page=admin_rounds">Spiele & Ergebnisse eintragen</a>
|
||||
<a href="/index.php?page=admin_roundmails">Runden-E-Mails versenden</a>
|
||||
<a href="/index.php?page=admin_accounts">Kontoliste</a>
|
||||
<a href="/index.php?page=admin_message">Aktuelle Mitteilung</a>
|
||||
<form method="post" action="/index.php?page=admin" class="nav-dropdown-form">
|
||||
<input type="hidden" name="action" value="set_registration">
|
||||
<input type="hidden" name="registration_open" value="<?php echo $registrationOpen ? '0' : '1'; ?>">
|
||||
|
|
@ -65,4 +79,5 @@
|
|||
<?php endif; ?>
|
||||
</span>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<main class="page">
|
||||
|
|
|
|||
138
tippspiel/src/Views/questions.php
Normal file
138
tippspiel/src/Views/questions.php
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
$pageTitle = 'Fragen';
|
||||
require __DIR__ . '/partials/header.php';
|
||||
?>
|
||||
|
||||
<h1>Fragen</h1>
|
||||
|
||||
<?php if (!empty($message)): ?>
|
||||
<p class="flash flash-ok"><?php echo htmlspecialchars($message); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($error)): ?>
|
||||
<p class="flash flash-err"><?php echo htmlspecialchars($error); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($answerQuestion): ?>
|
||||
|
||||
<h2>Frage beantworten</h2>
|
||||
<div class="question-entry">
|
||||
<p class="question-meta">
|
||||
Von <?php echo htmlspecialchars($answerQuestion['user_name']); ?>
|
||||
· <?php echo date('d.m.Y H:i', strtotime($answerQuestion['question_date'])); ?>
|
||||
</p>
|
||||
<p class="question-text"><?php echo nl2br(htmlspecialchars($answerQuestion['question'])); ?></p>
|
||||
</div>
|
||||
|
||||
<form method="post" action="/index.php?page=questions" class="questions-form">
|
||||
<input type="hidden" name="action" value="answer">
|
||||
<input type="hidden" name="id" value="<?php echo (int)$answerQuestion['id']; ?>">
|
||||
<div class="form-group">
|
||||
<label for="answer">Antwort:</label>
|
||||
<textarea id="answer" name="answer" rows="6" required></textarea>
|
||||
</div>
|
||||
<div class="form-group buttons">
|
||||
<button type="submit">Antwort speichern</button>
|
||||
<a href="/index.php?page=questions">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php if ($isAdmin): ?>
|
||||
<p>Hier siehst du alle Fragen der Spieler. Offene Fragen kannst du direkt beantworten.</p>
|
||||
<?php else: ?>
|
||||
<p>Hier siehst du deine Fragen an die Admins und deren Antworten.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2>Neue Frage stellen</h2>
|
||||
<form method="post" action="/index.php?page=questions" class="questions-form">
|
||||
<input type="hidden" name="action" value="ask">
|
||||
<div class="form-group">
|
||||
<label for="question">Deine Frage:</label>
|
||||
<textarea id="question" name="question" rows="4" required maxlength="5000"></textarea>
|
||||
</div>
|
||||
<div class="form-group buttons">
|
||||
<button type="submit">Absenden</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h2><?php echo $isAdmin ? 'Alle Fragen' : 'Deine Fragen'; ?></h2>
|
||||
|
||||
<?php if (!$questions): ?>
|
||||
<p><?php echo $isAdmin ? 'Noch keine Fragen vorhanden.' : 'Du hast noch keine Fragen gestellt.'; ?></p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($questions as $q): ?>
|
||||
<div class="question-entry<?php echo $q['answer'] === null ? ' is-open' : ''; ?>">
|
||||
<p class="question-meta">
|
||||
<?php if ($isAdmin): ?>
|
||||
Von <?php echo htmlspecialchars($q['user_name']); ?>
|
||||
<?php endif; ?>
|
||||
· <?php echo date('d.m.Y H:i', strtotime($q['question_date'])); ?>
|
||||
</p>
|
||||
<p class="question-text"><?php echo nl2br(htmlspecialchars($q['question'])); ?></p>
|
||||
|
||||
<?php if ($q['answer'] === null): ?>
|
||||
<p class="question-status open">Noch nicht beantwortet</p>
|
||||
<?php if ($isAdmin): ?>
|
||||
<p><a class="answer-link" href="/index.php?page=questions&answer_id=<?php echo (int)$q['id']; ?>">Antworten</a></p>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<div class="answer-box">
|
||||
<p class="question-meta">Antwort · <?php echo date('d.m.Y H:i', strtotime($q['answer_date'])); ?></p>
|
||||
<p class="question-text"><?php echo nl2br(htmlspecialchars($q['answer'])); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<style>
|
||||
.flash { padding: 0.6em 0.9em; border-radius: 6px; }
|
||||
.flash-ok { background: #e8f3ec; border-left: 4px solid var(--pitch); color: var(--pitch-dark); }
|
||||
.flash-err { background: #fdecea; border-left: 4px solid #d62d2d; color: #a32626; }
|
||||
|
||||
.questions-form { max-width: 760px; margin-bottom: 2em; }
|
||||
.questions-form .form-group { margin-bottom: 1rem; }
|
||||
.questions-form label { display: block; font-weight: bold; margin-bottom: 0.3rem; }
|
||||
.questions-form textarea { width: 100%; box-sizing: border-box; }
|
||||
.questions-form .buttons a { margin-left: 1em; }
|
||||
|
||||
.question-entry {
|
||||
max-width: 760px;
|
||||
margin: 1em 0;
|
||||
padding: 0.8em 1em;
|
||||
border: 1px solid var(--line);
|
||||
border-left: 5px solid var(--pitch);
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
.question-entry.is-open { border-left-color: var(--gold); background: #fffdf3; }
|
||||
.question-meta { color: var(--muted); font-size: 0.85em; margin: 0 0 0.35em; }
|
||||
.question-text { margin: 0.35em 0; white-space: normal; }
|
||||
.question-status { font-size: 0.85em; font-weight: 700; margin: 0.5em 0; }
|
||||
.question-status.open { color: var(--col-joker-exact); }
|
||||
.answer-link {
|
||||
display: inline-block;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
padding: 0.35em 1.1em;
|
||||
border-radius: 999px;
|
||||
color: #fff;
|
||||
background: linear-gradient(180deg, #1b7a3b, var(--pitch));
|
||||
text-decoration: none;
|
||||
box-shadow: 0 2px 0 var(--pitch-dark);
|
||||
}
|
||||
.answer-link:hover { background: var(--pitch-dark); color: var(--gold); }
|
||||
.answer-box {
|
||||
margin-top: 0.6em;
|
||||
padding: 0.6em 0.9em;
|
||||
background: var(--pitch-light);
|
||||
border-radius: 6px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php require __DIR__ . '/partials/footer.php'; ?>
|
||||
|
|
@ -102,6 +102,7 @@ CREATE TABLE `settings` (
|
|||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`current_season_id` int(11) NOT NULL,
|
||||
`registration_open` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`message` text DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
|
|
@ -144,6 +145,23 @@ CREATE TABLE `roundmails` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `questions`;
|
||||
CREATE TABLE `questions` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`question` text NOT NULL,
|
||||
`question_date` datetime NOT NULL,
|
||||
`answer` text DEFAULT NULL,
|
||||
`answer_date` datetime DEFAULT NULL,
|
||||
`answered_by` int(11) DEFAULT NULL,
|
||||
`answer_seen` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`question_seen` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `questions_user_id_index` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `manual_payouts`;
|
||||
CREATE TABLE `manual_payouts` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue