Example #1
0
function upgrade_075_080_pskills_migrate()
{
    # Note: Requires the players_skills table AND all skills name corrections made in DB so they fit $skillsididx.
    global $skillididx;
    global $skillididx_rvs;
    # Make global for use below (dirty trick).
    $skillididx_rvs = array_flip($skillididx);
    # Already run this version upgrade (note: this routine specifically does not remove the skills column(s))?
    if (!SQLUpgrade::doesColExist('players', 'ach_nor_skills')) {
        return true;
    }
    $status = true;
    $status &= (mysql_query("\n        CREATE TABLE IF NOT EXISTS players_skills (\n            f_pid      MEDIUMINT SIGNED NOT NULL,\n            f_skill_id SMALLINT UNSIGNED NOT NULL,\n            type       VARCHAR(1)\n        )\n    ") or die(mysql_error()));
    $players = get_rows('players', array('player_id', 'ach_nor_skills', 'ach_dob_skills', 'extra_skills'), array('ach_nor_skills != "" OR ach_dob_skills != "" OR extra_skills != ""'));
    foreach ($players as $p) {
        foreach (array('N' => 'ach_nor_skills', 'D' => 'ach_dob_skills', 'E' => 'extra_skills') as $t => $grp) {
            $values = empty($p->{$grp}) ? array() : array_map(create_function('$s', 'global $skillididx_rvs; return "(' . $p->player_id . ',\'' . $t . '\',".$skillididx_rvs[$s].")";'), explode(',', $p->{$grp}));
            if (!empty($values)) {
                $status &= (mysql_query("INSERT INTO players_skills(f_pid, type, f_skill_id) VALUES " . implode(',', $values)) or die(mysql_error()));
            }
        }
    }
    $sqls_drop = array(SQLUpgrade::runIfColumnExists('players', 'ach_nor_skills', 'ALTER TABLE players DROP ach_nor_skills'), SQLUpgrade::runIfColumnExists('players', 'ach_dob_skills', 'ALTER TABLE players DROP ach_dob_skills'), SQLUpgrade::runIfColumnExists('players', 'extra_skills', 'ALTER TABLE players DROP extra_skills'));
    foreach ($sqls_drop as $query) {
        $status &= (mysql_query($query) or die(mysql_error()));
    }
    return $status;
}
Example #2
0
 public static function getModuleUpgradeSQL()
 {
     return array('075-080' => array('CREATE TABLE IF NOT EXISTS leegmgr_matches (
                 mid     MEDIUMINT,
                 replay  MEDIUMBLOB,
                 hash    VARCHAR(32)
             )', 'DROP TABLE IF EXISTS leegmgr_matches_temp', SQLUpgrade::runIfColumnExists('matches', 'hash_botocs', 'CREATE TABLE leegmgr_matches_temp (
                     mid     MEDIUMINT,
                     replay  MEDIUMBLOB,
                     hash    VARCHAR(32)
                 )
             '), SQLUpgrade::runIfColumnExists('matches', 'hash_botocs', 'INSERT INTO leegmgr_matches_temp (mid, hash) SELECT match_id, hash_botocs FROM matches'), SQLUpgrade::runIfColumnExists('matches', 'hash_botocs', 'UPDATE leegmgr_matches_temp, leegmgr_matches SET leegmgr_matches_temp.replay = leegmgr_matches.replay WHERE leegmgr_matches_temp.mid = leegmgr_matches.mid'), SQLUpgrade::runIfColumnExists('matches', 'hash_botocs', 'DROP TABLE leegmgr_matches'), SQLUpgrade::runIfColumnExists('matches', 'hash_botocs', 'ALTER TABLE leegmgr_matches_temp RENAME TO leegmgr_matches')));
 }
Example #3
0
    # Redirect logged out users to the main page.
    Coach::logout();
}
Mobile::setIsMobile($isMobile);
if ($isMobile && !Coach::isLoggedIn()) {
    // Redirect logged out mobile users to login
    $_GET['section'] = 'login';
}
if ($_VISSTATE['COOCKIE'] || $_VISSTATE['POST_IN'] || $_VISSTATE['POST_OUT']) {
    setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_COACH_LOGINOUT);
}
if ($coach && $coach->isGlobalAdmin()) {
    if (!isset($db_version)) {
        echo '<div class="messagecontainer red">Your desired database version cannot be determined. Please ensure $db_version is set to a value in settings.php. If you aren\'t certain what to set it to, ask a NAFLM developer. 101 could be an appropriate default.</div>';
    } else {
        $databaseVersion = SQLUpgrade::getCurrentDatabaseVersion();
        $fromVersion = $databaseVersion ? $databaseVersion : '075-080';
        // set to earliest auto-upgrade version by default
        if (!$databaseVersion || $fromVersion < $db_version) {
            echo '<div class="messagecontainer lightgreen">';
            if (!$databaseVersion) {
                echo '<div>Your database version cannot be determined. Your system will run <strong>all</strong> automatic upgrades.</div>';
            }
            echo '<div>Your database will now be upgraded to version ' . $db_version . '.</div>';
            upgrade_database_to_version($db_version, $fromVersion);
            echo '</div>';
        }
    }
}
if (Mobile::isMobile()) {
    HTMLOUT::mobile_frame_begin();