improve PMA_getWithClauseForAddUserAndUpdatePrivs() function

This commit is contained in:
Thilina Buddika 2012-07-13 21:10:09 +05:30
parent f0dbcd4733
commit 800308a5f1
2 changed files with 10 additions and 5 deletions

View File

@ -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);
}
/**

View File

@ -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 .= ';';