示例#1
0
function UpdatePreOpen($TournamentID)
{
    // checks if the structure of the database is consistent
    //	CheckDbStructure();
    $DbVersion = GetParameter('DBUpdate');
    $rs = safe_r_SQL("SELECT ToDbVersion, ToType, ToNumSession FROM Tournament WHERE ToId='{$TournamentID}'");
    $row = safe_fetch($rs);
    $version = $row->ToDbVersion;
    if ($version < '2010-11-26 15:50:00') {
        updateEnTimeStamp_20101126($TournamentID);
        to_save_version($TournamentID, '2010-11-26 15:50:00');
    }
    if ($version < '2010-12-11 20:30:00') {
        recalculateIndividuals_20101211($TournamentID);
        to_save_version($TournamentID, '2010-12-11 20:30:00');
    }
    if ($version < '2011-02-16 15:42:00') {
        // metto a posto il numero max di persone nei team
        calcMaxTeamPerson_20110216($TournamentID);
        // ricalcolo le rank a squadra
        recalculateTeamRanking_20110216($TournamentID);
        to_save_version($TournamentID, '2011-02-16 15:42:00');
    }
    if ($version < '2011-03-09 14:38:00') {
        initTourGoldsXNineChars_20110309($TournamentID);
        to_save_version($TournamentID, '2011-03-09 14:38:00');
    }
    if ($version < '2011-04-15 15:55:00') {
        RecalcFinRank_20110415($TournamentID);
        to_save_version($TournamentID, '2011-04-15 15:55:00');
    }
    if ($version < '2012-01-11 10:20:00') {
        Update3DIta_20120111($TournamentID);
        to_save_version($TournamentID, '2012-01-11 10:20:00');
    }
    if ($version < '2012-01-24 15:16:00') {
        $q = insertIntoGridForF2F_21($TournamentID);
        $rs2 = safe_w_sql($q, false, array(1062));
        to_save_version($TournamentID, '2012-01-24 15:16:00');
    }
    if ($version < '2012-05-18 07:10:00') {
        safe_w_sql("update Divisions set DivWaDivision=DivId, DivRecDivision=DivId where DivWaDivision='' or DivRecDivision=''");
        safe_w_sql("update Classes set ClWaClass=ClId, ClRecClass=ClId where ClWaClass='' or ClRecClass=''");
        safe_w_sql("update Events set EvWaCategory=EvCode, EvRecCategory=EvCode where EvWaCategory='' or EvRecCategory=''");
        to_save_version($TournamentID, '2012-05-18 07:10:00');
    }
    if ($version < '2013-12-19 12:30:00') {
        // Updating DistanceInformation
        require_once 'Modules/Sets/lib.php';
        require_once 'Tournament/Fun_ManSessions.inc.php';
        $Distances = getDistanceArrays($row->ToType);
        $q = safe_r_sql("select SesAth4Target, SesOrder from Session where SesTournament={$TournamentID}");
        while ($r = safe_fetch($q)) {
            CreateDistanceInformation($TournamentID, $Distances, 0, $r->SesAth4Target, $r->SesOrder);
        }
        to_save_version($TournamentID, '2013-12-19 12:30:00');
    }
    if ($version < '2014-03-22 14:00:00') {
        UpdateWinLose_20140322($TournamentID);
        to_save_version($TournamentID, '2014-03-22 14:00:00');
    }
    if ($version < '2014-04-01 00:00:00') {
        UpdateItaRules_20140401($TournamentID);
        to_save_version($TournamentID, '2014-04-01 00:00:00');
    }
    if ($version < '2014-05-23 16:00:00') {
        safe_w_sql("update Scheduler\n\t\t\tleft join Session on SchTournament=SesTournament and SchSesOrder=SesOrder and SchSesType=SesType\n\t\t\tset SchDay=date(SchDateStart), SchStart=time(SchDateStart), SchDuration=TIMESTAMPDIFF(MINUTE, SchDateStart, SchDateEnd), SchText=SchDescr, SchTitle=SesName\n\t\t\twhere SchTournament={$TournamentID}");
        $q = safe_r_sql("select * from Scheduler where SchTournament={$TournamentID} and SchDay>0 and SchStart>0 order by SchDay, SchStart, SchOrder desc");
        $oldKeys = array();
        while ($r = safe_fetch($q)) {
            $good = true;
            $key = $r->SchDay . '|' . $r->SchStart;
            while (in_array($key, $oldKeys)) {
                $key++;
                $good = false;
            }
            $oldKeys[] = $key;
            if (!$good) {
                $SQL = "update Scheduler set SchStart='" . substr($key, -8) . "' where SchDay='{$r->SchDay}' and SchStart='{$r->SchStart}' and SchDuration='{$r->SchDuration}' and SchSesOrder={$r->SchSesOrder} and SchOrder={$r->SchOrder} and SchSesType='{$r->SchSesType}' limit 1";
                safe_w_sql($SQL);
            }
        }
        to_save_version($TournamentID, '2014-04-01 00:00:00');
    }
    to_save_version($TournamentID, $DbVersion);
}
示例#2
0
if ($version < '2011-02-10 11:07:00') {
    $MySql = "ALTER TABLE `Teams` CHANGE `TeFinalRank` `TeRankFinal` SMALLINT( 6 ) NOT NULL;";
    safe_w_SQL($MySql, false, array(1060));
    $MySql = "ALTER TABLE `Teams` ADD `TeTimeStampFinal` DATETIME NULL DEFAULT NULL AFTER `TeTimeStamp`";
    safe_w_SQL($MySql, false, array(1060));
    db_save_version('2011-02-10 11:07:00');
}
if ($version < '2011-02-16 15:42:00') {
    $MySql = "ALTER TABLE `Events` ADD `EvMaxTeamPerson` TINYINT NOT NULL DEFAULT '1' AFTER `EvMixedTeam` ";
    safe_w_SQL($MySql, false, array(1060));
    // metto a posto il campo per le gare presenti e le rank
    $q = "SELECT ToId FROM Tournament ";
    $r = safe_r_sql($q);
    while ($row = safe_fetch($r)) {
        calcMaxTeamPerson_20110216($row->ToId);
        recalculateTeamRanking_20110216($row->ToId);
    }
    db_save_version('2011-02-16 15:42:00');
}
if ($version < '2011-03-09 14:38:00') {
    $MySql = "ALTER TABLE `TournamentType` ADD `TtGoldsChars` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `TtXNine` ,\n\t\tADD `TtXNineChars` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `TtGoldsChars` ;\n\t";
    safe_w_SQL($MySql, false, array(1060));
    $MySql = "ALTER TABLE `Tournament` ADD `ToGoldsChars` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `ToXNine` ,\n\t\tADD `ToXNineChars` VARCHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `ToGoldsChars` ;\n\t";
    safe_w_SQL($MySql, false, array(1060));
    $maps = getMapsGoldsXNineChars_20110309();
    // aggiorno TournamentType
    $q = "\n\t\tSELECT\n\t\t\tTtId,TtGolds,TtXNine\n\t\tFROM\n\t\t\tTournamentType\n\t";
    //print $q;exit;
    $r = safe_r_sql($q);
    if (safe_num_rows($r) > 0) {
        while ($row = safe_fetch($r)) {