Chris
b429513ab4
All checks were successful
Build and push / Pulling repo on server (push) Successful in 21s
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
class Tournament extends Model
|
|
{
|
|
protected $dbTable = "tournaments";
|
|
protected $dbFields = array(
|
|
'registered' => ['type' => 'datetime', 'required', 'unique', 'autoValMethod' => 'getDateTime'],
|
|
'name' => ['type' => 'text', 'required'],
|
|
'date' => ['type' => 'datetime','required'],
|
|
'duration' => ['type' => 'int'], //in days
|
|
'referee' => ['type' => 'text'],
|
|
'text' => ['type' => 'text'],
|
|
'url' => ['type' => 'text'], //if there is one
|
|
'logo' => ['type' => 'text', 'default' => 'https://pictshare.net/prrnrk.jpg'],
|
|
'admins' => ['type'=> 'array', 'default'=>[]],
|
|
);
|
|
|
|
function isMyEvent($tournament = false)
|
|
{
|
|
if ($tournament == false)
|
|
$tournament = $this->id;
|
|
|
|
if (!$this->exists($tournament))
|
|
return false;
|
|
else {
|
|
if (in_array($tournament, $_SESSION['user']->data['tournaments']))
|
|
return true;
|
|
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;
|
|
}
|
|
}
|
|
}
|