/** * Synchronize favorite tables * * * @param RecentFavoriteTable $fav_instance Instance of this class * @param string $user The user hash * @param array $favorite_tables Existing favorites * * @return void */ protected function synchronizeFavoriteTables($fav_instance, $user, $favorite_tables) { $fav_instance_tables = $fav_instance->getTables(); if (empty($fav_instance_tables) && isset($favorite_tables[$user])) { foreach ($favorite_tables[$user] as $key => $value) { $fav_instance->add($value['db'], $value['table']); } } $favorite_tables[$user] = $fav_instance->getTables(); $this->response->addJSON(array('favorite_tables' => json_encode($favorite_tables), 'list' => $fav_instance->getHtmlList())); $server_id = $GLOBALS['server']; // Set flag when localStorage and pmadb(if present) are in sync. $_SESSION['tmpval']['favorites_synced'][$server_id] = true; }
$server_info .= ' ('; } } if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) { $server_info .= $GLOBALS['dbi']->getHostInfo(); } if (!empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) { $server_info .= ')'; } $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();'); // should we add the port info here? $short_server_info = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host']; } echo '<div id="maincontainer">', "\n"; // Anchor for favorite tables synchronization. echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables(); echo '<div id="main_pane_left">'; if ($server > 0 || count($cfg['Servers']) > 1) { if ($cfg['DBG']['demo']) { echo '<div class="group">'; echo '<h2>', __('phpMyAdmin Demo Server'), '</h2>'; echo '<p style="margin: 0.5em 1em 0.5em 1em">'; printf(__('You are using the demo server. You can do anything here, but ' . 'please do not change root, debian-sys-maint and pma users. ' . 'More information is available at %s.'), '<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'); echo '</p>'; echo '</div>'; } echo '<div class="group">'; echo '<h2>', __('General settings'), '</h2>'; echo '<ul>'; /** * Displays the MySQL servers choice form
/** * 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', 'pma__designer_settings' => 'designer_settings', 'pma__export_templates' => 'export_templates'); $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; } $foundOne = true; $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. if ($cfgRelation['favoritework']) { $fav_tables = RecentFavoriteTable::getInstance('favorite'); $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = $fav_tables->getFromDb(); } if ($cfgRelation['recentwork']) { $recent_tables = RecentFavoriteTable::getInstance('recent'); $_SESSION['tmpval']['recent_tables'][$GLOBALS['server']] = $recent_tables->getFromDb(); } // Reload navi panel to update the recent/favorite lists. $GLOBALS['reload'] = true; } }
/** * Function to check if a table is already in favorite list. * * @param string $current_table current table * * @return true|false */ protected function checkFavoriteTable($current_table) { // ensure $_SESSION['tmpval']['favorite_tables'] is initialized RecentFavoriteTable::getInstance('favorite'); foreach ($_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] as $value) { if ($value['db'] == $this->db && $value['table'] == $current_table) { return true; } } return false; }
/** * Add recently used table and reload the navigation. * * @param string $db Database name where the table is located. * @param string $table The table name * * @return string */ private function _addRecentTable($db, $table) { $retval = ''; if ($this->_menuEnabled && mb_strlen($table) && $GLOBALS['cfg']['NumRecentTables'] > 0) { $tmp_result = RecentFavoriteTable::getInstance('recent')->add($db, $table); if ($tmp_result === true) { $retval = RecentFavoriteTable::getHtmlUpdateRecentTables(); } else { $error = $tmp_result; $retval = $error->getDisplay(); } } return $retval; }
/** * Display quick warp links, contain Recents and Favorites * * @return string HTML code */ private function _quickWarp() { $retval = '<div class="pma_quick_warp">'; if ($GLOBALS['cfg']['NumRecentTables'] > 0) { $retval .= RecentFavoriteTable::getInstance('recent')->getHtml(); } if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) { $retval .= RecentFavoriteTable::getInstance('favorite')->getHtml(); } $retval .= '<div class="clearfloat"></div>'; $retval .= '</div>'; return $retval; }
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Browse recent and favourite tables chosen from navigation * * @package PhpMyAdmin */ use PMA\libraries\RecentFavoriteTable; require_once 'libraries/common.inc.php'; RecentFavoriteTable::getInstance('recent')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']); RecentFavoriteTable::getInstance('favorite')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']); require 'sql.php';