Beispiel #1
0
/**
 * Checks and fixes configuration storage in current DB.
 *
 * @return void
 */
function PMA_checkAndFixPMATablesInCurrentDb()
{
    if (isset($GLOBALS['db']) && !empty($GLOBALS['db'])) {
        if (isset($GLOBALS['cfg']['Server']['pmadb']) && empty($GLOBALS['cfg']['Server']['pmadb'])) {
            $default_tables = PMA_getDefaultPMATableNames();
            if (PMA_searchPMATablesInDb($GLOBALS['db'], array_keys($default_tables))) {
                PMA_fixPMATables($GLOBALS['db']);
                // Since configuration storage is updated, we need to
                // re-initialize the favorite and recent tables stored in the
                // session from the current configuration storage.
                include_once 'libraries/RecentFavoriteTable.class.php';
                $fav_tables = PMA_RecentFavoriteTable::getInstance('favorite');
                $recent_tables = PMA_RecentFavoriteTable::getInstance('recent');
                $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = $fav_tables->getFromDb();
                $_SESSION['tmpval']['recent_tables'][$GLOBALS['server']] = $recent_tables->getFromDb();
                // Reload navi panel to update the recent/favorite lists.
                $GLOBALS['reload'] = true;
            }
        }
    }
}
Beispiel #2
0
/**
 * Creates PMA tables in the given db, updates if already exists.
 *
 * @param string  $db     database
 * @param boolean $create whether to create tables if they don't exist.
 *
 * @return void
 */
function PMA_fixPMATables($db, $create = true)
{
    $tablesToFeatures = array('pma__bookmark' => 'bookmarktable', 'pma__relation' => 'relation', 'pma__table_info' => 'table_info', 'pma__table_coords' => 'table_coords', 'pma__pdf_pages' => 'pdf_pages', 'pma__column_info' => 'column_info', 'pma__history' => 'history', 'pma__recent' => 'recent', 'pma__favorite' => 'favorite', 'pma__table_uiprefs' => 'table_uiprefs', 'pma__tracking' => 'tracking', 'pma__userconfig' => 'userconfig', 'pma__users' => 'users', 'pma__usergroups' => 'usergroups', 'pma__navigationhiding' => 'navigationhiding', 'pma__savedsearches' => 'savedsearches', 'pma__central_columns' => 'central_columns');
    $existingTables = $GLOBALS['dbi']->getTables($db, $GLOBALS['controllink']);
    $createQueries = null;
    $foundOne = false;
    foreach ($tablesToFeatures as $table => $feature) {
        if (!in_array($table, $existingTables)) {
            if ($create) {
                if ($createQueries == null) {
                    // first create
                    $createQueries = PMA_getDefaultPMATableNames();
                    $GLOBALS['dbi']->selectDb($db);
                }
                $GLOBALS['dbi']->tryQuery($createQueries[$table]);
                if ($error = $GLOBALS['dbi']->getError()) {
                    $GLOBALS['message'] = $error;
                    return;
                }
                $GLOBALS['cfg']['Server'][$feature] = $table;
            }
        } else {
            $foundOne = true;
            $GLOBALS['cfg']['Server'][$feature] = $table;
        }
    }
    if (!$foundOne) {
        return;
    }
    $GLOBALS['cfg']['Server']['pmadb'] = $db;
    $_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam();
    $cfgRelation = PMA_getRelationsParam();
    if ($cfgRelation['recentwork'] || $cfgRelation['favoritework']) {
        // Since configuration storage is updated, we need to
        // re-initialize the favorite and recent tables stored in the
        // session from the current configuration storage.
        include_once 'libraries/RecentFavoriteTable.class.php';
        if ($cfgRelation['favoritework']) {
            $fav_tables = PMA_RecentFavoriteTable::getInstance('favorite');
            $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = $fav_tables->getFromDb();
        }
        if ($cfgRelation['recentwork']) {
            $recent_tables = PMA_RecentFavoriteTable::getInstance('recent');
            $_SESSION['tmpval']['recent_tables'][$GLOBALS['server']] = $recent_tables->getFromDb();
        }
        // Reload navi panel to update the recent/favorite lists.
        $GLOBALS['reload'] = true;
    }
}
Beispiel #3
0
/**
 * Creates PMA tables in the given db, updates if already exists.
 *
 * @param string $db Database
 *
 * @return void
 */
function PMA_fixPMATables($db)
{
    $default_tables = PMA_getDefaultPMATableNames();
    $GLOBALS['dbi']->selectDb($db);
    foreach ($default_tables as $table => $create_query) {
        $GLOBALS['dbi']->tryQuery($create_query);
        if ($error = $GLOBALS['dbi']->getError()) {
            $GLOBALS['message'] = $error;
            break;
        }
        if ($table == 'pma__bookmark') {
            $GLOBALS['cfg']['Server']['bookmarktable'] = $table;
        } elseif ($table == 'pma__relation') {
            $GLOBALS['cfg']['Server']['relation'] = $table;
        } elseif ($table == 'pma__table_info') {
            $GLOBALS['cfg']['Server']['table_info'] = $table;
        } elseif ($table == 'pma__table_coords') {
            $GLOBALS['cfg']['Server']['table_coords'] = $table;
        } elseif ($table == 'pma__column_info') {
            $GLOBALS['cfg']['Server']['column_info'] = $table;
        } elseif ($table == 'pma__pdf_pages') {
            $GLOBALS['cfg']['Server']['pdf_pages'] = $table;
        } elseif ($table == 'pma__history') {
            $GLOBALS['cfg']['Server']['history'] = $table;
        } elseif ($table == 'pma__recent') {
            $GLOBALS['cfg']['Server']['recent'] = $table;
        } elseif ($table == 'pma__table_uiprefs') {
            $GLOBALS['cfg']['Server']['table_uiprefs'] = $table;
        } elseif ($table == 'pma__tracking') {
            $GLOBALS['cfg']['Server']['tracking'] = $table;
        } elseif ($table == 'pma__userconfig') {
            $GLOBALS['cfg']['Server']['userconfig'] = $table;
        } elseif ($table == 'pma__users') {
            $GLOBALS['cfg']['Server']['users'] = $table;
        } elseif ($table == 'pma__usergroups') {
            $GLOBALS['cfg']['Server']['usergroups'] = $table;
        } elseif ($table == 'pma__navigationhiding') {
            $GLOBALS['cfg']['Server']['navigationhiding'] = $table;
        } elseif ($table == 'pma__savedsearches') {
            $GLOBALS['cfg']['Server']['savedsearches'] = $table;
        } elseif ($table == 'pma__central_columns') {
            $GLOBALS['cfg']['Server']['central_columns'] = $table;
        } else {
            if ($table == 'pma__designer_coords') {
                $GLOBALS['cfg']['Server']['designer_coords'] = $table;
            }
        }
    }
    $GLOBALS['cfg']['Server']['pmadb'] = $db;
    $_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam();
}