mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-26 03:42:20 +00:00
79 lines
3.2 KiB
PHP
79 lines
3.2 KiB
PHP
<?php
|
|
|
|
if ($_SESSION["role"] != Role::ADMIN)
|
|
require_once "server_files/403.php";
|
|
|
|
$has_error = false;
|
|
$error_message = null;
|
|
|
|
if (isset($_POST["update_calendar"])) {
|
|
$update_calendar = new UpdateCalendar($_POST);
|
|
try {
|
|
$update_calendar->makeVerifications();
|
|
$update_calendar->updateCalendar();
|
|
} catch (AssertionError $e) {
|
|
$has_error = true;
|
|
$error_message = $e->getMessage();
|
|
}
|
|
}
|
|
|
|
class UpdateCalendar
|
|
{
|
|
private $date_inscription;
|
|
private $time_inscription;
|
|
private $date_start_phase1;
|
|
private $time_start_phase1;
|
|
private $date_end_phase1;
|
|
private $time_end_phase1;
|
|
private $date_start_phase2;
|
|
private $time_start_phase2;
|
|
private $date_end_phase2;
|
|
private $time_end_phase2;
|
|
private $date_start_phase3;
|
|
private $time_start_phase3;
|
|
private $date_end_phase3;
|
|
private $time_end_phase3;
|
|
private $date_start_phase4;
|
|
private $time_start_phase4;
|
|
private $date_end_phase4;
|
|
private $time_end_phase4;
|
|
|
|
public function __construct($data)
|
|
{
|
|
foreach ($data as $key => $value)
|
|
$this->$key = htmlspecialchars($value);
|
|
}
|
|
|
|
public function makeVerifications()
|
|
{
|
|
ensure(dateWellFormed($this->date_inscription . " " . $this->time_inscription), "La date d'inscription n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_start_phase1 . " " . $this->time_start_phase1), "La date de début de la phase 1 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_end_phase1 . " " . $this->time_end_phase1), "La date de fin de la phase 1 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_start_phase2 . " " . $this->time_start_phase2), "La date de début de la phase 2 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_end_phase2 . " " . $this->time_end_phase2), "La date de fin de la phase 2 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_start_phase3 . " " . $this->time_start_phase3), "La date de début de la phase 3 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_end_phase3 . " " . $this->time_end_phase3), "La date de fin de la phase 3 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_start_phase4 . " " . $this->time_start_phase4), "La date de début de la phase 4 n'est pas bien formée.");
|
|
ensure(dateWellFormed($this->date_end_phase4 . " " . $this->time_end_phase4), "La date de fin de la phase 4 n'est pas bien formée.");
|
|
}
|
|
|
|
public function updateCalendar()
|
|
{
|
|
global $CONFIG, $URL_BASE;
|
|
|
|
$CONFIG->setInscriptionDate($this->date_inscription . " " . $this->time_inscription);
|
|
$CONFIG->setStartPhase1Date($this->date_start_phase1 . " " . $this->time_start_phase1);
|
|
$CONFIG->setEndPhase1Date($this->date_end_phase1 . " " . $this->time_end_phase1);
|
|
$CONFIG->setStartPhase2Date($this->date_start_phase2 . " " . $this->time_start_phase2);
|
|
$CONFIG->setEndPhase2Date($this->date_end_phase2 . " " . $this->time_end_phase2);
|
|
$CONFIG->setStartPhase3Date($this->date_start_phase3 . " " . $this->time_start_phase3);
|
|
$CONFIG->setEndPhase3Date($this->date_end_phase3 . " " . $this->time_end_phase3);
|
|
$CONFIG->setStartPhase4Date($this->date_start_phase4 . " " . $this->time_start_phase4);
|
|
$CONFIG->setEndPhase4Date($this->date_end_phase4 . " " . $this->time_end_phase4);
|
|
|
|
header("Location: $URL_BASE/problemes");
|
|
exit();
|
|
}
|
|
}
|
|
|
|
require_once "server_files/views/calendrier.php"; |