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(); }
public function executeMatchsInProgress(sfWebRequest $request) { $this->filter = new MatchsActiveFormFilter($this->getFilters()); $query = $this->filter->buildQuery($this->getFilters()); $this->filterValues = $this->getFilters(); $table = MatchsTable::getInstance(); $this->pager = null; $this->pager = new sfDoctrinePager('Matchs', 50); $this->pager->setQuery($query->andWhere("status >= ? AND status <= ?", array(Matchs::STATUS_NOT_STARTED, Matchs::STATUS_END_MATCH))->orderBy("status DESC")); $this->pager->setPage($request->getParameter('page', 1)); $this->pager->init(); $this->page = $request->getParameter('page', 1); $this->url = "@matchs_current_page"; $this->servers = ServersTable::getInstance()->findAll(); }
} else { setSessionStorageValue("current.selected", 0); } } }); </script> <style> .match-selectable { cursor: pointer; } </style> <?php $used = array(); $servers = ServersTable::getInstance()->createQuery()->orderBy("hostname ASC")->execute(); ?> <div class="container-fluid"> <div class="span10"> <div id="tableMatch"> <table class="table table-striped"> <tbody> <?php foreach ($pager->getResults() as $index => $match) { ?> <?php if ($match->getEnable() == 1 && $match->getStatus() > Matchs::STATUS_NOT_STARTED && $match->getStatus() < Matchs::STATUS_END_MATCH) { $used[] = $match->getServer()->getIp(); } $score1 = $score2 = 0; if ($match->getMapSelectionMode() == "bo3_modeb") {
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"); } } }
public function executeStats(sfWebRequest $request) { $this->servers = ServersTable::getInstance()->findAll(); }