From 800308a5f117381dee30ab7ca35557fb41937133 Mon Sep 17 00:00:00 2001 From: Thilina Buddika Date: Fri, 13 Jul 2012 21:10:09 +0530 Subject: [PATCH] improve PMA_getWithClauseForAddUserAndUpdatePrivs() function --- libraries/server_privileges.lib.php | 8 +++++++- server_privileges.php | 7 +++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index e26ec18085..c3afa08b50 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1185,27 +1185,33 @@ function PMA_getMessageAndSqlQueryForPrivilegesRevoke($db_and_table, $dbname, */ function PMA_getWithClauseForAddUserAndUpdatePrivs() { + $isWith = false; $sql_query = ''; if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') { $sql_query .= ' GRANT OPTION'; + $isWith = true; } if (isset($_POST['max_questions'])) { $max_questions = max(0, (int)$_POST['max_questions']); $sql_query .= ' MAX_QUERIES_PER_HOUR ' . $max_questions; + $isWith = true; } if (isset($_POST['max_connections'])) { $max_connections = max(0, (int)$_POST['max_connections']); $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . $max_connections; + $isWith = true; } if (isset($_POST['max_updates'])) { $max_updates = max(0, (int)$_POST['max_updates']); $sql_query .= ' MAX_UPDATES_PER_HOUR ' . $max_updates; + $isWith = true; } if (isset($_POST['max_user_connections'])) { $max_user_connections = max(0, (int)$_POST['max_user_connections']); $sql_query .= ' MAX_USER_CONNECTIONS ' . $max_user_connections; + $isWith = true; } - return $sql_query; + return ($isWith ? 'WITH' . $sql_query : $sql_query); } /** diff --git a/server_privileges.php b/server_privileges.php index a64eaa96cf..51c375f5a1 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -279,11 +279,10 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) { || isset($max_updates) || isset($max_user_connections)) ) { $with_clause = PMA_getWithClauseForAddUserAndUpdatePrivs(); + $real_sql_query .= $with_clause; + $sql_query .= $with_clause; } - if (!empty ($with_clause)) { - $real_sql_query .= 'WITH' . $with_clause; - $sql_query .= 'WITH' . $with_clause; - } + if (isset($create_user_real)) { $create_user_real .= ';'; $create_user_show .= ';';