Пример #1
0
/**
 * Returns current relation parameters
 *
 * @return array   $cfgRelation
 */
function PMA_getRelationsParam()
{
    if (empty($_SESSION['relation'][$GLOBALS['server']])) {
        $_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam();
    }
    // just for BC but needs to be before PMA_getRelationsParamDiagnostic()
    // which uses it
    $GLOBALS['cfgRelation'] = $_SESSION['relation'][$GLOBALS['server']];
    return $_SESSION['relation'][$GLOBALS['server']];
}
Пример #2
0
/**
 * Returns current relation parameters
 *
 * @return array   $cfgRelation
 */
function PMA_getRelationsParam()
{
    // avoid breakage if pmadb got unconfigured after login
    if (!defined('TESTSUITE') && empty($GLOBALS['cfg']['Server']['pmadb'])) {
        unset($_SESSION['relation'][$GLOBALS['server']]);
    }
    if (empty($_SESSION['relation'][$GLOBALS['server']])) {
        $_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam();
    }
    // just for BC but needs to be before PMA_getRelationsParamDiagnostic()
    // which uses it
    $GLOBALS['cfgRelation'] = $_SESSION['relation'][$GLOBALS['server']];
    return $_SESSION['relation'][$GLOBALS['server']];
}
Пример #3
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;
    }
}
 /**
  * Test for PMA_relationsCleanupDatabase
  *
  * @return void
  */
 public function testPMARelationsCleanupDatabase()
 {
     $db = "PMA";
     $this->redefineRelation();
     //the $cfgRelation value before cleanup column
     $cfgRelation = PMA_checkRelationsParam();
     $this->assertEquals('column_info', $cfgRelation['column_info']);
     $this->assertEquals('bookmark', $cfgRelation['bookmark']);
     $this->assertEquals('table_info', $cfgRelation['table_info']);
     $this->assertEquals('pdf_pages', $cfgRelation['pdf_pages']);
     $this->assertEquals('table_coords', $cfgRelation['table_coords']);
     $this->assertEquals('relation', $cfgRelation['relation']);
     //cleanup
     PMA_relationsCleanupDatabase($db);
     //the value after cleanup column
     $cfgRelation = PMA_checkRelationsParam();
     $is_defined_column_info = isset($cfgRelation['column_info']) ? $cfgRelation['column_info'] : null;
     $is_defined_table_info = isset($cfgRelation['table_info']) ? $cfgRelation['table_info'] : null;
     $is_defined_relation = isset($cfgRelation['relation']) ? $cfgRelation['relation'] : null;
     $is_defined_table_coords = isset($cfgRelation['table_coords']) ? $cfgRelation['table_coords'] : null;
     $this->assertEquals(null, $is_defined_column_info);
     $this->assertEquals(null, $is_defined_table_info);
     $this->assertEquals(null, $is_defined_relation);
     $this->assertEquals(null, $is_defined_table_coords);
 }
Пример #5
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();
}