public function actionStartTournament($id) { $model = $this->loadModel($id); $c = new ChallongeAPI(Yii::app()->params['challonge_api']); $params = array('include_matches' => 1, 'include_participants' => 1); $tournament_id = $model->challonge_id; $tournament = $c->startTournament($tournament_id, $params)->tournament; $model->started = date('Y-m-d H:i:s'); $model->save(); // echo "<pre>";print_r($tournament);echo "</pre>";//exit; if (count($c->errors)) { foreach ($c->errors as $error) { Yii::app()->user->setFlash('error', 'Challonge Error: ' . $error); } $this->redirect(array('teams', 'id' => $id)); } foreach ($tournament->matches as $k => $match) { // print $k."<br />"; // print_r($match); // print "<br />-------------------<br />"; try { $_match = new Match(); $_match->tournament_id = $id; $_match->challonge_tournament_id = $model->challonge_id; $_match->challonge_match_id = $match->match->id; $_match->team_1 = strlen($match->match->player1_id) ? $match->match->player1_id : ''; $_match->team_2 = strlen($match->match->player2_id) ? $match->match->player2_id : ''; $_match->identifier = $match->match->identifier; $_match->round = $match->match->round; $_match->state = $match->match->state; $_match->save(); } catch (CDbException $e) { continue; } } $model->updateMatchesFromChallonge(); // exit; $this->redirect(array('matches', 'id' => $id)); }
$thisTournament->participants = serialize($participants); $thisTournament->save(); $participants = unserialize($thisTournament->participants); $_SESSION['participants'] = $participants; $thisTeam = new tournamentTeam(); $thisTeam->tournamentid = $_POST['tournamentID']; $thisTeam->name = $_POST['name']; $thisTeam->save(); } //Start Tournament if (isset($_GET['start'])) { $thisTournament = Tournament::find_by_tournamentid($_POST['tournamentID']); //Edit on challonge $tournament_id = $thisTournament->challongeurl; $params = array(); $tournament = $challonge->startTournament($tournament_id, $params); //Set status to in progress $thisTournament->status = 2; $thisTournament->save(); header("Location: " . $_SERVER['HTTP_REFERER']); } //Submit Score if (isset($_GET['submitScore'])) { $tournament_id = $_POST['tournamentURL']; $match_id = $_POST['matchID']; switch ($_POST['winnerSelect']) { case 'A': $winner_id = $_POST['participantA']; break; case 'B': $winner_id = $_POST['participantB'];