From 20abe0c1b117c369ac0cc1b5ed92975c8867774f Mon Sep 17 00:00:00 2001 From: Jo Michael Date: Fri, 16 Mar 2012 15:10:16 +0100 Subject: [PATCH 1/4] Added Javascript fieldset reset button styling in pmahomme theme. --- themes/pmahomme/css/theme_right.css.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index 993a9b14b7..848c702b22 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -197,7 +197,8 @@ input[type=submit] { } input[type=submit], -input[type=reset] { +input[type=reset], +input[name=submit_reset] { margin-left: 14px; border: 1px solid #aaa; padding: 3px 7px; @@ -215,14 +216,16 @@ input[type=reset] { } input[type=submit]:hover, -input[type=reset]:hover { +input[type=reset]:hover, +input[name=submit_reset]:hover { position: relative; getCssGradient('cccccc', 'dddddd'); ?> cursor: pointer; } input[type=submit]:active, -input[type=reset]:active { +input[type=reset]:active, +input[name=submit_reset]:active { position: relative; top: 1px; left: 1px; From a3511ff31d5a617608c414ccb3835f271c4dbb9d Mon Sep 17 00:00:00 2001 From: Jo Michael Date: Fri, 16 Mar 2012 15:28:05 +0100 Subject: [PATCH 2/4] Added Generate Password button styling in pmahomme theme. --- js/functions.js | 4 ++-- libraries/replication_gui.lib.php | 2 +- themes/pmahomme/css/theme_right.css.php | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/js/functions.js b/js/functions.js index 2e1de549ed..628255fecc 100644 --- a/js/functions.js +++ b/js/functions.js @@ -157,8 +157,8 @@ function PMA_current_version() function displayPasswordGenerateButton() { - $('#tr_element_before_generate_password').parent().append('' + PMA_messages['strGeneratePassword'] + ''); - $('#div_element_before_generate_password').parent().append('
'); + $('#tr_element_before_generate_password').parent().append('' + PMA_messages['strGeneratePassword'] + ''); + $('#div_element_before_generate_password').parent().append('
'); } /* diff --git a/libraries/replication_gui.lib.php b/libraries/replication_gui.lib.php index c1098fce3f..35970cd8e8 100644 --- a/libraries/replication_gui.lib.php +++ b/libraries/replication_gui.lib.php @@ -366,7 +366,7 @@ function PMA_replication_gui_master_addslaveuser() . ' ' . __('Generate Password') . ':' . '' . '' - . ' ' + . ' ' . '' . '' . '' diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index 848c702b22..53a7b2060d 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -198,7 +198,8 @@ input[type=submit] { input[type=submit], input[type=reset], -input[name=submit_reset] { +input[name=submit_reset], +input.button { margin-left: 14px; border: 1px solid #aaa; padding: 3px 7px; @@ -217,7 +218,8 @@ input[name=submit_reset] { input[type=submit]:hover, input[type=reset]:hover, -input[name=submit_reset]:hover { +input[name=submit_reset]:hover, +input.button:hover { position: relative; getCssGradient('cccccc', 'dddddd'); ?> cursor: pointer; @@ -225,7 +227,8 @@ input[name=submit_reset]:hover { input[type=submit]:active, input[type=reset]:active, -input[name=submit_reset]:active { +input[name=submit_reset]:active, +input.button:active { position: relative; top: 1px; left: 1px; From 7d5a945a0143176deae72648ed0b33a2bcb575b3 Mon Sep 17 00:00:00 2001 From: Jo Michael Date: Fri, 16 Mar 2012 15:52:48 +0100 Subject: [PATCH 3/4] Don't rely on $GLOBALS for 'Add User' form --- server_privileges.php | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/server_privileges.php b/server_privileges.php index 60c2c485d9..f3bcc41824 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -46,6 +46,44 @@ foreach ($get_params as $one_get_param) { } } +/** + * Sets globals from $_POST + */ + +$post_params = array( + 'createdb-1', + 'createdb-2', + 'createdb-3', + 'grant_count', + 'hostname', + 'pma_pw', + 'pma_pw2', + 'pred_hostname', + 'pred_password', + 'pred_username', + 'username' +); +foreach ($post_params as $one_post_param) { + if (isset($_POST[$one_post_param])) { + $GLOBALS[$one_post_param] = $_POST[$one_post_param]; + } +} + +/** + * Sets globals from $_POST patterns, for privileges and max_* vars + */ + +$post_patterns = array( + '/_priv$/i', + '/^max_/i' +); +foreach (array_keys($_POST) as $post_key) { + foreach ($post_patterns as $one_post_pattern) { + if (preg_match($one_post_pattern, $post_key)) { + $GLOBALS[$post_key] = $_POST[$post_key]; + } + } +} /** * Messages are built using the message name @@ -2282,15 +2320,15 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo '
' . "\n" . '' . __('Database for user') . '' . "\n"; - PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); - echo '
' . "\n"; - PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); - echo '
' . "\n"; + PMA_display_html_checkbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); + echo '
' . "\n"; + PMA_display_html_checkbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); + echo '
' . "\n"; if (! empty($dbname) ) { - PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), true, false); + PMA_display_html_checkbox('createdb-3', sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), true, false); echo '' . "\n"; - echo '
' . "\n"; + echo '
' . "\n"; } echo '
' . "\n"; From 91e0d2f5842fc35d6d08577899157aea7ba84ce0 Mon Sep 17 00:00:00 2001 From: Jo Michael Date: Fri, 16 Mar 2012 16:49:01 +0100 Subject: [PATCH 4/4] Added user export for checkbox-selected users --- js/server_privileges.js | 47 +++++++++++++++++++++++++++++++++++++++++ server_privileges.php | 35 ++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/js/server_privileges.js b/js/server_privileges.js index 7214d74dbe..4e356ba304 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -473,6 +473,53 @@ $(document).ready(function() { * @memberOf jQuery * @name export_user_click */ + $("button.mult_submit[value=export]").live('click', function(event) { + event.preventDefault(); + var $msgbox = PMA_ajaxShowMessage(); + var button_options = {}; + button_options[PMA_messages['strClose']] = function() { + $(this).dialog("close"); + }; + $.post($(this.form).prop('action'), + $(this.form).serialize() + '&submit_mult=export&ajax_request=true', + function(data) { + var $ajaxDialog = $('
') + .append(data.message) + .dialog({ + title: data.title, + width: 500, + buttons: button_options, + close: function () { + $(this).remove(); + } + }); + PMA_ajaxRemoveMessage($msgbox); + // Attach syntax highlited editor to export dialog + CodeMirror.fromTextArea( + $ajaxDialog.find('textarea')[0], + { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + mode: "text/x-mysql" + } + ); + }); //end $.post + }); + // if exporting non-ajax, highlight anyways + if ($("textarea.export")) + { + CodeMirror.fromTextArea( + $('textarea.export')[0], + { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + mode: "text/x-mysql" + } + ); + } + $(".export_user_anchor.ajax").live('click', function(event) { event.preventDefault(); var $msgbox = PMA_ajaxShowMessage(); diff --git a/server_privileges.php b/server_privileges.php index f3bcc41824..14cffd4bfc 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -1528,14 +1528,15 @@ $link_export_all = '' - . PMA_getIcon('b_tblexport.png', __('Export all')) + . PMA_getIcon('b_tblexport.png', __('Export all')) . ' ' + . __('Export all') . ''; /** * If we are in an Ajax request for Create User/Edit User/Revoke User/ * Flush Privileges, show $message and exit. */ -if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_REQUEST['adduser']) || $_add_user_error) && ! isset($_REQUEST['initial']) && ! isset($_REQUEST['showall']) && ! isset($_REQUEST['edit_user_dialog']) && ! isset($_REQUEST['db_specific'])) { +if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (! isset($_REQUEST['adduser']) || $_add_user_error) && ! isset($_REQUEST['initial']) && ! isset($_REQUEST['showall']) && ! isset($_REQUEST['edit_user_dialog']) && ! isset($_REQUEST['db_specific'])) { if (isset($sql_query)) { $extra_data['sql_query'] = PMA_showMessage(null, $sql_query); @@ -1623,8 +1624,8 @@ if (isset($viewing_mode) && $viewing_mode == 'db') { */ // export user definition -if (isset($_REQUEST['export'])) { - $response = ''; unset($username, $hostname, $grants, $one_grant); if ($GLOBALS['is_ajax_request']) { @@ -1863,7 +1879,14 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs .'' . __('Uncheck All') . '' . "\n" - . '
' + .'' . __('With selected:') . '' . "\n"; + + PMA_buttonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_export', + __('Export'), 'b_tblexport.png', 'export' + ); + echo ''; + echo '' . '
' . '
'; printf($link_export_all, urlencode('%'), urlencode('%'), (isset($initial) ? $initial : ''));