Beispiel #1
0
 public function treatAction()
 {
     $enemyMapper = new EnemyMapper();
     $groupMapper = new GroupMapper();
     $warMapper = new WarMapper();
     $warModel = new WarModel();
     $gameMapper = new GamesMapper();
     $gameModel = new GamesModel();
     if ($this->getRequest()->getParam('id')) {
         $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('manageWarOverview'), array('action' => 'index'))->add($this->getTranslator()->trans('manageWar'), array('action' => 'treat'));
         $war = $warMapper->getWarById($this->getRequest()->getParam('id'));
         $this->getView()->set('war', $war);
         $this->getView()->set('warOptXonx', $warMapper->getWarOptDistinctXonx());
         $this->getView()->set('warOptGame', $warMapper->getWarOptDistinctGame());
         $this->getView()->set('warOptMatchtype', $warMapper->getWarOptDistinctMatchtype());
     } else {
         $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('manageWarOverview'), array('action' => 'index'))->add($this->getTranslator()->trans('menuActionNewWar'), array('action' => 'treat'));
     }
     if ($this->getRequest()->isPost()) {
         if ($this->getRequest()->getPost('warMapPlayed')) {
             $warId = $this->getRequest()->getParam('id');
             $maps = $this->getRequest()->getPost('warMapPlayed');
             $groupPoints = $this->getRequest()->getPost('warErgebnisGroup');
             $enemyPoints = $this->getRequest()->getPost('warErgebnisEnemy');
             $errorMaps = array_keys($groupPoints, true);
             if (empty($errorMaps)) {
                 $this->addMessage('missingWarMapPlayed', 'danger');
             } elseif (empty($groupPoints)) {
                 $this->addMessage('missingGroupPoints', 'danger');
             } elseif (empty($enemyPoints)) {
                 $this->addMessage('missingEnemyPoints', 'danger');
             } else {
                 for ($i = 0; $i < count($maps); $i++) {
                     $gameModel->setWarId($warId);
                     $gameModel->setMap($maps[$i]);
                     $gameModel->setGroupPoints($groupPoints[$i]);
                     $gameModel->setEnemyPoints($enemyPoints[$i]);
                     $gameMapper->save($gameModel);
                 }
                 $this->getView()->set('error', $errorMaps);
             }
         }
         if ($this->getRequest()->getParam('id')) {
             $warModel->setId($this->getRequest()->getParam('id'));
         }
         if ($this->getRequest()->getPost('warXonx') == 'neu') {
             $warXonx = $this->getRequest()->getPost('warXonxNew');
         } else {
             $warXonx = $this->getRequest()->getPost('warXonx');
         }
         if ($this->getRequest()->getPost('warGame') == 'neu') {
             $warGame = $this->getRequest()->getPost('warGameNew');
         } else {
             $warGame = $this->getRequest()->getPost('warGame');
         }
         if ($this->getRequest()->getPost('warMatchtype') == 'neu') {
             $warMatchtype = $this->getRequest()->getPost('warMatchtypeNew');
         } else {
             $warMatchtype = $this->getRequest()->getPost('warMatchtype');
         }
         $enemyName = trim($this->getRequest()->getPost('warEnemy'));
         $groupName = trim($this->getRequest()->getPost('warGroup'));
         $warTime = new \Ilch\Date(trim($this->getRequest()->getPost('warTime')));
         $warMap = trim($this->getRequest()->getPost('warMap'));
         $warServer = trim($this->getRequest()->getPost('warServer'));
         $warPassword = $this->getRequest()->getPost('warPassword');
         $warReport = $this->getRequest()->getPost('warReport');
         $warStatus = $this->getRequest()->getPost('warStatus');
         if (empty($enemyName)) {
             $this->addMessage('missingEnemyName', 'danger');
         } elseif (empty($groupName)) {
             $this->addMessage('missingGroupName', 'danger');
         } elseif (empty($warTime)) {
             $this->addMessage('missingWarTime', 'danger');
         } elseif (empty($warServer)) {
             $this->addMessage('missingWarServer', 'danger');
         } elseif (empty($warXonx)) {
             $this->addMessage('missingWarXonx', 'danger');
         } elseif (empty($warGame)) {
             $this->addMessage('missingWarGame', 'danger');
         } elseif (empty($warMatchtype)) {
             $this->addMessage('missingWarMatchtype', 'danger');
         } else {
             $warModel->setWarEnemy($enemyName);
             $warModel->setWarGroup($groupName);
             $warModel->setWarTime($warTime);
             $warModel->setWarMaps($warMap);
             $warModel->setWarServer($warServer);
             $warModel->setWarPassword($warPassword);
             $warModel->setWarXonx($warXonx);
             $warModel->setWarGame($warGame);
             $warModel->setWarMatchtype($warMatchtype);
             $warModel->setWarReport($warReport);
             $warModel->setWarStatus($warStatus);
             $warMapper->save($warModel);
             $this->addMessage('saveSuccess');
             $this->redirect(array('action' => 'index'));
         }
     }
     $this->getView()->set('group', $groupMapper->getGroups());
     $this->getView()->set('enemy', $enemyMapper->getEnemy());
     $this->getView()->set('warOptXonx', $warMapper->getWarOptDistinctXonx());
     $this->getView()->set('warOptGame', $warMapper->getWarOptDistinctGame());
     $this->getView()->set('warOptMatchtype', $warMapper->getWarOptDistinctMatchtype());
 }
Beispiel #2
0
 public function getWarListByStatusAndLimt($status = NULL, $limit = NULL)
 {
     $sql = 'SELECT SQL_CALC_FOUND_ROWS w.id as war_id,w.enemy,w.group,w.time,w.maps,w.server,w.password,w.xonx,w.game,w.matchtype,w.report,w.status,g.name as group_name,g.tag as group_tag,g.id as group_id,e.name as enemy_name,e.tag as enemy_tag,e.id as enemy_id
             FROM `[prefix]_war` as w
             LEFT JOIN [prefix]_war_groups as g ON w.group = g.id
             LEFT JOIN [prefix]_war_enemy as e ON w.enemy = e.id
             WHERE status = "' . $status . '"
             ORDER by w.id DESC
             LIMIT ' . $limit;
     $warArray = $this->db()->queryArray($sql);
     if (empty($warArray)) {
         return null;
     }
     $entry = array();
     foreach ($warArray as $entries) {
         $entryModel = new WarModel();
         $entryModel->setId($entries['war_id']);
         $entryModel->setWarEnemy($entries['enemy_name']);
         $entryModel->setWarEnemyTag($entries['enemy_tag']);
         $entryModel->setWarGroup($entries['group_name']);
         $entryModel->setWarGroupTag($entries['group_tag']);
         $entryModel->setWarTime($entries['time']);
         $entryModel->setWarMaps($entries['maps']);
         $entryModel->setWarServer($entries['server']);
         $entryModel->setWarPassword($entries['password']);
         $entryModel->setWarXonx($entries['xonx']);
         $entryModel->setWarGame($entries['game']);
         $entryModel->setWarMatchtype($entries['matchtype']);
         $entryModel->setWarReport($entries['report']);
         $entryModel->setWarStatus($entries['status']);
         $entry[] = $entryModel;
     }
     return $entry;
 }