updated events and added popovers
This commit is contained in:
@ -13,8 +13,47 @@ class Tournament extends Model
|
||||
'url' => ['type' => 'text'], //if there is one
|
||||
'logo' => ['type' => 'text', 'default' => 'https://pictshare.net/prrnrk.jpg'],
|
||||
'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)
|
||||
{
|
||||
if ($tournament == false)
|
||||
@ -42,4 +81,42 @@ class Tournament extends Model
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user