Esempio n. 1
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeMatch(sfWebRequest $request)
 {
     $this->forward404Unless($request->getParameter("id"));
     $this->match = MatchsTable::getInstance()->find($request->getParameter("id"));
     if (!$this->match->exists()) {
         $this->redirect("homepage");
     }
     $this->setLayout("layout_stream");
 }
Esempio n. 2
0
 public function executeIndex(sfWebRequest $request)
 {
     $data = Doctrine_Query::create()->select('SUM(nb_kill) AS total_kill')->from('players')->fetchOne();
     $this->nbKill = $data["total_kill"];
     $data = Doctrine_Query::create()->select('SUM(hs) AS total_hs')->from('players')->fetchOne();
     $this->nbHs = $data["total_hs"];
     $this->nbNotStarted = MatchsTable::getInstance()->createQuery()->where("status IN ?", array(array(Matchs::STATUS_NOT_STARTED)))->count();
     $this->nbClosed = MatchsTable::getInstance()->createQuery()->where("status >= ?", array(Matchs::STATUS_END_MATCH))->count();
     $this->nbInProgress = MatchsTable::getInstance()->createQuery()->where("status >= ? AND status <= ?", array(Matchs::STATUS_STARTING, Matchs::STATUS_OT_SECOND_SIDE))->andWhere("enable = ?", 1)->count();
     $this->nbServers = ServersTable::getInstance()->createQuery()->count();
 }
Esempio n. 3
0
 public function executeGlobal(sfWebRequest $request)
 {
     $this->filter = new MatchsFormFilter($this->getFilters());
     $query = $this->filter->buildQuery($this->getFilters());
     $this->filterValues = $this->getFilters();
     $matchs = $this->getUser()->getAttribute("global.stats.matchs", array());
     if (count($matchs) > 0) {
         $this->matchs = $query->andWhere("id IN ?", array($matchs))->execute();
     } else {
         $this->matchs = $query->execute();
     }
     if ($request->getMethod() == sfWebRequest::POST) {
         if (is_array($request->getPostParameter("ids"))) {
             $matchTab = array();
             foreach ($request->getPostParameter("ids") as $id) {
                 if (!is_numeric($id)) {
                     continue;
                 }
                 if (in_array($id, $matchTab)) {
                     continue;
                 }
                 if (!MatchsTable::getInstance()->find($id)) {
                     continue;
                 }
                 $matchTab[] = $id;
             }
             if (count($matchTab) == 0) {
                 $this->getUser()->setFlash("notification.error", "No entry found.");
                 $this->getUser()->setAttribute("global.stats.matchs", null);
             } else {
                 $this->getUser()->setFlash("notification.ok", "Filter applied.");
                 $this->getUser()->setAttribute("global.stats.matchs", $matchTab);
             }
         } else {
             $this->getUser()->setFlash("notification.ok", "The filter was resetted.");
             $this->getUser()->setAttribute("global.stats.matchs", null);
         }
         $this->redirect("global_stats");
     }
 }
