Example #1
0
 public function executeEdit($request)
 {
     $this->team = $this->getRoute()->getObject();
     $this->form = new TeamsForm($this->team);
     $this->seasons = SeasonsTable::getInstance()->findAll();
     $this->currentSeasons = TeamsInSeasonsTable::getInstance()->createQuery('s')->select('s.season_id')->where('s.team_id = ?', $this->team->getId())->fetchArray();
     if ($request->getMethod() == sfWebRequest::POST) {
         $this->form->bind($request->getPostParameter($this->form->getName()));
         $seasons = $request->getPostParameter('seasons_list');
         if ($this->form->isValid()) {
             $team = $this->form->save();
             $deleted = TeamsInSeasonsTable::getInstance()->createQuery('s')->delete()->where('s.team_id = ?', $this->team->getId())->execute();
             foreach ($seasons as $season) {
                 $teamsInSeasons = new TeamsInSeasons();
                 $teamsInSeasons->setSeasonId($season);
                 $teamsInSeasons->setTeams($this->team);
                 $teamsInSeasons->save();
             }
             $this->getUser()->setFlash("notification_ok", $this->__("Team edited successfully."));
             $this->redirect("teams/index");
         } else {
             $this->getUser()->setFlash("notification_error", $this->__("Error, invalid form"));
         }
     }
 }
Example #2
0
 public function executeMatchsInProgress(sfWebRequest $request)
 {
     if ($request->getMethod() == sfWebRequest::POST) {
         if ($request->getPostParameter('server_id', 0) && $request->getPostParameter('match_id', 0)) {
             $match = MatchsTable::getInstance()->find($request->getPostParameter('match_id'));
             $server = ServersTable::getInstance()->find($request->getPostParameter('server_id'));
             if ($match && $server && $match->exists() && $server->exists()) {
                 if ($match->getStatus() == 0) {
                     $match->setServer($server);
                     $match->setIp($server->getIp());
                     $match->save();
                     $this->getUser()->setFlash("notification_ok", $this->__("Server assigned"));
                 }
             }
         }
         $this->redirect("matchs_current");
     }
     $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', 12);
     $this->pager->setQuery($query->andWhere("status >= ? AND status <= ?", array(Matchs::STATUS_NOT_STARTED, Matchs::STATUS_END_MATCH))->orderBy("enable DESC, status DESC"));
     $this->pager->setPage($request->getParameter('page', 1));
     $this->pager->init();
     $this->buttons = array();
     foreach ($this->pager->getResults() as $result) {
         $this->buttons[] = $this->executeMatchsActions($request, $result);
     }
     $this->url = "@matchs_current_page";
     $this->servers = ServersTable::getInstance()->findAll();
     $this->seasons = SeasonsTable::getInstance()->findAll();
     $this->ebot_ip = sfConfig::get("app_ebot_ip");
     $this->ebot_port = sfConfig::get("app_ebot_port");
 }
Example #3
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->seasons = SeasonsTable::getInstance()->findAll();
 }