function generate_vars($section, &$vars) { if (!$vars['is_logged'] || !$vars['is_admin']) { return; } $matches = Match::find_all(); $vars['matches'] = $matches; $vars['arenas'] = Arena::filter(''); if (isset($_POST['description0'])) { for ($i = 0; $i < count($matches); $i++) { $match = $matches[$i]; if (isset($_POST['delete' . $i])) { $match->delete(); continue; } if ($match->description != $_POST['description' . $i] || $match->date != $_POST['date' . $i] || $match->arena != $_POST['arena' . $i] || $match->prix != $_POST['prix' . $i]) { $match->description = $_POST['description' . $i]; $match->date = $_POST['date' . $i]; $match->arena = $_POST['arena' . $i]; $match->prix = $_POST['prix' . $i]; $match->save(); } } } if (!empty($_POST['description-nouveau']) && !empty($_POST['date-nouveau']) && !empty($_POST['arena-nouveau']) && !empty($_POST['prix-nouveau'])) { $match = new Match(); $match->description = $_POST['description-nouveau']; $match->date = $_POST['date-nouveau']; $match->arena = $_POST['arena-nouveau']; $match->prix = $_POST['prix-nouveau']; $match->save(); } $matches = Match::find_all(); $vars['matches'] = $matches; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Match(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Match'])) { $model->attributes = $_POST['Match']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->matchId)); } } $this->render('create', array('model' => $model)); }
/** * 录入 * */ public function actionCreate() { parent::_acl('match_create'); $model = new Match(); if (isset($_POST['Match'])) { $model->attributes = $_POST['Match']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入房屋配套,ID:' . $model->id)); $this->redirect(array('index')); } } $this->render('create', array('model' => $model)); }
/** * Creates our section when POSTed to. Performs snazzy validation. * @return [type] [description] */ public function postCreate() { $rules = array('league_id' => 'required|integer|exists:leagues,id', 'teamA_id' => 'required|integer|exists:teams,id', 'teamB_id' => 'required|integer|exists:teams,id', 'start_time' => 'required', 'rounds' => 'required|integer|min:1'); $validatior = Validator::make(Input::all(), $rules); if ($validatior->fails()) { return Redirect::action('Admin_MatchesController@getCreate')->withInput()->withErrors($validatior); } else { $match = new Match(); $match->league_id = Input::get('league_id'); $match->teamA_id = Input::get('teamA_id'); $match->teamB_id = Input::get('teamB_id'); $match->start_time = date("Y-m-d H:i:s", strtotime(Input::get('start_time'))); $match->stream_url = Input::get('stream_url'); $match->chat_url = Input::get('chat_url'); $match->rounds = Input::get('rounds'); $match->message = Input::get('message'); $match->save(); return Redirect::action('Admin_MatchesController@getIndex'); } }
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)); }
public function createNewMatch($match_table, $found) { Log::info("*********************[Creating new match]*********************"); Log::info("********[found]************"); Log::info($found); $match = new Match(); $match->fip_id = $this->id; $match->match_table_id = $found['id']; // TODO try $found->id if ($match_table == ArmyUpdates::TABLE_NAME) { $match->match_army_update = true; } elseif ($match_table == FoundPeople::TABLE_NAME) { $match->match_found_person = true; } $match->save(); }
/** * Set a winner for a match. * * @return void **/ public function setMatchWinner(Match $match, Team $team) { $match->completed_at = date('Y-m-d H:i:s', time()); $match->winning_team_id = $team->id; return $match->save(); }