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:
  • - +
    + + + + + + + +
    - +