public function JoinTeam($ttid)
 {
     //Check not anonymous
     if ($this->user_id == 0) {
         return "Anonymous users cannot join teams!";
     }
     if (null == $ttid) {
         return "Programming error: No timetable ID passed!";
     }
     //Check allow signup
     $timetable = new Lan_timetable();
     $timetable->id = $ttid;
     //$timetable->allowsignups = 1;
     $timetable->teambased = 1;
     if (1 != $timetable->find()) {
         return "This event does not allow joining teams.";
     }
     //Check not already in a team
     $team = new Lan_timetable_teams();
     $member = new Lan_timetable_team_members();
     $member->user_id = $this->user_id;
     $team->timetable_id = $ttid;
     $team->joinAdd($member);
     if ($team->count() != 0) {
         return "This user cannot join a team twice!";
     }
     //Check max team size
     $timetable->fetch();
     $team->team_id = $this->team_id;
     $team->PopulateMembers();
     $teamsize = count($team->members);
     if (!streq($teamsize, "0") && $timetable->teamsize < $teamsize + 1) {
         return "Max team size reached!";
     }
     //Join team
     if ($this->insert() == 0) {
         return "This user is already in a team for this event!";
     }
     //Remove pug if needed.
     $signup = new Lan_timetable_signups();
     $signup->timetable_id = $ttid;
     $signup->user_id = $this->user_id;
     while ($signup->fetch()) {
         $signup->delete();
     }
     return false;
 }
Ejemplo n.º 2
0
<?php

include 'foodrun.logic.php';
$biggame = new Lan_timetable();
$biggame->type = "food";
if (isset($_GET["tid"])) {
    $user = new Lan_users();
    $biggame->joinAdd($user, "LEFT");
    if ($biggame->get($biggame->escape($_GET["tid"]))) {
        $biggame->fetch();
        //Find sign ups
        $tts = new Lan_timetable_signups();
        $user = new Lan_users();
        $tts->joinAdd($user);
        $tts->timetable_id = $biggame->id;
        $list = array();
        $tts->find();
        $currentUserSignedUp = false;
        $signups = 0;
        while ($tts->fetch()) {
            if (streq($tts->user_id, getCurrentUID())) {
                $currentUserSignedUp = true;
            }
            $list[] = clone $tts;
            $signups++;
        }
        $biggame->signups = $signups;
        $game = new Lan_games();
        if (1 == $game->get($biggame->game)) {
            $master->Smarty->assign("image", "images/games/" . $game->picture);
            $master->Smarty->assign("gamename", $game->name);
Ejemplo n.º 3
0
 $start->datetime = strtotime($lan->start);
 $events[] = $start;
 $event = new Lan_timetable();
 $event->lan_id = getCurrentLID();
 $event->orderBy('"when" ASC');
 $game = new Lan_games();
 $event->selectAs($game, "game_%s");
 $event->joinAdd($game, "LEFT");
 $event->find();
 while ($event->fetch()) {
     $event->diff = getDiffDateTime(strtotime($event->occurs));
     //Remove old events
     if (strlen($event->diff) == 0) {
         continue;
     }
     $users = new Lan_timetable_signups();
     $users->timetable_id = $event->id;
     $event->signups = $users->count();
     $users->user_id = getCurrentUID();
     if (getCurrentUID() == 0) {
         $event->currentUserSignedUp = false;
     } else {
         $event->currentUserSignedUp = $users->count() != 0;
     }
     if (streq("1", $event->teambased)) {
         $event->PopulateTeams();
     }
     $event->datetime = strtotime($event->occurs);
     //Pull additional info based on type
     switch ($event->type) {
         //	case 'start':
Ejemplo n.º 4
0
                        $signup = new Lan_timetable_signups();
                        $signup->timetable_id = $biggame->id;
                        $signup->user_id = getCurrentUID();
                        if ($signup->count() == 0) {
                            $signup->insert();
                        } else {
                            $error = "You are already signed up to this event!";
                        }
                    } else {
                        $error = "Unknown big game?";
                    }
                } else {
                    $error = "No event id set?";
                }
            }
            break;
        case "remsignup":
            if (isset($_GET["tid"])) {
                $signup = new Lan_timetable_signups();
                $signup->timetable_id = $signup->escape($_GET["tid"]);
                $signup->user_id = getCurrentUID();
                $signup->find();
                if ($signup->count() != 0) {
                    $signup->delete();
                }
            } else {
                $error = "No event id set?";
            }
            break;
    }
}
Ejemplo n.º 5
0
<?php

