Example #1
0
 function checkData()
 {
     // aktuelle Turnierdaten laden
     $tournament = new CLMTournament($this->id, true);
     if (trim($this->name) == '') {
         // Name vorhanden
         $this->setError(CLMText::errorText('NAME', 'MISSING'));
         return false;
     } elseif ($this->sid <= 0) {
         // SaisonID > 0
         $this->setError(CLMText::errorText('SEASON', 'IMPOSSIBLE'));
         return false;
     } elseif (!is_numeric($this->teil)) {
         // Teilnehmerzahl = Zahl
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'NOTANUMBER'));
         return false;
     } elseif ($this->teil <= 1) {
         // Teilnehmerzahl >= 2
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'TOOLOW'));
         return false;
     } elseif ($this->teil > 500) {
         // Teilnehmerzahl
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'TOOBIG'));
         return false;
     } elseif ($this->teil < $tournament->getPlayersIn()) {
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'MOREPLAYERSIN'));
         return false;
     } elseif (!is_numeric($this->runden)) {
         // Runden = Zahl
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'NOTANUMBER'));
         return false;
     } elseif ($this->runden < 1) {
         // Runden >= 2
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'TOOLOW'));
         return false;
     } elseif ($this->runden > 50) {
         // Runden
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'TOOBIG'));
         return false;
     } elseif ($this->typ != 3 and ($this->dg < 1 or $this->dg > 4)) {
         // DG möglich
         $this->setError(CLMText::errorText('STAGE_COUNT', 'IMPOSSIBLE'));
         return false;
         // Runden schon erstellt? dann keine Änderung Typ, Runden, dg möglich!
     } elseif ($this->typ != $tournament->data->typ and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('MODUS', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->runden != $tournament->data->runden and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->dg != $tournament->data->dg and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('STAGE_COUNT', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->teil != $tournament->data->teil and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'ROUNDSCREATED'));
         return false;
         /*		} elseif ($this->tl <= 0) {
         			$this->setError( CLMText::errorText('TOURNAMENT_DIRECTOR', 'MISSING') );
         			return false;
         */
     } elseif ($this->tiebr2 != 0 and $this->tiebr2 == $this->tiebr1 or $this->tiebr3 != 0 and ($this->tiebr3 == $this->tiebr1 or $this->tiebr3 == $this->tiebr2)) {
         $this->setError(CLMText::errorText('TIEBREAKERS', 'NOTDISTINCT'));
         return false;
     }
     // Endtag gegegeben und Datum geändert?
     if ($this->dateEnd != '0000-00-00' and ($this->dateStart != $tournament->data->dateStart or $this->dateEnd != $tournament->data->dateEnd)) {
         // zerlegen
         list($startY, $startM, $startD) = explode("-", $this->dateStart);
         list($endY, $endM, $endD) = explode("-", $this->dateEnd);
         // Endtag kleiner Starttag?
         if (mktime(0, 0, 0, $startM, $startD, $startY) > mktime(0, 0, 0, $endM, $endD, $endY)) {
             $this->setError(CLMText::errorText('TOURNAMENT_DAYEND', 'TOOLOW'));
             return false;
         }
     }
     // wurde eine Feinwertung verändert?
     if ($this->tiebr1 != $tournament->data->tiebr1 or $this->tiebr2 != $tournament->data->tiebr2 or $this->tiebr3 != $tournament->data->tiebr3) {
         // Rangliste neu berechnen
         $tournament->setRankingPositions();
     }
     return true;
 }
