From 5dda6b958d2cef278ef6d219eabe785558e02f7e Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 26 Oct 2023 21:48:04 +0200 Subject: [PATCH] join leave works --- web/pages/tournaments/controller.php | 37 ++++++++++++++++++++++++++++ web/pages/tournaments/event.html | 16 ++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/web/pages/tournaments/controller.php b/web/pages/tournaments/controller.php index fe925d1..0ff1f06 100644 --- a/web/pages/tournaments/controller.php +++ b/web/pages/tournaments/controller.php @@ -34,6 +34,43 @@ class Tournaments extends Page { } + function manage() + { + $action = $this->params[0]; + $tid = $this->params[1]; + $t = new Tournament(); + if($t->exists($tid)) + $t->load($tid); + else + return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Dieses Turnier existiert nicht']); + + switch($action) + { + case 'join': + if(in_array($tid, $_SESSION['user']->data['tournaments'])) + return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist bereits für dieses Turnier angemeldet']); + else + { + $_SESSION['user']->data['tournaments'][] = $tid; + return partial('success.html', ['successTitle' => 'Erfolgreich', 'successMessage' => 'Du wurdest erfolgreich für dieses Turnier angemeldet']); + } + case 'leave': + if(!in_array($tid, $_SESSION['user']->data['tournaments'])) + return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist für dieses Turnier nicht angemeldet']); + else + { + $_SESSION['user']->data['tournaments'] = array_diff($_SESSION['user']->data['tournaments'], [$tid]); + return partial('success.html', ['successTitle' => 'Erfolgreich', 'successMessage' => 'Du wurdest erfolgreich für dieses Turnier abgemeldet']); + } + } + + } + + function leave() + { + + } + function event() { $tid = $this->params[0]; diff --git a/web/pages/tournaments/event.html b/web/pages/tournaments/event.html index 34728a0..d7431bc 100644 --- a/web/pages/tournaments/event.html +++ b/web/pages/tournaments/event.html @@ -18,13 +18,25 @@
  • Webseite:
  • - +
    + + + + + + + +
    - +