Beispiel #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;
 }
 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;
 }
Beispiel #3
0
 function _saveDo()
 {
     JRequest::checkToken() or die('Invalid Token');
     // Instanz der Tabelle
     $row = JTable::getInstance('turniere', 'TableCLM');
     $row->load($this->turnierid);
     // Daten zu dieser ID laden
     $clmAccess = clm_core::$access;
     if ($row->tl != clm_core::$access->getJid() and $clmAccess->access('BE_tournament_edit_detail') !== true or $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;
     }
     $turnier = $this->turnierid;
     $task = JRequest::getVar('task');
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     // JArrayHelper::toInteger($cid, array(0));
     // weiteren Daten aus TlnTabelle
     $query = "SELECT MAX(mgl_nr), MAX(snr) FROM `#__clm_turniere_tlnr`" . " WHERE turnier = " . $this->turnierid;
     $this->_db->setQuery($query);
     list($maxFzps, $maxSnr) = $this->_db->loadRow();
     $maxFzps++;
     // fiktive ZPS für manuell eingegeben Spieler
     $maxSnr++;
     // maximale snr für alle Spieler
     // Turnierdaten
     $tournament = new CLMTournament($this->turnierid, true);
     $playersIn = $tournament->getPlayersIn();
     $turParams = new clm_class_params($tournament->data->params);
     $param_useastwz = $turParams->get('useAsTWZ', 0);
     // Turnier schon vorher voll?
     if (!$this->_checkTournamentOpen($playersIn, $tournament->data->teil)) {
         return false;
     }
     $name = trim(JRequest::getVar('name'));
     // Spieler aus manueller Nachmeldung speichern
     if ($name != "") {
         // weitere Angaben holen
         $verein = JRequest::getString('verein');
         // $dwz = JRequest::getInt('dwz');
         $natrating = JRequest::getInt('natrating', 0);
         $fideelo = JRequest::getInt('fideelo', 0);
         $titel = JRequest::getString('titel');
         $geschlecht = JRequest::getString('geschlecht', 'NULL');
         $birthYear = JRequest::getString('birthYear', '0000');
         $twz = clm_core::$load->gen_twz($param_useastwz, $natrating, $fideelo);
         $query = " INSERT INTO #__clm_turniere_tlnr" . " (`sid`, `turnier`, `snr`, `name`, `birthYear`, `geschlecht`, `verein`, `twz`, `start_dwz`, `FIDEelo`, `titel`, `mgl_nr` ,`zps`)" . " VALUES" . " ('" . $tournament->data->sid . "', '" . $this->turnierid . "', '" . $maxSnr++ . "', '{$name}', '{$birthYear}', '{$geschlecht}', '{$verein}', '{$twz}', '{$natrating}', '{$fideelo}', '{$titel}', '" . $maxFzps . "', '99999')";
         $this->_db->setQuery($query);
         if ($this->_db->query()) {
             $this->app->enqueueMessage(JText::_('PLAYER') . " " . $name . " " . JText::_('ADDED'));
             $playersIn++;
             // den angemeldeten Spielern zufügen
             return true;
         } else {
             $this->app->enqueueMessage(JText::_('DB_ERROR'));
             return false;
         }
     }
     // wenn hier ein Spieler eingetragen wurde, geht es nicht mehr durch die Liste...
     foreach ($cid as $id) {
         // noch Platz im Turnier?
         if ($this->_checkTournamentOpen($playersIn, $tournament->data->teil)) {
             // ausgelesene Daten
             $mgl = substr($id, 5);
             if (!is_numeric($mgl)) {
                 $mgl = -1;
             }
             $zps = substr($id, 0, 5);
             // weitere Daten des Spielers ermitteln
             // in CLM DB suchen
             $query = "SELECT a.Spielername, a.Geburtsjahr, a.Geschlecht, a.FIDE_Titel, a.FIDE_Elo, a.FIDE_ID, FIDE_Land, a.DWZ, v.Vereinname" . " FROM `#__clm_dwz_spieler` as a" . " LEFT JOIN #__clm_dwz_vereine as v ON v.ZPS = a.ZPS" . " LEFT JOIN #__clm_saison as s ON s.id = a.sid " . " WHERE a.ZPS = '{$zps}'" . " AND a.Mgl_Nr = " . $mgl . " AND s.archiv = 0 " . " AND a.sid = " . clm_core::$access->getSeason();
             $this->_db->setQuery($query);
             $data = $this->_db->loadObject();
             if (isset($data->Spielername)) {
                 // checken ob Spieler schon eingetragen, um Doppelungen zu vermeiden
                 $query = "SELECT COUNT(*) FROM #__clm_turniere_tlnr" . " WHERE `turnier` = '" . $this->turnierid . "' AND `mgl_nr` = '{$mgl}' AND `zps` = '{$zps}'";
                 $this->_db->setQuery($query);
                 if ($this->_db->loadResult() > 0) {
                     JError::raiseWarning(500, JText::_('PLAYER') . " " . $data->Spielername . " " . JText::_('ALREADYIN'));
                 } else {
                     $twz = clm_core::$load->gen_twz($param_useastwz, $data->DWZ, $data->FIDE_Elo);
                     $query = " INSERT INTO #__clm_turniere_tlnr" . " (`sid`, `turnier`, `snr`, `name`, `birthYear`, `geschlecht`, `verein`, `twz`, `start_dwz`, `FIDEelo`, `FIDEid`, `FIDEcco`, `titel`,`mgl_nr` ,`zps`) " . " VALUES" . " ('" . $tournament->data->sid . "','" . $this->turnierid . "', '" . $maxSnr++ . "', '" . clm_escape($data->Spielername) . "', '" . $data->Geburtsjahr . "', '" . $data->Geschlecht . "','" . clm_escape($data->Vereinname) . "', '" . $twz . "', '" . $data->DWZ . "', '" . $data->FIDE_Elo . "', '" . $data->FIDE_ID . "', '" . $data->FIDE_Land . "', '" . $data->FIDE_Titel . "', '{$mgl}', '{$zps}')";
                     $this->_db->setQuery($query);
                     if ($this->_db->query()) {
                         $playersIn++;
                         $this->app->enqueueMessage(JText::_('PLAYER') . " " . $data->Spielername . " " . JText::_('ADDED'));
                     } else {
                         JError::raiseWarning(500, JText::_('DB_ERROR'));
                     }
                 }
             } else {
                 JError::raiseWarning(500, CLMText::errorText('PLAYER', 'UNKNOWN'));
             }
         }
         // sonst war Turnier voll
     }
     // je nach Task: Message und Weiterleitung
     switch ($task) {
         case 'apply':
             $stringAktion = JText::_('PLAYERS_ADDED');
             break;
         case 'save':
         default:
             $stringAktion = JText::_('PLAYERS_SAVED');
             $this->adminLink->view = "turplayers";
             // WL in Liste
             break;
     }
     // Plätze frei?
     $openSpots = $tournament->data->teil - $playersIn;
     if ($openSpots > 0) {
         JError::raiseNotice(500, JText::_('PARTICIPANTS_WANTED') . ": " . $openSpots);
     } else {
         JError::raiseNotice(500, CLMText::errorText('PARTICIPANTLIST', 'FULL'));
     }
     // Message
     // $this->app->enqueueMessage($stringAktion);
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = $stringAktion;
     $clmLog->params = array('sid' => $tournament->data->sid, 'tid' => $this->turnierid);
     // TurnierID wird als LigaID gespeichert
     $clmLog->write();
     return true;
 }
 function _saveDo()
 {
     // 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;
     }
     // Für runden_termine update
     $user = JFactory::getUser();
     // Turnierdaten sammeln
     $tournament = new CLMTournament($this->turnierid, true);
     $this->teil = $tournament->data->teil;
     $turParams = new clm_class_params($tournament->data->params);
     $pgnInput = $turParams->get('pgnInput', 1);
     // Anzahl gemeldeter Teilnehmer sammeln
     $sum_tln = $tournament->getPlayersIn();
     // Anzahl Spieler abgleichen bevor gemeldet werden kann
     if ($sum_tln != $this->teil) {
         $diff = $this->teil - $sum_tln;
         JError::raiseWarning(500, JText::_('INSUFFICIENT_PLAYERS_REGISTERED'));
         JError::raiseNotice(6000, JText::_('ADD_PLAYERS_OR_CHANGE_PARAMETERS'));
         return false;
     }
     // Reale RundenNummer, DG aus RundenID ermitteln - zudem 'gemeldet' für späteren Abgleich
     $query = 'SELECT nr, dg, gemeldet, tl_ok' . ' FROM #__clm_turniere_rnd_termine' . ' WHERE id = ' . $this->roundid;
     $this->_db->setQuery($query);
     list($runde, $dg, $gemeldet, $tl_ok) = $this->_db->loadRow();
     if ($tl_ok == 1) {
         // Runden schon bestätigt?
         JError::raiseWarning(500, CLMText::errorText(JText::_('ROUND'), 'ALREADYAPPROVED'));
         return false;
     }
     // Datensätze in Spielertabelle schreiben
     // convert Array nur für SCHWARZ !!
     $convert = array(0 => 1, 0, 2, 3, 5, 4, 6, 7, 8, 10, 9);
     // andere Matrix für eid
     // daten ermitteln
     $array_w = JRequest::getVar('w');
     $array_b = JRequest::getVar('b');
     $array_res = JRequest::getVar('res');
     if ($pgnInput == 1) {
         $array_pgn = JRequest::getVar('pgn');
     }
     $array_ergebnis = array();
     // Array für bisherige Ergebnisse (Weiß)
     if ($tournament->data->typ == 3 or $tournament->data->typ == 5) {
         // KO
         $array_tiebrS = JRequest::getVar('tiebrS');
         $array_tiebrG = JRequest::getVar('tiebrG');
         $array_tiebrS_old = array();
         $array_tiebrG_old = array();
     }
     $array_id = array();
     // Array für ID des nicht-heim-Matches
     $array_idBlack = array();
     // für MatchID des schwarzen Datensatzes
     $array_duplo = array();
     // Array für alle Startnummern, um Doppelungen abzuchecken
     // alle Matches anhand der weißen Daten durchgehen - evtl fehlerhafte Daten ausschließen
     foreach ($array_w as $key => $value) {
         // $key 					- die ID des Matches
         // $value 				- die snr des Weißen
         // $array_b[$key]		- die snr des Schwarzen
         // $array_res[$key]	- dir ID des Ergebnisses
         // check: Match vorhanden? mit 'heim' und in diesem Turnier?
         if ($tournament->data->typ != 3 and $tournament->data->typ != 5) {
             // nicht KO
             // brett ermitteln, um zweiten Match-Datensatz ermitteln zu können
             $query = 'SELECT brett, ergebnis, pgn' . ' FROM #__clm_turniere_rnd_spl' . ' WHERE id = ' . $key . ' AND turnier = \'' . $this->turnierid . '\' AND heim = \'1\'';
             $this->_db->setQuery($query);
             if (!(list($brettBlack, $array_ergebnis[$key], $array_pgnold[$key]) = $this->_db->loadRow())) {
                 JError::raiseWarning(500, JText::_('MATCH_UNKNOWN') . " - ID: " . $key);
                 // aus Array entfernen!
                 unset($array_w[$key]);
             }
         } else {
             // KO
             // brett ermitteln, um zweiten Match-Datensatz ermitteln zu können
             // zudem ergebnis und tiebr nachladen
             $query = 'SELECT brett, ergebnis, tiebrS, tiebrG, pgn' . ' FROM #__clm_turniere_rnd_spl' . ' WHERE id = ' . $key . ' AND turnier = \'' . $this->turnierid . '\' AND heim = \'1\'';
             $this->_db->setQuery($query);
             if (!(list($brettBlack, $array_ergebnis[$key], $array_tiebrS_old[$key], $array_tiebrG_old[$key], $array_pgnold[$key]) = $this->_db->loadRow())) {
                 JError::raiseWarning(500, JText::_('MATCH_UNKNOWN') . " - ID: " . $key);
                 // aus Array entfernen!
                 unset($array_w[$key]);
             }
         }
         // check: zweiter Datensatz zu diesem match vorhanden? anhand von $brett
         // ID ermitteln und zwischenspeichern
         $query = "SELECT id" . " FROM #__clm_turniere_rnd_spl" . " WHERE turnier = '" . $this->turnierid . "' AND runde = '{$runde}' AND dg = '{$dg}' AND heim = '0' AND brett = " . $brettBlack;
         $this->_db->setQuery($query);
         if (!($array_idBlack[$key] = $this->_db->loadResult())) {
             JError::raiseWarning(500, JText::_('MATCH_UNKNOWN') . " - ID: " . $key);
             // aus Array entfernen!
             unset($array_w[$key]);
         } else {
             $array_id[$key] = $id;
         }
         // alle Startnummern in Duplo-Array eintragen (wenn Startnummer vorhanden)
         if ($value > 0) {
             $array_duplo[] = $value;
         }
         if ($array_b[$key] > 0) {
             $array_duplo[] = $array_b[$key];
         }
     }
     // Duplo-Kontrolle - nicht im freien System
     if ($tournament->data->typ != 6 and count($array_duplo) > count(array_unique($array_duplo))) {
         JError::raiseWarning(500, JText::_("PLAYER_ENTERED_TWICE"));
         return false;
     }
     $countChanges = 0;
     // noch vorhandene Matches erneut durchgehen
     foreach ($array_w as $key => $value) {
         // liegt Änderung vor?
         if ($tournament->data->typ != 3 and $tournament->data->typ != 5) {
             // nicht KO
             if (is_null($array_ergebnis[$key]) and $array_res[$key] >= 0 or !is_null($array_ergebnis[$key]) and $array_res[$key] != $array_ergebnis[$key] or $pgnInput == 1 and $array_pgn[$key] != $array_pgnold[$key]) {
                 // Änderung?
                 $countChanges++;
             }
         } else {
             // KO - checkt auch auf tiebreaker-Änderung!
             if (is_null($array_ergebnis[$key]) and $array_res[$key] >= 0 or !is_null($array_ergebnis[$key]) and $array_res[$key] != $array_ergebnis[$key] or $array_tiebrS_old[$key] != $array_tiebrS[$key] or $array_tiebrG_old[$key] != $array_tiebrG[$key] or $pgnInput == 1 and $array_pgn[$key] != $array_pgnold[$key]) {
                 // Änderung?
                 $countChanges++;
                 // dann aber auch ermitteln, wer ausscheidet, und wer im Turnier bleibt.
                 if ($array_res[$key] == 2 or $array_res[$key] == 3 or $array_res[$key] == 6 or $array_res[$key] == 7) {
                     // remis bzw. nicht gespielt
                     //					if ($array_res[$key] == 2) { // remis
                     if ($array_tiebrS[$key] > $array_tiebrG[$key]) {
                         // sofort schreiben
                         $this->_updateTlnrKoStatus($value, 1, $runde);
                         $this->_updateTlnrKoStatus($array_b[$key], 0, $runde);
                     } elseif ($array_tiebrS[$key] < $array_tiebrG[$key]) {
                         // sofort schreiben
                         $this->_updateTlnrKoStatus($value, 0, $runde);
                         $this->_updateTlnrKoStatus($array_b[$key], 1, $runde);
                     } else {
                         // gleich - beide noch drin!
                         $this->_updateTlnrKoStatus($value, 1, $runde);
                         $this->_updateTlnrKoStatus($array_b[$key], 1, $runde);
                     }
                 } elseif ($array_res[$key] == 1 or $array_res[$key] == 5) {
                     // sofort schreiben
                     $this->_updateTlnrKoStatus($value, 1, $runde);
                     $this->_updateTlnrKoStatus($array_b[$key], 0, $runde);
                 } elseif ($array_res[$key] == 0 or $array_res[$key] == 4) {
                     // sofort schreiben
                     $this->_updateTlnrKoStatus($value, 0, $runde);
                     $this->_updateTlnrKoStatus($array_b[$key], 1, $runde);
                 }
             }
         }
         // jetzt die beiden Datesätze updaten
         if ($array_res[$key] == '-1' or $array_res[$key] == '-2') {
             // kein Resultat eingegeben
             $sqlResultW = "NULL";
             $sqlResultB = "NULL";
         } else {
             $sqlResultW = "'" . $array_res[$key] . "'";
             $sqlResultB = "'" . $convert[$array_res[$key]] . "'";
         }
         // für pgn
         if ($pgnInput == 1) {
             $sqlPGN = ", pgn = '" . $array_pgn[$key] . "'";
         } else {
             $sqlPGN = "";
         }
         if ($tournament->data->typ != 3 and $tournament->data->typ != 5) {
             // nicht KO
             // Weiss
             $query = "UPDATE #__clm_turniere_rnd_spl" . " SET ergebnis = " . $sqlResultW . ", tln_nr = '" . $value . "', spieler = '" . $value . "', gegner = '" . $array_b[$key] . "'" . $sqlPGN . " WHERE id = " . $key;
             $this->_db->setQuery($query);
             $this->_db->query();
             // Schwarz
             $query = "UPDATE #__clm_turniere_rnd_spl" . " SET ergebnis = " . $sqlResultB . ", tln_nr ='" . $array_b[$key] . "', spieler ='" . $array_b[$key] . "', gegner ='" . $value . "'" . $sqlPGN . " WHERE id = " . $array_idBlack[$key];
             $this->_db->setQuery($query);
             $this->_db->query();
         } else {
             // KO - auch tiebreak schreiben
             // Weiss
             $query = "UPDATE #__clm_turniere_rnd_spl" . " SET ergebnis = " . $sqlResultW . ", tiebrS = '" . $array_tiebrS[$key] . "', tiebrG = '" . $array_tiebrG[$key] . "', tln_nr = '" . $value . "', spieler = '" . $value . "', gegner = '" . $array_b[$key] . "'" . $sqlPGN . " WHERE id = " . $key;
             $this->_db->setQuery($query);
             $this->_db->query();
             // Schwarz
             $query = "UPDATE #__clm_turniere_rnd_spl" . " SET ergebnis = " . $sqlResultB . ", tiebrS = '" . $array_tiebrG[$key] . "', tiebrG = '" . $array_tiebrS[$key] . "', tln_nr ='" . $array_b[$key] . "', spieler ='" . $array_b[$key] . "', gegner ='" . $value . "'" . $sqlPGN . " WHERE id = " . $array_idBlack[$key];
             $this->_db->setQuery($query);
             $this->_db->query();
         }
     }
     // ergebnisse eingetragen
     // Nachrichten:
     // 1 - Matches wurden gespeichert
     // 2 - Anzahl ($countChanges) geänderter Erebnisse
     JError::raiseNotice(500, JText::_('MATCHES') . ' ' . JText::_('SAVED'));
     $stringAction = CLMText::sgpl($countChanges, JText::_('RESULT'), JText::_('RESULTS')) . " " . JText::_('SAVED') . "/" . JText::_('EDITED');
     JError::raiseNotice(500, $stringAction);
     $tournament->calculateRanking();
     $tournament->setRankingPositions();
     // Runde gemeldet ?
     if ($gemeldet == NULL) {
         $query = "UPDATE #__clm_turniere_rnd_termine" . " SET gemeldet = " . $user->id . ", zeit = NOW()" . " WHERE turnier = " . $this->turnierid . " AND nr = " . $runde . " AND dg = " . $dg;
     } else {
         $query = "UPDATE #__clm_turniere_rnd_termine" . " SET editor = " . $user->id . ", edit_zeit = NOW()" . " WHERE turnier = " . $this->turnierid . " AND nr = " . $runde . " AND dg = " . $dg;
     }
     $this->_db->setQuery($query);
     $this->_db->query();
     // Berechne oder Lösche die inoff. DWZ nach dieser Änderung
     $turParams = new clm_class_params(clm_core::$db->turniere->get($this->turnierid)->params);
     $autoDWZ = $turParams->get("autoDWZ", 0);
     if ($autoDWZ == 0) {
         clm_core::$api->direct("db_tournament_genDWZ", array($this->turnierid, false));
     } else {
         if ($autoDWZ == 1) {
             clm_core::$api->direct("db_tournament_delDWZ", array($this->turnierid, false));
         }
     }
     // Log schreiben
     $clmLog = new CLMLog();
     $clmLog->aktion = $stringAction;
     $clmLog->params = array('tid' => $this->turnierid, 'rnd' => $runde);
     // TurnierID wird als LigaID gespeichert
     $clmLog->write();
     return true;
 }