Esempio n. 4
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->match = $this->getRoute()->getObject();
     $this->forward404Unless($this->match);
     $this->maps = sfConfig::get("app_maps");
     array_push($this->maps, 'tba');
     $this->servers = ServersTable::getInstance()->findAll();
     if ($this->match->getEnable()) {
         $this->getUser()->setFlash("notification_error", $this->__("Match is currently in progress, can't be edited."));
         $this->redirect("matchs_current");
     }
     $this->form = new MatchsForm($this->match);
     $this->formScores = array();
     $scores = MapsScoreTable::getInstance()->createQuery()->where("map_id = ?", $this->match->getMap()->getId())->orderBy("id ASC")->execute();
     foreach ($scores as $score) {
         $this->formScores[] = new MapsScoreForm($score);
     }
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         if ($this->form->isValid() && in_array($_POST["maps"], $this->maps)) {
             $server = null;
             $server_id = $request->getPostParameter("server_id");
             if (is_numeric($server_id) && $server_id != 0) {
                 $server = ServersTable::getInstance()->find($server_id);
                 $this->forward404Unless($server && $server->exists());
             }
             if (is_null($server)) {
                 $matchs = MatchsTable::getInstance()->getMatchsInProgressQuery()->andWhere("enable = ?", 1)->andWhere("status < ? ", Matchs::STATUS_END_MATCH)->andWhere("status > ? ", Matchs::STATUS_NOT_STARTED)->execute();
                 $servers = ServersTable::getInstance()->createQuery()->orderBy("RAND()")->execute();
                 $used = array();
                 foreach ($matchs as $m) {
                     $used[] = $m->getServer()->getIp();
                 }
                 foreach ($servers as $s) {
                     if (in_array($s->getIp(), $used)) {
                         continue;
                     }
                     $server = $s;
                     break;
                 }
             }
             if (is_null($server)) {
                 $this->getUser()->setFlash("notification_error", $this->__("No Server available"));
                 $this->redirect("matchs_current");
             }
             $match = $this->form->save();
             $match->setIp($server->getIp());
             $match->setServer($server);
             if ($match->getAutoStart()) {
                 if ($match->getStartdate() == NULL) {
                     $match->setAutoStart(false);
                 }
             }
             $match->save();
             $map = $match->getMap();
             $map->setMapName($_POST["maps"]);
             $map->save();
             $this->getUser()->setFlash("notification_ok", $this->__("Match edited successfully"));
             $this->redirect("matchs_current");
         }
     }
 }
Esempio n. 5
0
 public function getNbMatchs()
 {
     return MatchsTable::getInstance()->createQuery()->andWhere("server_id = ?", $this->getId())->count();
 }
Esempio n. 6
0
 public function executeExternalTvStatsTeams(sfWebRequest $request)
 {
     $this->setLayout("layout_external");
     $this->forward404Unless($request->getParameter("ids"));
     $this->forward404Unless($request->getParameter("team1"));
     $this->forward404Unless($request->getParameter("team2"));
     $this->matchs = MatchsTable::getInstance()->createQuery()->where("id IN ?", array(explode(",", $request->getParameter("ids"))))->execute();
     $this->team1 = TeamsTable::getInstance()->find($request->getParameter("team1"));
     $this->team2 = TeamsTable::getInstance()->find($request->getParameter("team2"));
 }
Esempio n. 7
0
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="modalSearchLabel"><?php 
echo __("Filter");
?>
</h3>
        </div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label" for="inputMatchs"><?php 
echo __("Matches");
?>
</label>
                <div class="controls">
                    <select name="ids[]" id="inputMatchs" multiple="multiple" class="input-xlarge">
                        <?php 