Example #2
0
 function store()
 {
     $rcount = JRequest::getVar('rcount', '', 'post', 'int');
     $rlast = JRequest::getVar('rlast', '', 'post', 'int');
     // Rundeninformationen in Datenbank schreiben
     if (!$this->_storeRundenInfos()) {
         return false;
     }
     // Paarungen in Datenbank schreiben
     if (!$this->_storePaarungen()) {
         return false;
     }
     if ($rlast < $rcount) {
         return true;
     }
     //Spielfreidummys l�schen
     if (!$this->_deleteSpielfreiDummys()) {
         return false;
     }
     //Kopieren in CLM-Tabellen
     if (!$this->_copyToCLMTables()) {
         return false;
     }
     $turnier = new CLMTournament($this->_tid, true);
     //Punkte und Feinwertungen neu berechnen
     $turnier->calculateRanking();
     //Rangliste neu berechnen
     $turnier->setRankingPositions();
     //Import war erfolgreich
     return true;
 }
 function _saveDo()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     if (CLM_usertype != 'admin' and CLM_usertype != 'tl') {
         JError::raiseWarning(500, JText::_('SECTION_NO_ACCESS'));
         return FALSE;
     }
     // Task
     $task = JRequest::getVar('task');
     // Instanz der Tabelle
     $row =& JTable::getInstance('turniere', 'TableCLM');
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $row->getError());
         return FALSE;
     }
     // Rundenzahl berechnen!
     if ($row->typ == 2) {
         $tempTeil = $row->teil;
         if ($tempTeil % 2 != 0) {
             // gerade machen
             $tempTeil++;
         }
         $row->runden = $tempTeil - 1;
     } elseif ($row->typ == 3) {
         $row->runden = ceil(log($row->teil) / log(2));
     }
     // Parameter
     $paramsStringArray = array();
     foreach ($row->params as $key => $value) {
         $paramsStringArray[] = $key . '=' . intval($value);
     }
     $row->params = implode("\n", $paramsStringArray);
     if (!$row->checkData()) {
         // pre-save checks
         JError::raiseWarning(500, $row->getError());
         // Weiterleitung bleibt im Formular !!
         $this->adminLink->more = array('task' => $task, 'id' => $row->id);
         return FALSE;
     }
     // if new item, order last in appropriate group
     if (!$row->id) {
         $this->neu = TRUE;
         // Flag für neues Turnier
         $stringAktion = JText::_('TOURNAMENT_CREATED');
         // $where = "sid = " . (int) $row->sid; warum nur in Saison?
         $row->ordering = $row->getNextOrder();
         // ( $where );
     } else {
         $this->neu = FALSE;
         $stringAktion = JText::_('TOURNAMENT_EDITED');
     }
     // save the changes
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     $row->checkin();
     // bei bereits bestehendem Turnier noch calculateRanking
     if (!$this->neu) {
         $tournament = new CLMTournament($row->id, TRUE);
         $tournament->calculateRanking();
         $tournament->setRankingPositions();
     }
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = $stringAktion . ": " . $row->name;
     $clmLog->params = array('sid' => $row->sid, 'tid' => $row->id);
     // TurnierID wird als LigaID gespeichert
     $clmLog->write();
     // wenn 'apply', weiterleiten in form
     if ($task == 'apply') {
         // Weiterleitung bleibt im Formular
         $this->adminLink->more = array('task' => 'edit', 'id' => $row->id);
     } else {
         // Weiterleitung in Liste
         $this->adminLink->view = "turmain";
         // WL in Liste
     }
     return TRUE;
 }
 function checkData()
 {
     // aktuelle Turnierdaten laden
     $tournament = new CLMTournament($this->id, TRUE);
     if (trim($this->name) == '') {
         // Name vorhanden
         $this->setError(CLMText::errorText('NAME', 'MISSING'));
         return false;
     } elseif ($this->sid <= 0) {
         // SaisonID > 0
         $this->setError(CLMText::errorText('SEASON', 'IMPOSSIBLE'));
         return false;
     } elseif (!is_numeric($this->teil)) {
         // Teilnehmerzahl = Zahl
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'NOTANUMBER'));
         return false;
     } elseif ($this->teil <= 1) {
         // Teilnehmerzahl >= 2
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'TOOLOW'));
         return false;
     } elseif ($this->teil > 500) {
         // Teilnehmerzahl
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'TOOBIG'));
         return false;
     } elseif ($this->teil < $tournament->getPlayersIn()) {
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'MOREPLAYERSIN'));
         return false;
     } elseif (!is_numeric($this->runden)) {
         // Runden = Zahl
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'NOTANUMBER'));
         return false;
     } elseif ($this->runden < 1) {
         // Runden >= 2
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'TOOLOW'));
         return false;
     } elseif ($this->runden > 50) {
         // Runden
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'TOOBIG'));
         return false;
     } elseif ($this->typ != 3 and ($this->dg < 1 or $this->dg > 2)) {
         // DG möglich
         $this->setError(CLMText::errorText('STAGE_COUNT', 'IMPOSSIBLE'));
         return false;
         // Runden schon erstellt? dann keine Änderung Typ, Runden, dg möglich!
     } elseif ($this->typ != $tournament->data->typ and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('MODUS', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->runden != $tournament->data->runden and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('ROUNDS_COUNT', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->dg != $tournament->data->dg and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('STAGE_COUNT', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->teil != $tournament->data->teil and $tournament->data->rnd == 1) {
         $this->setError(CLMText::errorText('PARTICIPANT_COUNT', 'ROUNDSCREATED'));
         return false;
     } elseif ($this->tl <= 0) {
         $this->setError(CLMText::errorText('TOURNAMENT_DIRECTOR', 'MISSING'));
         return false;
     } elseif ($this->tiebr2 != 0 and $this->tiebr2 == $this->tiebr1 or $this->tiebr3 != 0 and ($this->tiebr3 == $this->tiebr1 or $this->tiebr3 == $this->tiebr2)) {
         $this->setError(CLMText::errorText('TIEBREAKERS', 'NOTDISTINCT'));
         return false;
     }
     // wurde eine Feinwertung verändert?
     if ($this->tiebr1 != $tournament->data->tiebr1 or $this->tiebr2 != $tournament->data->tiebr2 or $this->tiebr3 != $tournament->data->tiebr3) {
         // Rangliste neu berechnen
         $tournament->setRankingPositions();
     }
     return true;
 }
Example #5
0
 function _setRankingDo()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $clmAccess = clm_core::$access;
     if ($clmAccess->access('BE_tournament_edit_detail') === false) {
         //if (clm_core::$access->getType() != 'admin' AND clm_core::$access->getType() != 'tl') {
         JError::raiseWarning(500, JText::_('TOURNAMENT_NO_ACCESS'));
         return false;
     }
     $tournament = new CLMTournament($this->id, true);
     $tournament->checkTournamentStarted();
     if (!$tournament->started) {
         JError::raiseWarning(500, JText::_('RANKING_NOT_POSSIBLE') . ": " . JText::_('NO_RESULTS_ENTERED'));
         return false;
     } elseif ($tournament->data->typ == 3) {
         JError::raiseWarning(500, JText::_('RANKING_NOT_POSSIBLE') . ": " . JText::_('MODUS_TYP_3'));
         return false;
     }
     $tournament->calculateRanking();
     $tournament->setRankingPositions();
     $stringMessage = JText::_('SET_RANKING_DONE');
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = $stringMessage;
     $clmLog->params = array('sid' => $tournament->data->sid, 'tid' => $this->id);
     $clmLog->write();
     $app = JFactory::getApplication();
     $app->enqueueMessage($stringMessage);
     return true;
 }
 function _setRankingDo()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     if (CLM_usertype != 'admin' and CLM_usertype != 'tl') {
         JError::raiseWarning(500, JText::_('TOURNAMENT_NO_ACCESS'));
         return FALSE;
     }
     $tournament = new CLMTournament($this->id, TRUE);
     $tournament->checkTournamentStarted();
     if (!$tournament->started) {
         JError::raiseWarning(500, JText::_('RANKING_NOT_POSSIBLE') . ": " . JText::_('NO_RESULTS_ENTERED'));
         return FALSE;
     } elseif ($tournament->data->typ == 3) {
         JError::raiseWarning(500, JText::_('RANKING_NOT_POSSIBLE') . ": " . JText::_('MODUS_TYP_3'));
         return FALSE;
     }
     $tournament->calculateRanking();
     $tournament->setRankingPositions();
     $stringMessage = JText::_('SET_RANKING_DONE');
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = $stringMessage;
     $clmLog->params = array('sid' => $tournament->data->sid, 'tid' => $this->id);
     $clmLog->write();
     $app =& JFactory::getApplication();
     $app->enqueueMessage($stringMessage);
     return TRUE;
 }
 function _deleteDo()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     // Instanz der Tabelle
     $row = JTable::getInstance('turniere', 'TableCLM');
     $row->load($this->turnierid);
     $clmAccess = clm_core::$access;
     if ($row->tl != clm_core::$access->getJid() and $clmAccess->access('BE_tournament_edit_round') !== true or $clmAccess->access('BE_tournament_edit_round') === false) {
         JError::raiseWarning(500, JText::_('TOURNAMENT_NO_ACCESS'));
         return false;
     }
     $user = JFactory::getUser();
     // Reale RundenNummer, DG aus RundenID ermitteln, tl_ok
     $query = 'SELECT sid, nr, dg, tl_ok' . ' FROM #__clm_turniere_rnd_termine' . ' WHERE id = ' . $this->roundid;
     $this->_db->setQuery($query);
     list($sid, $runde, $dg, $tl_ok) = $this->_db->loadRow();
     // wenn Runde schon bestätigt, löschen nicht erlauben
     if ($tl_ok == 1) {
         JError::raiseWarning(500, CLMText::errorText('ROUND', 'ALREADYAPPROVED'));
         return false;
     }
     // bisher höchstes Brett dieser Runde ermitteln
     $query = 'SELECT MAX(brett)' . ' FROM #__clm_turniere_rnd_spl' . ' WHERE turnier = ' . $this->turnierid . ' AND runde = ' . $runde;
     $this->_db->setQuery($query);
     list($brettMax) = $this->_db->loadRow();
     //echo "<br>brettM: ".$brettMax."  "; //var_dump(list($brettMax));
     // letzte Paarung löschen
     $query = "DELETE FROM #__clm_turniere_rnd_spl" . " WHERE sid = " . $sid . " AND turnier = " . $this->turnierid . "   AND runde = " . $runde . " AND brett = " . $brettMax . " LIMIT 2 ";
     //echo "<br>query: ".$query; //die('  del?');
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         JError::raiseError(500, $this->_db->getErrorMsg());
     }
     JError::raiseNotice(500, JText::_('MATCH_DELETED'));
     // Rangliste neu berechnen!
     $tournament = new CLMTournament($this->turnierid, true);
     $tournament->calculateRanking();
     $tournament->setRankingPositions();
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = JText::_('MATCH_DELETED');
     $clmLog->params = array('tid' => $this->turnierid, 'rnd' => $this->roundid);
     // TurnierID wird als LigaID gespeichert
     $clmLog->write();
     return true;
 }
 function _resetDo()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     if (CLM_usertype != 'admin' and CLM_usertype != 'tl') {
         JError::raiseWarning(500, JText::_('TOURNAMENT_NO_ACCESS'));
         return FALSE;
     }
     $user =& JFactory::getUser();
     // Reale RundenNummer, DG aus RundenID ermitteln, tl_ok
     $query = 'SELECT nr, dg, tl_ok' . ' FROM #__clm_turniere_rnd_termine' . ' WHERE id = ' . $this->roundid;
     $this->_db->setQuery($query);
     list($runde, $dg, $tl_ok) = $this->_db->loadRow();
     // wenn Runde schon bestätigt, zurücksetzen nicht erlauben
     if ($tl_ok == 1) {
         JError::raiseWarning(500, CLMText::errorText('ROUND', 'ALREADYAPPROVED'));
         return FALSE;
     }
     // sind überhaupt Ergebnisse eingetragen?
     $query = "SELECT COUNT(*) FROM #__clm_turniere_rnd_spl" . " WHERE turnier = " . $this->turnierid . " AND runde = " . $runde . " AND dg = " . $dg . " AND ergebnis IS NOT NULL";
     $this->_db->setQuery($query);
     $resultCount = $this->_db->loadResult();
     if ($resultCount == 0) {
         JError::raiseWarning(500, CLMText::errorText('RESULTS', 'NOTEXISTING'));
         return FALSE;
     }
     // Runde anpassen
     $query = "UPDATE #__clm_turniere_rnd_termine" . " SET gemeldet = NULL, zeit ='000e0-00-00 00:00:00', editor = " . $user->id . ", edit_zeit = NOW()" . " WHERE id = " . $this->roundid;
     $this->_db->setQuery($query);
     $this->_db->query();
     // Ergebnisse löschen
     $query = "UPDATE #__clm_turniere_rnd_spl" . " SET ergebnis = NULL" . " WHERE turnier = " . $this->turnierid . " AND runde = " . $runde . " AND dg = " . $dg;
     $this->_db->setQuery($query);
     $this->_db->query();
     JError::raiseNotice(500, CLMText::sgpl($resultCount / 2, JText::_('RESULT'), JText::_('RESULTS')) . " " . JText::_('RESET'));
     // Rangliste neu berechnen!
     $tournament = new CLMTournament($this->turnierid, TRUE);
     $tournament->calculateRanking();
     $tournament->setRankingPositions();
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = JText::_('RESULTS') . " " . JText::_('RESET');
     $clmLog->params = array('tid' => $this->turnierid, 'rnd' => $this->roundid);
     // TurnierID wird als LigaID gespeichert
     $clmLog->write();
     return TRUE;
 }