Merge commit '3a672d43b814dbf63276f4631eb0a4fa83a235c5'

This commit is contained in:
Marc Delisle 2011-08-12 08:01:31 -04:00
commit 70b664a3bd
9 changed files with 92 additions and 20 deletions

View File

@ -1086,9 +1086,9 @@ ALTER TABLE `pma_column_comments`
</dt>
<dd>
Since release 3.5.0 phpMyAdmin can be configured to remember several things
(table sorting
(sorted column
<a href="#cfg_RememberSorting" class="configrule">$cfg['RememberSorting']</a>
, etc.) for browsing tables.
, column order, and column visibility from a database table) for browsing tables.
Without configuring the storage, these features still can be used,
but the values will disappear after you logout.<br/><br/>
@ -1223,6 +1223,17 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE</pre>
</ul>
</dd>
<dt><span id="cfg_Servers_MaxTableUiprefs">$cfg['Servers'][$i]['MaxTableUiprefs']</span> integer
</dt>
<dd>Maximum number of records saved in <a
href="#cfg_Servers_table_uiprefs">$cfg['Servers'][$i]['table_uiprefs']</a> table.<br /><br />
In case where tables in databases is modified (e.g. dropped or renamed),
table_uiprefs may contains invalid data (referring to tables which are not
exist anymore).<br />
This configuration make sure that we only keep N (N = MaxTableUiprefs)
newest record in table_uiprefs and automatically delete older records.</dd>
<dt><span id="cfg_Servers_verbose_check">$cfg['Servers'][$i]['verbose_check']</span> boolean
</dt>
<dd>Because release 2.5.0 introduced the new MIME-transformation support, the

View File

@ -353,22 +353,31 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
* Send column preferences (column order and visibility) to the server.
*/
sendColPrefs: function() {
var post_params = {
ajax_request: true,
db: g.db,
table: g.table,
token: g.token,
server: g.server,
set_col_prefs: true,
table_create_time: g.tableCreateTime
};
if (g.colOrder.length > 0) {
$.extend(post_params, { col_order: g.colOrder.toString() });
if ($(g.t).is('.ajax')) { // only send preferences if AjaxEnable is true
var post_params = {
ajax_request: true,
db: g.db,
table: g.table,
token: g.token,
server: g.server,
set_col_prefs: true,
table_create_time: g.tableCreateTime
};
if (g.colOrder.length > 0) {
$.extend(post_params, { col_order: g.colOrder.toString() });
}
if (g.colVisib.length > 0) {
$.extend(post_params, { col_visib: g.colVisib.toString() });
}
$.post('sql.php', post_params, function(data) {
if (data.success != true) {
var $temp_div = $(document.createElement('div'));
$temp_div.html(data.error);
$temp_div.addClass("error");
PMA_ajaxShowMessage($temp_div);
}
});
}
if (g.colVisib.length > 0) {
$.extend(post_params, { col_visib: g.colVisib.toString() });
}
$.post('sql.php', post_params);
},
/**
@ -1500,6 +1509,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
g.cellEditHint = PMA_messages['strCellEditHint'];
g.saveCellWarning = PMA_messages['strSaveCellWarning'];
g.alertNonUnique = PMA_messages['strAlertNonUnique'];
g.gotoLinkText = PMA_messages['strGoToLink'];
// initialize cell editing configuration
g.saveCellsAtOnce = $('#save_cells_at_once').val();
@ -1560,6 +1570,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
// attach to global div
$(g.gDiv).append(g.cEdit);
// add hint for grid editing feature when hovering "Edit" link in each table row
PMA_createqTip($(g.t).find('.edit_row_anchor a'), PMA_messages['strGridEditFeatureHint']);
}
}

View File

@ -283,6 +283,8 @@ $js_messages['strColMarkHint'] = __('Click to mark/unmark');
$js_messages['strColVisibHint'] = __('Click the drop-down arrow<br />to toggle column\'s visibility');
$js_messages['strShowAllCol'] = __('Show all');
$js_messages['strAlertNonUnique'] = __('This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.');
$js_messages['strGridEditFeatureHint'] = __('You can also edit most columns<br />by clicking directly on their content.');
$js_messages['strGoToLink'] = __('Go to link');
/* password generation */
$js_messages['strGeneratePassword'] = __('Generate password');

View File

@ -1266,7 +1266,7 @@ class PMA_Table
" REPLACE INTO " . $pma_table .
" VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name) . "', '" .
PMA_sqlAddSlashes($this->name) . "', '" .
PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "')";
PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
@ -1276,6 +1276,28 @@ class PMA_Table
$message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
return $message;
}
// Remove some old rows in table_uiprefs if it exceeds the configured maximum rows
$sql_query = 'SELECT COUNT(*) FROM ' . $pma_table;
$rows_count = PMA_DBI_fetch_value($sql_query);
$max_rows = $GLOBALS['cfg']['Server']['MaxTableUiprefs'];
if ($rows_count > $max_rows) {
$num_rows_to_delete = $rows_count - $max_rows;
$sql_query =
' DELETE FROM ' . $pma_table .
' ORDER BY last_update ASC' .
' LIMIT ' . $num_rows_to_delete;
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
if (!$success) {
$message = PMA_Message::error(__('Failed to cleanup table UI preferences (see cfg["Server"]["MaxTableUiprefs"] documentation)'));
$message->addMessage('<br /><br />');
$message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
print_r($message);
return $message;
}
}
return true;
}