include 'biggame.logic.php';
$biggame = new Lan_timetable();
$biggame->type = "biggame";
if (isset($_GET["tid"])) {
    if ($biggame->get($biggame->escape($_GET["tid"]))) {
        $biggame->fetch();
        //Find sign ups
        $tts = new Lan_timetable_signups();
        $user = new Lan_users();
        $tts->joinAdd($user, "LEFT");
        //$tgame = new Lan_games;
        //$tts->joinAdd($tgame, "LEFT");
        $tts->timetable_id = $biggame->id;
        $list = array();
        $tts->find();
        $currentUserSignedUp = "no";
        while ($tts->fetch()) {
            if (streq($tts->user_id, getCurrentUID())) {
                $currentUserSignedUp = "signup";
            }
            $list[] = clone $tts;
        }
        $master->Smarty->assign("signups", $list);
        $game = new Lan_games();
        if (1 == $game->get($biggame->game)) {
            $master->Smarty->assign("image", "images/games/" . $game->picture);
            $master->Smarty->assign("gamename", $game->name);
            if (!streq($biggame->game, "0")) {
                $link = "http://apps.metacritic.com/search/process?ty=3&ts=" . $game->name . "&tfs=game_title&sb=0&game_platform=PC&x=11&y=6&release_date_s=";
Ejemplo n.º 6
0
 /**
  * Create a team
  * @param $name
  * @param $tag
  */
 public function CreateTeam()
 {
     //Anonymous users cannot register.
     if (streq($this->owner, "0")) {
         return "Anonymous users cannot register teams!";
     }
     //Validate against team name being in use.
     $test = new Lan_timetable_teams();
     $test->name = $this->name;
     $test->tag = $this->tag;
     $test->timetable_id = $this->timetable_id;
     if ($test->count() != 0) {
         return "A team with this name already exists!";
     }
     //Validate against the captain already being in a team
     $tm = new Lan_timetable_team_members();
     $tm->user_id = $this->owner;
     $test = new Lan_timetable_teams();
     $test->joinAdd($tm, "CENTER");
     if ($test->count() != 0) {
         return "You cannot create a team whilst you are in a team!";
     }
     //Check that teams are being used
     $tt = new Lan_timetable();
     $tt->id = $this->timetable_id;
     $tt->teambased = 1;
     if ($tt->find() != 1) {
         return "This event is not team based!";
     }
     $tt->fetch();
     $test = new Lan_timetable_teams();
     $test->timetable_id = $this->timetable_id;
     if (!streq("0", $tt->maxplayers) && $tt->maxplayers < $test->count() + 1) {
         return "Max team count reached for this event.";
     }
     //All is ok, so insert the team
     if (0 == $this->insert()) {
         return "Team creation failed!";
     }
     //Add the captain as a member
     $tm = new Lan_timetable_team_members();
     $tm->team_id = $this->team_id;
     $tm->user_id = $this->owner;
     if (0 == $tm->insert()) {
         return "Error adding captain as team member!";
     }
     //If the player is a PUG player then remove them from the list.
     $signup = new Lan_timetable_signups();
     $signup->timetable_id = $this->timetable_id;
     $signup->user_id = $this->owner;
     while ($signup->fetch()) {
         $signup->delete();
     }
     return false;
 }