Merge branch 'master' into DBI_naming_cleanUp

Conflicts:
	ChangeLog
This commit is contained in:
Kasun Chathuranga 2013-05-01 21:33:52 +05:30
commit d632dd9946
14 changed files with 191 additions and 67 deletions

View File

@ -2,6 +2,9 @@ phpMyAdmin - ChangeLog
======================
4.1.0.0 (not yet released)
+ rfe #499 On user creation, warn if the user already exists
+ Use indeterminate check all checkbox in server privileges
+ Break server_status.php functions into smaller functions
+ PMA_DBI functions in database_interface.lib.php renamed to be compliant with PEAR standards
4.0.1.0 (not yet released)

View File

@ -132,7 +132,7 @@ $response->addHTML(
$response->addHTML(PMA_generate_common_hidden_inputs($db));
$response->addHTML(
PMA_TableHeader($db_is_information_schema, $server_slave_status)
PMA_tableHeader($db_is_information_schema, $server_slave_status)
);
$i = $sum_entries = 0;
@ -263,7 +263,7 @@ foreach ($tables as $keyname => $current_table) {
'</tr></tbody></table>'
);
$response->addHTML(PMA_TableHeader(false, $server_slave_status));
$response->addHTML(PMA_tableHeader(false, $server_slave_status));
}
list($do, $ignored) = PMA_getServerSlaveStatus(

View File

@ -3755,14 +3755,13 @@ $(function () {
/**
* Watches checkboxes in a form to set the checkall box accordingly
*/
var checkboxes_sel = "input.checkall:checkbox:enabled";
$(checkboxes_sel).live("change", function () {
var checkboxes_changed = function () {
var $form = $(this.form);
// total number of checkboxes in current form
var total_boxes = $form.find(checkboxes_sel).length;
// number of checkboxes checked in current form
var checked_boxes = $form.find(checkboxes_sel + ":checked").length;
var $checkall = $form.find("input#checkall");
var $checkall = $form.find("input.checkall_box");
if (total_boxes == checked_boxes) {
$checkall.prop({checked: true, indeterminate: false});
}
@ -3772,8 +3771,11 @@ $(checkboxes_sel).live("change", function () {
else {
$checkall.prop({checked: false, indeterminate: false});
}
});
$("input#checkall").live("change", function () {
};
var checkboxes_sel = "input.checkall:checkbox:enabled";
$(checkboxes_sel).live("change", checkboxes_changed);
$("input.checkall_box").live("change", function () {
var is_checked = $(this).is(":checked");
$(this.form).find(checkboxes_sel).prop("checked", is_checked)
.parents("tr").toggleClass("marked", is_checked);

View File

@ -36,8 +36,8 @@ AJAX.registerOnload('server_databases.js', function () {
* @var selected_dbs Array containing the names of the checked databases
*/
var selected_dbs = [];
// loop over all checked checkboxes, except the #checkall checkbox
$form.find('input:checkbox:checked:not(#checkall)').each(function () {
// loop over all checked checkboxes, except the .checkall_box checkbox
$form.find('input:checkbox:checked:not(.checkall_box)').each(function () {
$(this).closest('tr').addClass('removeMe');
selected_dbs[selected_dbs.length] = 'DROP DATABASE `' + escapeHtml($(this).val()) + '`;';
});

View File

@ -165,7 +165,8 @@ function addUser($form)
/**
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('server_privileges.js', function () {
AJAX.registerTeardown('server_privileges.js', function() {
$("#fieldset_add_user_login input[name='username']").die("focusout");
$("#fieldset_add_user a.ajax").die("click");
$('form[name=usersForm]').unbind('submit');
$("#reload_privileges_anchor.ajax").die("click");
@ -176,9 +177,35 @@ AJAX.registerTeardown('server_privileges.js', function () {
$("a.export_user_anchor.ajax").die('click');
$("#initials_table").find("a.ajax").die('click');
$('#checkbox_drop_users_db').unbind('click');
$(".checkall_box").die("click");
});
AJAX.registerOnload('server_privileges.js', function () {
/**
* Display a warning if there is already a user by the name entered as the username.
*/
$("#fieldset_add_user_login input[name='username']").live("focusout", function() {
var username = $(this).val();
var $warning = $("#user_exists_warning");
if ($("#select_pred_username").val() == 'userdefined' && username != '') {
var href = $("form[name='usersForm']").attr('action');
var params = {
'ajax_request' : true,
'token' : PMA_commonParams.get('token'),
'validate_username' : true,
'username' : username
};
$.get(href, params, function(data) {
if (data['user_exists']) {
$warning.show();
} else {
$warning.hide();
}
});
} else {
$warning.hide();
}
});
/**
* AJAX event handler for 'Add a New User'
*
@ -335,6 +362,7 @@ AJAX.registerOnload('server_privileges.js', function () {
}
$div.html(data.message);
displayPasswordGenerateButton();
$(checkboxes_sel).trigger("change");
PMA_ajaxRemoveMessage($msgbox);
PMA_showHints($div);
} else {

View File

@ -5037,9 +5037,9 @@ class PMA_DisplayResults
. ' alt="' . __('With selected:') . '" />';
}
$links_html .= '<input type="checkbox" id="checkall" title="'
. __('Check All') . '" /> '
. '<label for="checkall">' . __('Check All') . '</label> '
$links_html .= '<input type="checkbox" id="resultsForm_checkall" '
. 'class="checkall_box" title="' . __('Check All') . '" /> '
. '<label for="resultsForm_checkall">' . __('Check All') . '</label> '
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
$links_html .= PMA_Util::getButtonOrImage(

View File

@ -774,12 +774,9 @@ function PMA_getHtmlForGlobalOrDbSpecificPrivs($db, $table, $row)
} else {
$html_output .= __('Table-specific privileges');
}
$html_output .= ' (<a href="#" '
. 'onclick="setCheckboxes(\'fieldset_user_global_rights\', true); '
. 'return false;">' . __('Check All') . '</a> /'
. '<a href="#" '
. 'onclick="setCheckboxes(\'fieldset_user_global_rights\', false); '
. 'return false;">' . __('Uncheck All') . '</a>)';
$html_output .= '<input type="checkbox" id="addUsersForm_checkall" '
. 'class="checkall_box" title="' . __('Check All') . '" /> '
. '<label for="addUsersForm_checkall">' . __('Check All') . '</label> ';
$html_output .= '</legend>';
$html_output .= '<p><small><i>'
. __('Note: MySQL privilege names are expressed in English')
@ -982,7 +979,7 @@ function PMA_getHtmlForGlobalPrivTableWithCheckboxes(
. '<legend>' . $privTable_names[$i] . '</legend>' . "\n";
foreach ($table as $priv) {
$html_output .= '<div class="item">' . "\n"
. '<input type="checkbox"'
. '<input type="checkbox" class="checkall"'
. ' name="' . $priv[0] . '_priv" '
. 'id="checkbox_' . $priv[0] . '_priv"'
. ' value="Y" title="' . $priv[2] . '"'
@ -1035,6 +1032,7 @@ function PMA_getHtmlForDisplayLoginInformationFields($mode = 'new')
$html_output .= ' onchange="'
. 'if (this.value == \'any\') {'
. ' username.value = \'\'; '
. ' user_exists_warning.style.display = \'none\'; '
. '} else if (this.value == \'userdefined\') {'
. ' username.focus(); username.select(); '
. '}">' . "\n";
@ -1068,8 +1066,15 @@ function PMA_getHtmlForDisplayLoginInformationFields($mode = 'new')
: $GLOBALS['username']
) . '"'
)
. ' onchange="pred_username.value = \'userdefined\';" />' . "\n"
. '</div>' . "\n";
. ' onchange="pred_username.value = \'userdefined\';" />' . "\n";
$html_output .= '<div id="user_exists_warning"'
. ' name="user_exists_warning" style="display:none;">'
. PMA_Message::notice(
__('An account already exists with the same username but possibly a different hostname. Are you sure you wish to proceed?')
)->getDisplay()
. '</div>';
$html_output .= '</div>';
$html_output .= '<div class="item">' . "\n"
. '<label for="select_pred_hostname">' . "\n"
@ -1905,6 +1910,19 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query,
$extra_data['new_privileges'] = $new_privileges;
}
if (isset($_REQUEST['validate_username'])) {
$sql_query = "SELECT * FROM `mysql`.`user` WHERE `User` = '"
. $_REQUEST['username'] . "';";
$res = PMA_DBI_query($sql_query);
$row = PMA_DBI_fetch_row($res);
if (empty($row)) {
$extra_data['user_exists'] = false;
} else {
$extra_data['user_exists'] = true;
}
}
return $extra_data;
}
@ -2395,13 +2413,14 @@ function PMA_getUsersOverview($result, $db_rights, $link_edit, $pmaThemeImage,
. '</table>' . "\n";
$html_output .= '<div style="float:left;">'
.'<img class="selectallarrow"'
.' src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png"'
.' width="38" height="22"'
.' alt="' . __('With selected:') . '" />' . "\n"
.'<input type="checkbox" id="checkall" title="' . __('Check All') . '" /> '
.'<label for="checkall">' . __('Check All') . '</label> '
.'<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
. '<img class="selectallarrow"'
. ' src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png"'
. ' width="38" height="22"'
. ' alt="' . __('With selected:') . '" />' . "\n"
. '<input type="checkbox" id="usersForm_checkall" class="checkall_box" '
. 'title="' . __('Check All') . '" /> '
. '<label for="usersForm_checkall">' . __('Check All') . '</label> '
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
$html_output .= PMA_Util::getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_export',
@ -2431,10 +2450,9 @@ function PMA_getUsersOverview($result, $db_rights, $link_edit, $pmaThemeImage,
function PMA_getTableBodyForUserRightsTable($db_rights, $link_edit, $link_export)
{
$odd_row = true;
$index_checkbox = -1;
$index_checkbox = 0;
$html_output = '';
foreach ($db_rights as $user) {
$index_checkbox++;
ksort($user);
foreach ($user as $host) {
$index_checkbox++;

View File

@ -277,9 +277,9 @@ function PMA_getHtmlForCheckAllTables($pmaThemeImage, $text_dir,
. 'src="' .$pmaThemeImage .'arrow_'.$text_dir.'.png' . '"'
. 'width="38" height="22" alt="' . __('With selected:') . '" />';
$html_output .= '<input type="checkbox" id="checkall" '
. 'title="' . __('Check All') .'" />';
$html_output .= '<label for="checkall">' .__('Check All') . '</label>';
$html_output .= '<input type="checkbox" id="tablesForm_checkall" '
. 'class="checkall_box" title="' . __('Check All') .'" />';
$html_output .= '<label for="tablesForm_checkall">' .__('Check All') . '</label>';
if ($overhead_check != '') {
$html_output .= PMA_getHtmlForCheckTablesHavingOverheadlink(
@ -740,7 +740,7 @@ function PMA_getHtmlForRepairtable(
*
* @return html data
*/
function PMA_TableHeader($db_is_information_schema = false, $replication = false)
function PMA_tableHeader($db_is_information_schema = false, $replication = false)
{
$cnt = 0; // Let's count the columns...
@ -1312,8 +1312,8 @@ function PMA_getHtmlForDropColumn($tbl_is_view, $db_is_information_schema,
if (! $tbl_is_view && ! $db_is_information_schema) {
$html_output .= '<td class="edit center">'
. '<a class="change_column_anchor ajax"'
. ' href="tbl_structure.php?'
. $url_query . '&amp;field=' . $field_encoded
. ' href="tbl_structure.php?'
. $url_query . '&amp;field=' . $field_encoded
. '&amp;change_column=1">'
. $titles['Change'] . '</a>' . '</td>';
$html_output .= '<td class="drop center">'
@ -1356,9 +1356,9 @@ function PMA_getHtmlForCheckAllTableColumn($pmaThemeImage, $text_dir,
. 'src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png' . '"'
. 'width="38" height="22" alt="' . __('With selected:') . '" />';
$html_output .= '<input type="checkbox" id="checkall" '
. 'title="' . __('Check All') . '" />'
. '<label for="checkall">' . __('Check All') . '</label>';
$html_output .= '<input type="checkbox" id="fieldsForm_checkall" '
. 'class="checkall_box" title="' . __('Check All') . '" />'
. '<label for="fieldsForm_checkall">' . __('Check All') . '</label>';
$html_output .= '<i style="margin-left: 2em">'
. __('With selected:') . '</i>';
@ -2209,15 +2209,15 @@ function PMA_getHtmlForDisplayTableStats($showtable, $table_info_num_rows,
/**
* Displays HTML for changing one or more columns
*
* @param string $db database name
* @param string $table table name
* @param array $selected the selected columns
* @param string $action target script to call
* @param string $db database name
* @param string $table table name
* @param array $selected the selected columns
* @param string $action target script to call
*
* @return boolean $regenerate true if error occurred
*
* @return boolean $regenerate true if error occurred
*
*/
function PMA_displayHtmlForColumnChange($db, $table, $selected, $action)
function PMA_displayHtmlForColumnChange($db, $table, $selected, $action)
{
// $selected comes from multi_submits.inc.php
if (empty($selected)) {
@ -2234,12 +2234,12 @@ function PMA_displayHtmlForColumnChange($db, $table, $selected, $action)
$fields_meta[] = PMA_DBI_getColumns($db, $table, $selected[$i], true);
}
$num_fields = count($fields_meta);
// set these globals because tbl_columns_definition_form.inc.php
// set these globals because tbl_columns_definition_form.inc.php
// verifies them
// @todo: refactor tbl_columns_definition_form.inc.php so that it uses
// @todo: refactor tbl_columns_definition_form.inc.php so that it uses
// function params
$GLOBALS['action'] = 'tbl_structure.php';
$GLOBALS['num_fields'] = $num_fields;
$GLOBALS['num_fields'] = $num_fields;
// Get more complete field information.
// For now, this is done to obtain MySQL 4.1.2+ new TIMESTAMP options
@ -2271,8 +2271,8 @@ function PMA_displayHtmlForColumnChange($db, $table, $selected, $action)
/**
* Update the table's structure based on $_REQUEST
*
* @param string $db database name
* @param string $table table name
* @param string $db database name
* @param string $table table name
*
* @return boolean $regenerate true if error occurred
*
@ -2400,7 +2400,8 @@ function PMA_updateColumns($db, $table)
} else {
// An error happened while inserting/updating a table definition
$response->isSuccess(false);
$response->addJSON('message',
$response->addJSON(
'message',
PMA_Message::rawError(__('Query error') . ':<br />'.PMA_DBI_getError())
);
$regenerate = true;
@ -2411,8 +2412,10 @@ function PMA_updateColumns($db, $table)
/**
* Moves columns in the table's structure based on $_REQUEST
*
* @param string $db database name
* @param string $table table name
* @param string $db database name
* @param string $table table name
*
* @return void
*/
function PMA_moveColumns($db, $table)
{

View File

@ -321,8 +321,9 @@ if ($databases_count > 0) {
$html .= '<img class="selectallarrow" src="'
. $pmaThemeImage . 'arrow_' . $text_dir . '.png"'
. ' width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
. '<input type="checkbox" id="checkall" title="' . __('Check All') . '" /> '
. '<label for="checkall">' . __('Check All') . '</label> '
. '<input type="checkbox" id="dbStatsForm_checkall" class="checkall_box" '
. 'title="' . __('Check All') . '" /> '
. '<label for="dbStatsForm_checkall">' . __('Check All') . '</label> '
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
$html .= PMA_Util::getButtonOrImage(
'',

View File

@ -356,6 +356,10 @@ if (isset($_REQUEST['flush_privileges'])) {
$message = PMA_Message::success(__('The privileges were reloaded successfully.'));
}
if (isset($_REQUEST['validate_username'])) {
$message = PMA_Message::success();
}
/**
* some standard links
*/

View File

@ -128,7 +128,28 @@ function getServerTrafficHtml($ServerStatusData)
}
}
$retval .= '<table id="serverstatustraffic" class="data noclick">';
//display the server state traffic
$retval .= getServerStateTrafficHtml($ServerStatusData);
//display the server state connection information
$retval .= getServerStateConnectionsHtml($ServerStatusData);
//display the Table Process List information
$retval .= getTableProcesslistHtml($ServerStatusData);
return $retval;
}
/**
* Prints server state traffic information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getServerStateTrafficHtml($ServerStatusData)
{
$retval = '<table id="serverstatustraffic" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">';
@ -203,9 +224,20 @@ function getServerTrafficHtml($ServerStatusData)
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
$retval .= '</table>';
return $retval;
}
$retval .= '<table id="serverstatusconnections" class="data noclick">';
/**
* Prints server state connections information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getServerStateConnectionsHtml($ServerStatusData)
{
$retval = '<table id="serverstatusconnections" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">' . __('Connections') . '</th>';
@ -291,6 +323,18 @@ function getServerTrafficHtml($ServerStatusData)
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
/**
* Prints Table Process list
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getTableProcesslistHtml($ServerStatusData)
{
$url_params = array();
$show_full_sql = ! empty($_REQUEST['full']);
@ -373,11 +417,8 @@ function getServerTrafficHtml($ServerStatusData)
}
$result = PMA_DBI_query($sql_query);
/**
* Displays the page
*/
$retval .= '<table id="tableprocesslist" class="data clearfloat noclick sortable">';
$retval = '<table id="tableprocesslist" class="data clearfloat noclick sortable">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Processes') . '</th>';

View File

@ -89,13 +89,29 @@ function getQueryStatisticsHtml($ServerStatusData)
$retval .= '</span>';
$retval .= '</h3>';
$retval .= getServerStatusQueriesDetailsHtml($ServerStatusData);
return $retval;
}
/**
* Returns the html content for the query details
*
* @param object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getServerStatusQueriesDetailsHtml($ServerStatusData)
{
$used_queries = $ServerStatusData->used_queries;
$total_queries = array_sum($used_queries);
// reverse sort by value to show most used statements first
arsort($used_queries);
$odd_row = true;
$perc_factor = 100 / $total_queries; //(- $ServerStatusData->status['Connections']);
$retval .= '<table id="serverstatusqueriesdetails" class="data sortable noclick">';
$retval = '<table id="serverstatusqueriesdetails" class="data sortable noclick">';
$retval .= '<col class="namecol" />';
$retval .= '<col class="valuecol" span="3" />';
$retval .= '<thead>';
@ -155,7 +171,7 @@ function getQueryStatisticsHtml($ServerStatusData)
}
$retval .= htmlspecialchars(json_encode($chart_json));
$retval .= '</div>';
return $retval;
}

View File

@ -963,6 +963,10 @@ div#tablestatistics table {
#fieldset_user_global_rights fieldset {
float: <?php echo $left; ?>;
}
#fieldset_user_global_rights legend input {
margin-<?php echo $left; ?>: 2em;
}
/* END user privileges */

View File

@ -1218,6 +1218,10 @@ div#tablestatistics table {
#fieldset_user_global_rights fieldset {
float: <?php echo $left; ?>;
}
#fieldset_user_global_rights legend input {
margin-<?php echo $left; ?>: 2em;
}
/* END user privileges */