mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
- ErrorHandler tests: 77 assertions covering FK extraction, normalization, dedup, edge cases. Fix FK table map for child tables. - Fix FK violation: (int)null → 0 in createThesis for orientation/ap/finality/license FK columns. Add FK value logging to updateThesis. - Add CURRENT_ISSUES.md with summary of FK violation, dev debugging, and tag dedup status for next conversation
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Save handler for form help blocks (student-facing explanatory text shown
|
|
* in the /partage share-link submission form).
|
|
*/
|
|
require_once __DIR__ . '/../../../bootstrap.php';
|
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
if (!isset($_POST['csrf_token'], $_SESSION['csrf_token'])
|
|
|| !hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'])) {
|
|
App::flash('error', 'Erreur de sécurité : token invalide.');
|
|
header('Location: /admin/contenus.php');
|
|
exit;
|
|
}
|
|
|
|
$key = $_POST['form_help_key'] ?? '';
|
|
$content = $_POST['content'] ?? '';
|
|
|
|
require_once APP_ROOT . '/src/Database.php';
|
|
require_once APP_ROOT . '/src/AdminLogger.php';
|
|
require_once APP_ROOT . '/src/ErrorHandler.php';
|
|
$db = new Database();
|
|
|
|
if (!in_array($key, Database::FORM_HELP_KEYS, true)) {
|
|
App::flash('error', 'Clé de bloc invalide.');
|
|
header('Location: /admin/contenus.php');
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$db->setFormHelpBlock($key, $content);
|
|
AdminLogger::make()->logFormStructureEdit($key);
|
|
App::flash('success', 'Bloc « ' . htmlspecialchars($key) . ' » mis à jour.');
|
|
} catch (Exception $e) {
|
|
ErrorHandler::log('form_help', $e);
|
|
App::flash('error', 'Erreur lors de la sauvegarde : ' . ErrorHandler::userMessage($e));
|
|
}
|
|
|
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
|
header('Location: /admin/contenus.php#form-help-blocks');
|
|
exit;
|