diff --git a/ChangeLog b/ChangeLog
index b223c7721c..7408a6de61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)
diff --git a/db_structure.php b/db_structure.php
index ed5a481518..5bbc0e6f2a 100644
--- a/db_structure.php
+++ b/db_structure.php
@@ -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) {
''
);
- $response->addHTML(PMA_TableHeader(false, $server_slave_status));
+ $response->addHTML(PMA_tableHeader(false, $server_slave_status));
}
list($do, $ignored) = PMA_getServerSlaveStatus(
diff --git a/js/functions.js b/js/functions.js
index 875907282d..f07294a656 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -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);
diff --git a/js/server_databases.js b/js/server_databases.js
index 17dfb8e01b..c6e844fc8f 100644
--- a/js/server_databases.js
+++ b/js/server_databases.js
@@ -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()) + '`;';
});
diff --git a/js/server_privileges.js b/js/server_privileges.js
index 8863b4cceb..7e170fe613 100644
--- a/js/server_privileges.js
+++ b/js/server_privileges.js
@@ -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 {
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php
index c364c7f6af..7cb30073ba 100644
--- a/libraries/DisplayResults.class.php
+++ b/libraries/DisplayResults.class.php
@@ -5037,9 +5037,9 @@ class PMA_DisplayResults
. ' alt="' . __('With selected:') . '" />';
}
- $links_html .= ' '
- . '' . __('Check All') . ' '
+ $links_html .= ' '
+ . '' . __('Check All') . ' '
. '' . __('With selected:') . ' ' . "\n";
$links_html .= PMA_Util::getButtonOrImage(
diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php
index 471fc0ef9d..62f7af4427 100644
--- a/libraries/server_privileges.lib.php
+++ b/libraries/server_privileges.lib.php
@@ -774,12 +774,9 @@ function PMA_getHtmlForGlobalOrDbSpecificPrivs($db, $table, $row)
} else {
$html_output .= __('Table-specific privileges');
}
- $html_output .= ' (' . __('Check All') . ' /'
- . '' . __('Uncheck All') . ' )';
+ $html_output .= ' '
+ . '' . __('Check All') . ' ';
$html_output .= '';
$html_output .= '
'
. __('Note: MySQL privilege names are expressed in English')
@@ -982,7 +979,7 @@ function PMA_getHtmlForGlobalPrivTableWithCheckboxes(
. '' . $privTable_names[$i] . ' ' . "\n";
foreach ($table as $priv) {
$html_output .= '
' . "\n"
- . ' ' . "\n";
@@ -1068,8 +1066,15 @@ function PMA_getHtmlForDisplayLoginInformationFields($mode = 'new')
: $GLOBALS['username']
) . '"'
)
- . ' onchange="pred_username.value = \'userdefined\';" />' . "\n"
- . '
' . "\n";
+ . ' onchange="pred_username.value = \'userdefined\';" />' . "\n";
+
+ $html_output .= ''
+ . PMA_Message::notice(
+ __('An account already exists with the same username but possibly a different hostname. Are you sure you wish to proceed?')
+ )->getDisplay()
+ . '
';
+ $html_output .= '';
$html_output .= '' . "\n"
. '
' . "\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,
. '' . "\n";
$html_output .= ''
- .'
' . "\n"
- .'
'
- .'
' . __('Check All') . ' '
- .'
' . __('With selected:') . ' ' . "\n";
+ . '
' . "\n"
+ . '
'
+ . '
' . __('Check All') . ' '
+ . '
' . __('With selected:') . ' ' . "\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++;
diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php
index 62a75bbc39..1b88c0cb39 100644
--- a/libraries/structure.lib.php
+++ b/libraries/structure.lib.php
@@ -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 .= '
';
- $html_output .= '
' .__('Check All') . ' ';
+ $html_output .= '
';
+ $html_output .= '
' .__('Check All') . ' ';
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 .= '
'
. ''
. $titles['Change'] . ' ' . ' ';
$html_output .= '
'
@@ -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 .= ' '
- . '' . __('Check All') . ' ';
+ $html_output .= ' '
+ . '' . __('Check All') . ' ';
$html_output .= ''
. __('With selected:') . ' ';
@@ -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') . ': '.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)
{
diff --git a/server_databases.php b/server_databases.php
index d703fa6e74..14c271f555 100644
--- a/server_databases.php
+++ b/server_databases.php
@@ -321,8 +321,9 @@ if ($databases_count > 0) {
$html .= ' ' . "\n"
- . ' '
- . '' . __('Check All') . ' '
+ . ' '
+ . '' . __('Check All') . ' '
. '' . __('With selected:') . ' ' . "\n";
$html .= PMA_Util::getButtonOrImage(
'',
diff --git a/server_privileges.php b/server_privileges.php
index ef1449582b..eb7ae58b98 100644
--- a/server_privileges.php
+++ b/server_privileges.php
@@ -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
*/
diff --git a/server_status.php b/server_status.php
index f9b9e797ef..592cf749cc 100644
--- a/server_status.php
+++ b/server_status.php
@@ -128,7 +128,28 @@ function getServerTrafficHtml($ServerStatusData)
}
}
- $retval .= '';
+ //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 = '';
$retval .= '';
$retval .= '';
$retval .= '';
@@ -203,9 +224,20 @@ function getServerTrafficHtml($ServerStatusData)
$retval .= '';
$retval .= ' ';
$retval .= '';
- $retval .= '
';
+ $retval .= '
';
+ return $retval;
+}
- $retval .= '';
+/**
+ * Prints server state connections information
+ *
+ * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
+ *
+ * @return string
+ */
+function getServerStateConnectionsHtml($ServerStatusData)
+{
+ $retval = '';
$retval .= '';
$retval .= '';
$retval .= '' . __('Connections') . ' ';
@@ -291,6 +323,18 @@ function getServerTrafficHtml($ServerStatusData)
$retval .= '';
$retval .= '
';
+ 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 .= '';
+
+ $retval = '';
$retval .= '';
$retval .= '';
$retval .= '' . __('Processes') . ' ';
diff --git a/server_status_queries.php b/server_status_queries.php
index ef1968e7ec..3df0725b76 100644
--- a/server_status_queries.php
+++ b/server_status_queries.php
@@ -89,13 +89,29 @@ function getQueryStatisticsHtml($ServerStatusData)
$retval .= '';
$retval .= '';
+ $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 .= '';
+ $retval = '';
$retval .= ' ';
$retval .= ' ';
$retval .= '';
@@ -155,7 +171,7 @@ function getQueryStatisticsHtml($ServerStatusData)
}
$retval .= htmlspecialchars(json_encode($chart_json));
$retval .= '';
-
+
return $retval;
}
diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php
index 46854707d8..a2dceaf372 100644
--- a/themes/original/css/common.css.php
+++ b/themes/original/css/common.css.php
@@ -963,6 +963,10 @@ div#tablestatistics table {
#fieldset_user_global_rights fieldset {
float: ;
}
+
+#fieldset_user_global_rights legend input {
+ margin-: 2em;
+}
/* END user privileges */
diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php
index 949131b7ac..27d3a70df3 100644
--- a/themes/pmahomme/css/common.css.php
+++ b/themes/pmahomme/css/common.css.php
@@ -1218,6 +1218,10 @@ div#tablestatistics table {
#fieldset_user_global_rights fieldset {
float: ;
}
+
+#fieldset_user_global_rights legend input {
+ margin-: 2em;
+}
/* END user privileges */