foreach (MatchsTable::getInstance()->findAll() as $match) {
    ?>
                            <option value="<?php 
    echo $match->getId();
    ?>
">#<?php 
    echo $match->getId();
    ?>
 - <?php 
    echo $match->getTeamA();
    ?>
 vs <?php 
    echo $match->getTeamB();
    ?>
</option>
                        <?php 
Esempio n. 8
0
 public function executeMenu()
 {
     $this->nbMatchs = MatchsTable::getInstance()->createQuery()->andWhere("status >= ? AND status <= ?", array(Matchs::STATUS_NOT_STARTED, Matchs::STATUS_END_MATCH))->andWhere("enable = ?", 1)->count();
 }
Esempio n. 9
0
 public function executeExternalCoverage(sfWebRequest $request)
 {
     $this->setLayout("layout_external");
     $this->forward404Unless($request->getParameter("id"));
     $this->match = MatchsTable::getInstance()->find($request->getParameter("id"));
     $this->ebot_ip = sfConfig::get("app_ebot_ip");
     $this->ebot_port = sfConfig::get("app_ebot_port");
 }
Esempio n. 10
0
 public function executeGunround(sfWebRequest $request)
 {
     $q = Doctrine_Manager::getInstance()->getCurrentConnection();
     $teamNames = array();
     foreach (MatchsTable::getInstance()->findAll() as $match) {
         $teamNames[$match->getTeamAName()]['count']++;
         $teamNames[$match->getTeamBName()]['count']++;
         if ($match->getScoreA() > $match->getScoreB()) {
             $teamNames[$match->getTeamAName()]['win']++;
             $teamNames[$match->getTeamBName()]['loose']++;
         } else {
             $teamNames[$match->getTeamAName()]['loose']++;
             $teamNames[$match->getTeamBName()]['win']++;
         }
     }
     $teamStats = array();
     foreach ($teamNames as $team => $v) {
         $statsGRA1 = Doctrine_Query::create()->select('count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("s.team_win = ?", "a")->andWhere("s.round_id = ?", 1)->execute()->toArray();
         $statsGRA2 = Doctrine_Query::create()->select('count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("s.team_win = ?", "a")->andWhere("s.round_id = ?", 16)->execute()->toArray();
         $statsGRB1 = Doctrine_Query::create()->select('count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("s.team_win = ?", "b")->andWhere("s.round_id = ?", 1)->execute()->toArray();
         $statsGRB2 = Doctrine_Query::create()->select('count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("s.team_win = ?", "b")->andWhere("s.round_id = ?", 16)->execute()->toArray();
         $statsA1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("s.team_win = ?", "a")->andWhere("s.round_id IN ?", array(array(1, 2)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsA2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("s.team_win = ?", "a")->andWhere("s.round_id IN ?", array(array(16, 17)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsB1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("s.team_win = ?", "b")->andWhere("s.round_id IN ?", array(array(1, 2)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsB2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("s.team_win = ?", "b")->andWhere("s.round_id IN ?", array(array(16, 17)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsEA1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'b') OR (s.round_id = ? AND s.team_win = 'a'))", array(1, 2))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsEA2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'b') OR (s.round_id = ? AND s.team_win = 'a'))", array(16, 17))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsEB1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'a') OR (s.round_id = ? AND s.team_win = 'b'))", array(1, 2))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsEB2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'a') OR (s.round_id = ? AND s.team_win = 'b'))", array(16, 17))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsLA1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("s.team_win = ?", "b")->andWhere("s.round_id IN ?", array(array(1, 2)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsLA2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("s.team_win = ?", "b")->andWhere("s.round_id IN ?", array(array(16, 17)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsLB1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("s.team_win = ?", "a")->andWhere("s.round_id IN ?", array(array(1, 2)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsLB2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("s.team_win = ?", "a")->andWhere("s.round_id IN ?", array(array(16, 17)))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsTA1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'a') OR (s.round_id = ? AND s.team_win = 'b'))", array(1, 2))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsTA2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_a_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'a') OR (s.round_id = ? AND s.team_win = 'b'))", array(16, 17))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsTB1 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'b') OR (s.round_id = ? AND s.team_win = 'a'))", array(1, 2))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $statsTB2 = Doctrine_Query::create()->select('s.map_id, count(*) as nb')->from('RoundSummary s')->leftJoin("s.Match m")->andWhere("m.team_b_name = ?", $team)->andWhere("((s.round_id = ? AND s.team_win = 'b') OR (s.round_id = ? AND s.team_win = 'a'))", array(16, 17))->groupBy("s.map_id")->having("COUNT(*) = 2")->execute()->toArray();
         $stats = count($statsA1) + count($statsA2) + count($statsB1) + count($statsB2);
         $statsE = count($statsEA1) + count($statsEA2) + count($statsEB1) + count($statsEB2);
         $statsL = count($statsLA1) + count($statsLA2) + count($statsLB1) + count($statsLB2);
         $statsT = count($statsTA1) + count($statsTA2) + count($statsTB1) + count($statsTB2);
         $statsGR = $statsGRA1[0]['nb'] + $statsGRA2[0]['nb'] + $statsGRB1[0]['nb'] + $statsGRB2[0]['nb'];
         $teamStats[$team] = array("stats" => $stats, "statsE" => $statsE, "statsL" => $statsL, "statsT" => $statsT, "statsGR" => $statsGR, "count" => $v['count'], "win" => $v['win'], "loose" => $v['loose']);
     }
     ksort($teamStats);
     $this->teamStats = $teamStats;
 }