Example #1
0
 public function executeDuplicate(sfWebRequest $request)
 {
     $match = $this->getRoute()->getObject();
     $this->forward404Unless($match);
     $newMatch = new Matchs();
     $newMatch->setIp($match->getIp());
     $newMatch->setServer($match->getServer());
     $newMatch->setSeason($match->getSeason());
     $newMatch->setTeamA($match->getTeamA());
     $newMatch->setTeamAFlag($match->getTeamAFlag());
     $newMatch->setTeamAName($match->getTeamAName());
     $newMatch->setTeamB($match->getTeamB());
     $newMatch->setTeamBFlag($match->getTeamBFlag());
     $newMatch->setTeamBName($match->getTeamBName());
     $newMatch->setScoreA(0);
     $newMatch->setScoreB(0);
     $newMatch->setMaxRound($match->getMaxRound());
     $newMatch->setRules($match->getRules());
     $newMatch->overtime_startmoney = $match->overtime_startmoney;
     $newMatch->overtime_max_round = $match->overtime_max_round;
     $newMatch->config_full_score = $match->config_full_score;
     $newMatch->config_ot = $match->config_ot;
     $newMatch->config_streamer = $match->config_streamer;
     $newMatch->config_knife_round = $match->config_knife_round;
     $newMatch->config_password = $match->config_password;
     $newMatch->map_selection_mode = $match->map_selection_mode;
     $newMatch->setConfigAuthkey(uniqid(mt_rand(), true));
     $newMatch->setStatus(Matchs::STATUS_NOT_STARTED);
     $newMatch->save();
     $maps = new Maps();
     $maps->setMatch($newMatch);
     $maps->setMapsFor("default");
     $maps->setNbOt(0);
     $maps->setStatus(0);
     $maps->score_1 = 0;
     $maps->score_2 = 0;
     $maps->current_side = $match->getMap()->getCurrentSide();
     $maps->setMapName("tba");
     $maps->save();
     $newMatch->setCurrentMap($maps);
     $newMatch->save();
     $this->getUser()->setFlash("notification_ok", $this->__("Match cloned with ID") . " " . $newMatch->getId());
     $this->redirect("matchs_current");
 }