View File

@ -377,6 +377,19 @@ $cfg['Servers'][$i]['tracking'] = '';
*/
$cfg['Servers'][$i]['userconfig'] = '';
/**
* Maximum number of records saved in $cfg['Servers'][$i]['table_uiprefs'] table.
*
* In case where tables in databases is modified (e.g. dropped or renamed),
* table_uiprefs may contains invalid data (referring to tables which are not
* exist anymore).
* This configuration make sure that we only keep N (N = MaxTableUiprefs)
* newest record in table_uiprefs and automatically delete older records.
*
* @global integer $cfg['Servers'][$i]['userconfig'] = '';
*/
$cfg['Servers'][$i]['MaxTableUiprefs'] = 100;
/**
* set to false if you know that your pma_* tables are up to date.
* This prevents compatibility checks and thereby increases performance.

View File

@ -395,6 +395,8 @@ $strConfigServers_history_name = __('SQL query history table');
$strConfigServers_host_desc = __('Hostname where MySQL server is running');
$strConfigServers_host_name = __('Server hostname');
$strConfigServers_LogoutURL_name = __('Logout URL');
$strConfigServers_MaxTableUiprefs_desc = __('This configuration make sure that we only keep N (N = MaxTableUiprefs) newest record in "table_uiprefs" and automatically delete older records');
$strConfigServers_MaxTableUiprefs_name = __('Maximum number of records saved in "table_uiprefs" table');
$strConfigServers_nopassword_desc = __('Try to connect without password');
$strConfigServers_nopassword_name = __('Connect without password');
$strConfigServers_only_db_desc = __('You can use MySQL wildcard characters (% and _), escape them if you want to use their literal instances, i.e. use [kbd]\'my\_db\'[/kbd] and not [kbd]\'my_db\'[/kbd]. Using this option you can sort database list, just enter their names in order and use [kbd]*[/kbd] at the end to show the rest in alphabetical order.');

View File

@ -78,7 +78,8 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
'tracking' => 'pma_tracking',
'table_coords' => 'pma_table_coords',
'pdf_pages' => 'pma_pdf_pages',
'designer_coords' => 'pma_designer_coords')));
'designer_coords' => 'pma_designer_coords',
'MaxTableUiprefs' => 100)));
$forms['Servers']['Server_tracking'] = array('Servers' => array(1 => array(
'tracking_version_auto_create',
'tracking_default_statements',

View File

@ -128,6 +128,7 @@ CREATE TABLE IF NOT EXISTS `pma_table_uiprefs` (
`db_name` varchar(64) NOT NULL,
`table_name` varchar(64) NOT NULL,
`prefs` text NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`username`,`db_name`,`table_name`)
)
ENGINE=MyISAM COMMENT='Tables'' UI preferences'

View File

@ -174,12 +174,19 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
if (isset($_REQUEST['col_order'])) {
$col_order = explode(',', $_REQUEST['col_order']);
$retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_ORDER, $col_order, $_REQUEST['table_create_time']);
if ($retval !== true) {
PMA_ajaxResponse($retval->getString(), false);
}
}
// set column visibility
if (isset($_REQUEST['col_visib'])) {
$col_visib = explode(',', $_REQUEST['col_visib']);
$retval &= $pmatable->setUiProp(PMA_Table::PROP_COLUMN_VISIB, $col_visib, $_REQUEST['table_create_time']);
$retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_VISIB, $col_visib, $_REQUEST['table_create_time']);
if ($retval !== true) {
PMA_ajaxResponse($retval->getString(), false);
}
}
PMA_ajaxResponse(NULL, ($retval == true));