diff --git a/ChangeLog b/ChangeLog index 3358b48f04..6e92d58e3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ phpMyAdmin - ChangeLog - rfe #1523 Better visual clue for table structure primary key column - rfe #982 Support for editing binary fields in hexadecimal - bug #4416 New lines are removed when grid editing +- rfe #706 Multi-db privileges adding 4.2.3.0 (not yet released) - bug #4423 Moving fields not working diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 2a8c8c175c..2ad3a1e995 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2844,11 +2844,9 @@ function PMA_getHtmlForSelectDbInEditPrivs($found_rows) $databases_to_skip = array('information_schema', 'performance_schema'); $html_output = '' . "\n"; + . __('Add privileges on the following database(s):') . '' . "\n"; if (! empty($pred_db_array)) { - $html_output .= '' . "\n"; foreach ($pred_db_array as $current_db) { if (in_array($current_db, $databases_to_skip)) { continue; @@ -2867,8 +2865,7 @@ function PMA_getHtmlForSelectDbInEditPrivs($found_rows) } $html_output .= '' . "\n"; } - $html_output .= '' + $html_output .= '' . "\n" . PMA_Util::showHint( __('Wildcards % and _ should be escaped with a \ to use them literally.') @@ -3644,9 +3641,39 @@ function PMA_getDataForDBInfo() unset($tablename); } - if (PMA_isValid($_REQUEST['pred_dbname'])) { + if (isset($_REQUEST['pred_dbname'])) { + $is_valid_pred_dbname = true; + foreach ($_REQUEST['pred_dbname'] as $key => $db_name) { + if (! PMA_isValid($db_name)) { + $is_valid_pred_dbname = false; + break; + } + } + } + + if (isset($_REQUEST['dbname'])) { + $is_valid_dbname = true; + if (is_array($_REQUEST['dbname'])) { + foreach ($_REQUEST['dbname'] as $key => $db_name) { + if (! PMA_isValid($db_name)) { + $is_valid_dbname = false; + break; + } + } + } else { + if (! PMA_isValid($_REQUEST['dbname'])) { + $is_valid_dbname = false; + } + } + } + + if (isset($is_valid_pred_dbname) && $is_valid_pred_dbname) { $dbname = $_REQUEST['pred_dbname']; - } elseif (PMA_isValid($_REQUEST['dbname'])) { + // If dbname contains only one database. + if (count($dbname) == 1) { + $dbname = $dbname[0]; + } + } elseif (isset($is_valid_dbname) && $is_valid_dbname) { $dbname = $_REQUEST['dbname']; } else { unset($dbname); @@ -3654,12 +3681,25 @@ function PMA_getDataForDBInfo() } if (isset($dbname)) { - $unescaped_db = PMA_Util::unescapeMysqlWildcards($dbname); - $db_and_table = PMA_Util::backquote($unescaped_db) . '.'; + if (is_array($dbname)) { + $db_and_table = $dbname; + foreach ($db_and_table as $key => $db_name) { + $db_and_table[$key] .= '.'; + } + } else { + $unescaped_db = PMA_Util::unescapeMysqlWildcards($dbname); + $db_and_table = PMA_Util::backquote($unescaped_db) . '.'; + } if (isset($tablename)) { $db_and_table .= PMA_Util::backquote($tablename); } else { - $db_and_table .= '*'; + if (is_array($db_and_table)) { + foreach ($db_and_table as $key => $db_name) { + $db_and_table[$key] .= '*'; + } + } else { + $db_and_table .= '*'; + } } } else { $db_and_table = '*.*'; @@ -3668,7 +3708,7 @@ function PMA_getDataForDBInfo() // check if given $dbname is a wildcard or not if (isset($dbname)) { //if (preg_match('/\\\\(?:_|%)/i', $dbname)) { - if (preg_match('/(?' . "\n"; $html_output .= ' - '; - $html_output .= $dbname_is_wildcard ? __('Databases') : __('Database'); + $html_output .= ($dbname_is_wildcard + || is_array($dbname) && count($dbname) > 1) + ? __('Databases') : __('Database'); if (! empty($_REQUEST['tablename'])) { $html_output .= ' ' . "\n"; $html_output .= PMA_URL_getHiddenInputs($_params); $html_output .= PMA_getHtmlToDisplayPrivilegesTable( - PMA_ifSetOr($dbname, '*', 'length'), + // If $dbname is an array, pass any one db as all have same privs. + PMA_ifSetOr($dbname, (is_array($dbname)) ? $dbname[0] : '*', 'length'), PMA_ifSetOr($tablename, '*', 'length') ); $html_output .= '' . "\n"; - if (! strlen($tablename) && empty($dbname_is_wildcard)) { + if (! is_array($dbname) && ! strlen($tablename) && empty($dbname_is_wildcard)) { // no table name was given, display all table specific rights // but only if $dbname contains no wildcards @@ -4013,12 +4063,12 @@ function PMA_getHtmlForUserProperties($dbname_is_wildcard,$url_dbname, } // Provide a line with links to the relevant database and table - if (strlen($dbname) && empty($dbname_is_wildcard)) { + if (! is_array($dbname) && strlen($dbname) && empty($dbname_is_wildcard)) { $html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename); } - if (! strlen($dbname) && ! $user_does_not_exists) { + if (! is_array($dbname) && ! strlen($dbname) && ! $user_does_not_exists) { //change login information $html_output .= PMA_getHtmlForChangePassword($username, $hostname); $html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname); diff --git a/po/tr.po b/po/tr.po index 8f4ca237bf..548ad6c6c3 100644 --- a/po/tr.po +++ b/po/tr.po @@ -6188,7 +6188,7 @@ msgid "" "pma__savedsearches[/kbd]." msgstr "" "QBE kaydedilmiş aramalar desteği istenmiyorsa boş bırakın, önerilen: " -"[kbd]pma__savedsearches[/kbd]" +"[kbd]pma__savedsearches[/kbd]." #: libraries/config/messages.inc.php:622 msgid "Try to connect without password." diff --git a/server_privileges.php b/server_privileges.php index b6da7d6f1e..d061a042f1 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -185,12 +185,25 @@ if (isset($_REQUEST['change_copy'])) { * Updates privileges */ if (! empty($_POST['update_privs'])) { - list($sql_query, $message) = PMA_updatePrivileges( - (isset($username) ? $username : ''), - (isset($hostname) ? $hostname : ''), - (isset($tablename) ? $tablename : ''), - (isset($dbname) ? $dbname : '') - ); + if (is_array($dbname)) { + foreach ($dbname as $key => $db_name) { + list($sql_query[$key], $message) = PMA_updatePrivileges( + (isset($username) ? $username : ''), + (isset($hostname) ? $hostname : ''), + (isset($tablename) ? $tablename : ''), + (isset($db_name) ? $db_name : '') + ); + } + + $sql_query = implode("\n", $sql_query); + } else { + list($sql_query, $message) = PMA_updatePrivileges( + (isset($username) ? $username : ''), + (isset($hostname) ? $hostname : ''), + (isset($tablename) ? $tablename : ''), + (isset($dbname) ? $dbname : '') + ); + } } /** @@ -368,12 +381,16 @@ if (isset($_REQUEST['adduser'])) { if ($GLOBALS['is_ajax_request'] == true) { header('Cache-Control: no-cache'); } - $url_dbname = urlencode( - str_replace( - array('\_', '\%'), - array('_', '%'), $_REQUEST['dbname'] - ) - ); + if (! is_array($dbname)) { + $url_dbname = urlencode( + str_replace( + array('\_', '\%'), + array('_', '%'), $_REQUEST['dbname'] + ) + ); + } else { + $url_dbname = ''; + } $response->addHTML( PMA_getHtmlForUserProperties( ((isset ($dbname_is_wildcard)) ? $dbname_is_wildcard : ''), diff --git a/test/libraries/PMA_server_privileges_test.php b/test/libraries/PMA_server_privileges_test.php index 3442222ec7..0c22556d45 100644 --- a/test/libraries/PMA_server_privileges_test.php +++ b/test/libraries/PMA_server_privileges_test.php @@ -170,7 +170,7 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase //pre variable have been defined $_REQUEST['pred_tablename'] = "PMA_pred__tablename"; - $_REQUEST['pred_dbname'] = "PMA_pred_dbname"; + $_REQUEST['pred_dbname'] = array("PMA_pred_dbname"); list( $username, $hostname, $dbname, $tablename, $db_and_table, $dbname_is_wildcard