Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db_structure.php')
-rw-r--r--db_structure.php40
1 files changed, 38 insertions, 2 deletions
diff --git a/db_structure.php b/db_structure.php
index ab46c50909..3ca9009753 100644
--- a/db_structure.php
+++ b/db_structure.php
@@ -18,11 +18,38 @@ require_once 'libraries/structure.lib.php';
// Add/Remove favorite tables using Ajax request.
if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['favorite_table'])) {
+ $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
+ $favorite_tables = json_decode($_REQUEST['favorite_tables'], true);
+ // Required to keep each user's preferences seperate.
+ $user = sha1($GLOBALS['cfg']['Server']['user']);
+ // Request for Synchronization of favorite tables.
+ if (isset($_REQUEST['sync_favorite_tables'])) {
+ 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->tables;
+
+ $ajax_response = PMA_Response::getInstance();
+ $ajax_response->addJSON(
+ 'favorite_tables',
+ json_encode($favorite_tables)
+ );
+ $ajax_response->addJSON(
+ 'options',
+ $fav_instance->getHtmlSelectOption()
+ );
+ $server_id = $GLOBALS['server'];
+ // Set flag when localStorage and pmadb(if present) are in sync.
+ $_SESSION['tmpval']['favorites_synced'][$server_id] = true;
+ exit;
+ }
global $db;
$changes = true;
$msg = '';
$titles = PMA_Util::buildActionTitles();
- $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
$favorite_table = $_REQUEST['favorite_table'];
$already_favorite = PMA_checkFavoriteTable($db, $favorite_table);
@@ -48,6 +75,7 @@ if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['favorite_table'])) {
}
+ $favorite_tables[$user] = $fav_instance->tables;
$ajax_response = PMA_Response::getInstance();
$ajax_response->addJSON(
'changes',
@@ -55,8 +83,16 @@ if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['favorite_table'])) {
);
if ($changes) {
$ajax_response->addJSON(
+ 'user',
+ $user
+ );
+ $ajax_response->addJSON(
+ 'favorite_tables',
+ json_encode($favorite_tables)
+ );
+ $ajax_response->addJSON(
'options',
- PMA_RecentFavoriteTable::getInstance('favorite')->getHtmlSelectOption()
+ $fav_instance->getHtmlSelectOption()
);
$ajax_response->addJSON(
'anchor',