nonadminsmaysee
All checks were successful
Build and push / Pulling repo on server (push) Successful in 21s
All checks were successful
Build and push / Pulling repo on server (push) Successful in 21s
This commit is contained in:
parent
00c2e1ded6
commit
b429513ab4
@ -11,7 +11,8 @@ class Tournament extends Model
|
|||||||
'referee' => ['type' => 'text'],
|
'referee' => ['type' => 'text'],
|
||||||
'text' => ['type' => 'text'],
|
'text' => ['type' => 'text'],
|
||||||
'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'=>[]],
|
||||||
);
|
);
|
||||||
|
|
||||||
function isMyEvent($tournament = false)
|
function isMyEvent($tournament = false)
|
||||||
@ -27,4 +28,18 @@ class Tournament extends Model
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function amIAdmin($tournament = false)
|
||||||
|
{
|
||||||
|
if ($tournament == false)
|
||||||
|
$tournament = $this->id;
|
||||||
|
|
||||||
|
if (!$this->exists($tournament))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
if (in_array($_SESSION['user']->id, $this->data['admins']))
|
||||||
|
return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ class Tournaments extends Page {
|
|||||||
|
|
||||||
$t->load($tid);
|
$t->load($tid);
|
||||||
|
|
||||||
|
$this->set('admin',$t->amIAdmin($tid));
|
||||||
|
$this->set('joined',$t->isMyEvent($tid));
|
||||||
$this->set('tournament_id',$tid);
|
$this->set('tournament_id',$tid);
|
||||||
$this->set('tdata',$t->data);
|
$this->set('tdata',$t->data);
|
||||||
$this->set('template','event.html');
|
$this->set('template','event.html');
|
||||||
@ -111,7 +113,12 @@ class Tournaments extends Page {
|
|||||||
{
|
{
|
||||||
$t = new Tournament();
|
$t = new Tournament();
|
||||||
if($id)
|
if($id)
|
||||||
|
{
|
||||||
|
if(!in_array($_SESSION['user']->id, $t->data['admins']))
|
||||||
|
return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Du bist nicht berechtigt, dieses Turnier zu bearbeiten']);
|
||||||
|
else
|
||||||
$t->load($id);
|
$t->load($id);
|
||||||
|
}
|
||||||
|
|
||||||
$t->name = $name;
|
$t->name = $name;
|
||||||
$t->date = $date;
|
$t->date = $date;
|
||||||
@ -119,6 +126,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(!in_array($_SESSION['user']->id, $t->data['admins']))
|
||||||
|
$t->data['admins'][] = $_SESSION['user']->id;
|
||||||
if($newlogo)
|
if($newlogo)
|
||||||
$t->logo = $newlogo;
|
$t->logo = $newlogo;
|
||||||
|
|
||||||
|
@ -18,11 +18,13 @@
|
|||||||
<?php if($tdata['url']): ?><li>Webseite: <a href="<?= $tdata['url']; ?>"><?= escape($tdata['url']); ?></a></li> <?php endif; ?>
|
<?php if($tdata['url']): ?><li>Webseite: <a href="<?= $tdata['url']; ?>"><?= escape($tdata['url']); ?></a></li> <?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<?php if($admin===true): ?>
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex justify-content-end">
|
||||||
<button type="button" class="btn btn-secondary" hx-get="/tournaments/edit/<?= $tournament_id; ?>" hx-target="#main">
|
<button type="button" class="btn btn-secondary" hx-get="/tournaments/edit/<?= $tournament_id; ?>" hx-target="#main">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user