updated events and added popovers
This commit is contained in:
parent
c22b000f46
commit
9e0d1cfa35
6
web/js/popper.min.js
vendored
Normal file
6
web/js/popper.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -13,8 +13,47 @@ class Tournament extends Model
|
|||||||
'url' => ['type' => 'text'], //if there is one
|
'url' => ['type' => 'text'], //if there is one
|
||||||
'logo' => ['type' => 'text', 'default' => 'https://pictshare.net/prrnrk.jpg'],
|
'logo' => ['type' => 'text', 'default' => 'https://pictshare.net/prrnrk.jpg'],
|
||||||
'admins' => ['type'=> 'array', 'default'=>[]],
|
'admins' => ['type'=> 'array', 'default'=>[]],
|
||||||
|
'members' => ['type'=> 'array', 'default'=>[]],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function joinUser($tournament = false)
|
||||||
|
{
|
||||||
|
if ($tournament == false)
|
||||||
|
$tournament = $this->id;
|
||||||
|
|
||||||
|
if (!$this->exists($tournament))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
if (!in_array($_SESSION['user']->id, $this->data['members']))
|
||||||
|
$this->data['members'][] = $_SESSION['user']->id;
|
||||||
|
if(!in_array($tournament,$_SESSION['user']->data['tournaments']))
|
||||||
|
{
|
||||||
|
$_SESSION['user']->data['tournaments'][] = $tournament;
|
||||||
|
$_SESSION['user']->save();
|
||||||
|
}
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeUser($tournament = false)
|
||||||
|
{
|
||||||
|
if ($tournament == false)
|
||||||
|
$tournament = $this->id;
|
||||||
|
|
||||||
|
if (!$this->exists($tournament))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
if (in_array($_SESSION['user']->id, $this->data['members']))
|
||||||
|
$this->data['members'] = array_diff($this->data['members'],[$_SESSION['user']->id]);
|
||||||
|
if(in_array($tournament,$_SESSION['user']->data['tournaments']))
|
||||||
|
{
|
||||||
|
$_SESSION['user']->data['tournaments'] = array_diff($_SESSION['user']->data['tournaments'],[$tournament]);
|
||||||
|
$_SESSION['user']->save();
|
||||||
|
}
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isMyEvent($tournament = false)
|
function isMyEvent($tournament = false)
|
||||||
{
|
{
|
||||||
if ($tournament == false)
|
if ($tournament == false)
|
||||||
@ -42,4 +81,42 @@ class Tournament extends Model
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAdmins($tournament = false)
|
||||||
|
{
|
||||||
|
if ($tournament == false)
|
||||||
|
$tournament = $this->id;
|
||||||
|
|
||||||
|
if (!$this->exists($tournament))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
$admins = [];
|
||||||
|
foreach($this->data['admins'] as $admin)
|
||||||
|
{
|
||||||
|
$u = new User();
|
||||||
|
$u->load($admin);
|
||||||
|
$admins[] = $u->getDataFiltered();
|
||||||
|
}
|
||||||
|
return $admins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMembers($tournament = false)
|
||||||
|
{
|
||||||
|
if ($tournament == false)
|
||||||
|
$tournament = $this->id;
|
||||||
|
|
||||||
|
if (!$this->exists($tournament))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
$members = [];
|
||||||
|
foreach($this->data['members'] as $member)
|
||||||
|
{
|
||||||
|
$u = new User();
|
||||||
|
$u->load($member);
|
||||||
|
$members[] = $u->getDataFiltered();
|
||||||
|
}
|
||||||
|
return $members;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class Tournaments extends Page {
|
|||||||
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist bereits für dieses Turnier angemeldet']);
|
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist bereits für dieses Turnier angemeldet']);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$_SESSION['user']->data['tournaments'][] = $tid;
|
$t->joinUser($tid);
|
||||||
return partial('success.html', ['successTitle' => 'Erfolgreich', 'successMessage' => 'Du wurdest erfolgreich für dieses Turnier angemeldet']);
|
return partial('success.html', ['successTitle' => 'Erfolgreich', 'successMessage' => 'Du wurdest erfolgreich für dieses Turnier angemeldet']);
|
||||||
}
|
}
|
||||||
case 'leave':
|
case 'leave':
|
||||||
@ -59,7 +59,7 @@ class Tournaments extends Page {
|
|||||||
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist für dieses Turnier nicht angemeldet']);
|
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist für dieses Turnier nicht angemeldet']);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$_SESSION['user']->data['tournaments'] = array_diff($_SESSION['user']->data['tournaments'], [$tid]);
|
$t->removeUser($tid);
|
||||||
return partial('success.html', ['successTitle' => 'Erfolgreich', 'successMessage' => 'Du wurdest erfolgreich für dieses Turnier abgemeldet']);
|
return partial('success.html', ['successTitle' => 'Erfolgreich', 'successMessage' => 'Du wurdest erfolgreich für dieses Turnier abgemeldet']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,6 +83,8 @@ class Tournaments extends Page {
|
|||||||
$this->set('admin',$t->amIAdmin($tid));
|
$this->set('admin',$t->amIAdmin($tid));
|
||||||
$this->set('joined',$t->isMyEvent($tid));
|
$this->set('joined',$t->isMyEvent($tid));
|
||||||
$this->set('tournament_id',$tid);
|
$this->set('tournament_id',$tid);
|
||||||
|
$this->set('admins',$t->getAdmins($tid));
|
||||||
|
$this->set('members',$t->getMembers($tid));
|
||||||
$this->set('tdata',$t->data);
|
$this->set('tdata',$t->data);
|
||||||
$this->set('template','event.html');
|
$this->set('template','event.html');
|
||||||
}
|
}
|
||||||
@ -162,6 +164,8 @@ class Tournaments extends Page {
|
|||||||
$t->referee = $tournament_referee;
|
$t->referee = $tournament_referee;
|
||||||
$t->text = $tournament_text;
|
$t->text = $tournament_text;
|
||||||
$t->url = $tournament_url;
|
$t->url = $tournament_url;
|
||||||
|
if(!$t->data['admins'] || !is_array($t->data['admins'] || count($t->data['admins']) == 0))
|
||||||
|
$t->data['admins'] = [];
|
||||||
if(!in_array($_SESSION['user']->id, $t->data['admins']))
|
if(!in_array($_SESSION['user']->id, $t->data['admins']))
|
||||||
$t->data['admins'][] = $_SESSION['user']->id;
|
$t->data['admins'][] = $_SESSION['user']->id;
|
||||||
if($newlogo)
|
if($newlogo)
|
||||||
|
@ -39,6 +39,12 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card p-2">
|
||||||
|
<?php foreach($admins as $admin) : ?>
|
||||||
|
<img src="https://pictshare.net/identicon/<?= $admin['email']?>" height="50" width="50" class="rounded-circle" alt="<?= escape($admin['name']); ?>" data-bs-toggle="tooltip" data-bs-placement="top" title="<?= escape($admin['name']); ?>">
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8" id="sitemain">
|
<div class="col-8" id="sitemain">
|
||||||
<pre><?= escape($tdata['text']); ?></pre>
|
<pre><?= escape($tdata['text']); ?></pre>
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
<script src="/js/htmx.min.js"></script>
|
<script src="/js/htmx.min.js"></script>
|
||||||
<script src="/js/bootstrap.bundle.min.js"></script>
|
<script src="/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="/js/color-modes.js"></script>
|
<script src="/js/color-modes.js"></script>
|
||||||
|
<script src="/js/popper.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Reference in New Issue
Block a user