join leave works
All checks were successful
Build and push / Pulling repo on server (push) Successful in 3s

This commit is contained in:
Chris 2023-10-26 21:48:04 +02:00
parent ebe969c7de
commit 5dda6b958d
2 changed files with 51 additions and 2 deletions

View File

@ -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];

View File

@ -18,13 +18,25 @@
<?php if($tdata['url']): ?><li>Webseite: <a href="<?= $tdata['url']; ?>"><?= escape($tdata['url']); ?></a></li> <?php endif; ?>
</ul>
<?php if($admin===true): ?>
<div class="d-flex justify-content-end">
<?php if($admin===true): ?>
<button type="button" class="btn btn-secondary" hx-get="/tournaments/edit/<?= $tournament_id; ?>" hx-target="#main">
<i class="fas fa-edit"></i>
</button>
<?php endif; ?>
<?php if($joined===false): ?>
<button type="button" class="btn btn-secondary" hx-get="/tournaments/manage/join/<?= $tournament_id; ?>" hx-swap="outerHTML">
<i class="fas fa-plus-circle"></i> Diesem Event beitreten
</button>
<?php elseif($admin===false): ?>
<button type="button" class="btn btn-danger" hx-get="/tournaments/manage/leave/<?= $tournament_id; ?>" hx-swap="outerHTML" hx-confirm="Möchtest du dieses Event wirklich verlassen?">
<i class="fas fa-minus-circle"></i> Event verlassen
</button>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>