diff --git a/db_structure.php b/db_structure.php index bd8ad925b0..97f6b53471 100644 --- a/db_structure.php +++ b/db_structure.php @@ -22,16 +22,20 @@ if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['favorite_table'])) { $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) + + $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->tables; + $favorite_tables[$user] = $fav_instance->getTables(); $ajax_response = PMA_Response::getInstance(); $ajax_response->addJSON( @@ -61,7 +65,7 @@ if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['favorite_table'])) { } } elseif (isset($_REQUEST['add_favorite'])) { if (!$already_favorite) { - if (count($fav_instance->tables) == $GLOBALS['cfg']['NumFavoriteTables']) { + if (count($fav_instance->getTables()) == $GLOBALS['cfg']['NumFavoriteTables']) { $changes = false; $msg = '
'
@@ -76,7 +80,7 @@ if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['favorite_table'])) {
}
- $favorite_tables[$user] = $fav_instance->tables;
+ $favorite_tables[$user] = $fav_instance->getTables();
$ajax_response = PMA_Response::getInstance();
$ajax_response->addJSON(
'changes',
diff --git a/libraries/RecentFavoriteTable.class.php b/libraries/RecentFavoriteTable.class.php
index ffbef725a5..d0fd6ccc9f 100644
--- a/libraries/RecentFavoriteTable.class.php
+++ b/libraries/RecentFavoriteTable.class.php
@@ -33,10 +33,10 @@ class PMA_RecentFavoriteTable
/**
* Reference to session variable containing recently used or favorite tables.
*
- * @access public
+ * @access private
* @var array
*/
- public $tables;
+ private $_tables;
/**
* Defines type of action, Favorite or Recent table.
@@ -44,7 +44,7 @@ class PMA_RecentFavoriteTable
* @access private
* @var string
*/
- private $table_type;
+ private $_tableType;
/**
* PMA_RecentFavoriteTable instances.
@@ -62,20 +62,20 @@ class PMA_RecentFavoriteTable
*/
private function __construct($type)
{
- $this->table_type = $type;
+ $this->_tableType = $type;
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
- && strlen($GLOBALS['cfg']['Server'][$this->table_type])
+ && strlen($GLOBALS['cfg']['Server'][$this->_tableType])
) {
$this->_pmaTable
= PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
- . PMA_Util::backquote($GLOBALS['cfg']['Server'][$this->table_type]);
+ . PMA_Util::backquote($GLOBALS['cfg']['Server'][$this->_tableType]);
}
$server_id = $GLOBALS['server'];
- if (! isset($_SESSION['tmpval'][$this->table_type . '_tables'][$server_id])) {
- $_SESSION['tmpval'][$this->table_type . '_tables'][$server_id]
+ if (! isset($_SESSION['tmpval'][$this->_tableType . '_tables'][$server_id])) {
+ $_SESSION['tmpval'][$this->_tableType . '_tables'][$server_id]
= isset($this->_pmaTable) ? $this->getFromDb() : array();
}
- $this->tables =& $_SESSION['tmpval'][$this->table_type . '_tables'][$server_id];
+ $this->_tables =& $_SESSION['tmpval'][$this->_tableType . '_tables'][$server_id];
}
/**
@@ -93,6 +93,16 @@ class PMA_RecentFavoriteTable
return self::$_instances[$type];
}
+ /**
+ * Returns the recent/favorite tables array
+ *
+ * @return array
+ */
+ public function getTables()
+ {
+ return $this->_tables;
+ }
+
/**
* Returns recently used tables or favorite from phpMyAdmin database.
*
@@ -128,14 +138,14 @@ class PMA_RecentFavoriteTable
= " REPLACE INTO " . $this->_pmaTable . " (`username`, `tables`)" .
" VALUES ('" . $username . "', '"
. PMA_Util::sqlAddSlashes(
- json_encode($this->tables)
+ json_encode($this->_tables)
) . "')";
$success = $GLOBALS['dbi']->tryQuery($sql_query, $GLOBALS['controllink']);
if (! $success) {
$error_msg = '';
- switch ($this->table_type) {
+ switch ($this->_tableType) {
case 'recent':
$error_msg = __('Could not save recent table!');
break;
@@ -165,11 +175,11 @@ class PMA_RecentFavoriteTable
public function trim()
{
$max = max(
- $GLOBALS['cfg']['Num' . ucfirst($this->table_type) . 'Tables'], 0
+ $GLOBALS['cfg']['Num' . ucfirst($this->_tableType) . 'Tables'], 0
);
- $trimming_occurred = count($this->tables) > $max;
- while (count($this->tables) > $max) {
- array_pop($this->tables);
+ $trimming_occurred = count($this->_tables) > $max;
+ while (count($this->_tables) > $max) {
+ array_pop($this->_tables);
}
return $trimming_occurred;
}
@@ -182,16 +192,16 @@ class PMA_RecentFavoriteTable
public function getHtmlList()
{
// Remove Recent/Favorite tables that don't exist.
- foreach ($this->tables as $tbl) {
+ foreach ($this->_tables as $tbl) {
if (! $GLOBALS['dbi']->getColumns($tbl['db'], $tbl['table'])) {
$this->remove($tbl['db'], $tbl['table']);
}
}
$html = '';
- if (count($this->tables)) {
- if ($this->table_type == 'recent') {
- foreach ($this->tables as $table) {
+ if (count($this->_tables)) {
+ if ($this->_tableType == 'recent') {
+ foreach ($this->_tables as $table) {
$html .= '