From 99c65f37e72b2718f01b2517660a770ba5b1520f Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Fri, 30 Aug 2013 18:49:03 +0530 Subject: [PATCH 01/88] Table specific privileges --- libraries/Menu.class.php | 21 +- libraries/Util.class.php | 1 + libraries/build_html_for_db.lib.php | 2 +- libraries/server_privileges.lib.php | 343 ++++++++++++++++++++++++++-- server_privileges.php | 62 ++--- 5 files changed, 379 insertions(+), 50 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 5bdcaf39eb..08d8af7700 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -292,6 +292,7 @@ class PMA_Menu { $db_is_information_schema = $GLOBALS['dbi']->isSystemSchema($this->_db); $tbl_is_view = PMA_Table::isView($this->_db, $this->_table); + $is_superuser = $GLOBALS['dbi']->isSuperuser(); $tabs = array(); @@ -328,14 +329,26 @@ class PMA_Menu $tabs['export']['text'] = __('Export'); /** - * Don't display "Import" and "Operations" - * for views and information_schema + * Don't display "Import" for views and information_schema */ if (! $tbl_is_view && ! $db_is_information_schema) { $tabs['import']['icon'] = 'b_tblimport.png'; $tabs['import']['link'] = 'tbl_import.php'; $tabs['import']['text'] = __('Import'); - + } + if ($is_superuser && ! PMA_DRIZZLE && ! $db_is_information_schema) { + $tabs['privileges']['link'] = 'server_privileges.php'; + $tabs['privileges']['args']['checkprivsdb'] = $this->_db; + $tabs['privileges']['args']['checkprivstable'] = $this->_table; + // stay on table view + $tabs['privileges']['args']['viewing_mode'] = 'table'; + $tabs['privileges']['text'] = __('Privileges'); + $tabs['privileges']['icon'] = 's_rights.png'; + } + /** + * Don't display "Operations" for views and information_schema + */ + if (! $tbl_is_view && ! $db_is_information_schema) { $tabs['operation']['icon'] = 'b_tblops.png'; $tabs['operation']['link'] = 'tbl_operations.php'; $tabs['operation']['text'] = __('Operations'); @@ -425,7 +438,7 @@ class PMA_Menu if ($is_superuser && ! PMA_DRIZZLE) { $tabs['privileges']['link'] = 'server_privileges.php'; - $tabs['privileges']['args']['checkprivs'] = $this->_db; + $tabs['privileges']['args']['checkprivsdb'] = $this->_db; // stay on database view $tabs['privileges']['args']['viewing_mode'] = 'db'; $tabs['privileges']['text'] = __('Privileges'); diff --git a/libraries/Util.class.php b/libraries/Util.class.php index b97f6f0edc..907478d1a4 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -4114,6 +4114,7 @@ class PMA_Util 'insert' => __('Insert'), 'export' => __('Export'), 'import' => __('Import'), + 'privileges' => __('Privileges'), 'operation' => __('Operations'), 'tracking' => __('Tracking'), 'triggers' => __('Triggers'), diff --git a/libraries/build_html_for_db.lib.php b/libraries/build_html_for_db.lib.php index 466e4506cc..0fcee3101b 100644 --- a/libraries/build_html_for_db.lib.php +++ b/libraries/build_html_for_db.lib.php @@ -165,7 +165,7 @@ function PMA_buildHtmlForDb( . 'PMA_commonActions.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');' . '" href="server_privileges.php?' . $url_query - . '&checkprivs=' . urlencode($current['SCHEMA_NAME']) + . '&checkprivsdb=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf( __('Check privileges for database "%s".'), diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 29b8e476db..83a67cc2ad 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -94,14 +94,19 @@ function PMA_rangeOfUsers($initial = '') * * @param array $row the row * @param boolean $enableHTML add tag with tooltips + * @param boolean $tablePrivs whether row contains table privileges * * @global resource $user_link the database connection * * @return array */ -function PMA_extractPrivInfo($row = '', $enableHTML = false) +function PMA_extractPrivInfo($row = '', $enableHTML = false, $tablePrivs = false) { - $grants = PMA_getGrantsArray(); + if ($tablePrivs) { + $grants = PMA_getTableGrantsArray(); + } else { + $grants = PMA_getGrantsArray(); + } if (! empty($row) && isset($row['Table_priv'])) { $row1 = $GLOBALS['dbi']->fetchSingleRow( @@ -178,6 +183,57 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false) return $privs; } // end of the 'PMA_extractPrivInfo()' function +function PMA_getTableGrantsArray() +{ + return array( + array( + 'Delete', + 'DELETE', + $GLOBALS['strPrivDescDelete'] + ), + array( + 'Create', + 'CREATE', + $GLOBALS['strPrivDescCreateTbl'] + ), + array( + 'Drop', + 'DROP', + $GLOBALS['strPrivDescDropTbl'] + ), + array( + 'Grant', + 'GRANT', + $GLOBALS['strPrivDescGrant'] + ), + array( + 'Index', + 'INDEX', + $GLOBALS['strPrivDescIndex'] + ), + array( + 'Alter', + 'ALTER', + $GLOBALS['strPrivDescAlter'] + ), + array( + 'Create view', + 'CREATE_VIEW', + $GLOBALS['strPrivDescCreateView'] + ), + array( + 'Show viwew', + 'SHOW_VIEW', + $GLOBALS['strPrivDescShowView'] + ), + array( + 'Trigger', + 'TRIGGER', + $GLOBALS['strPrivDescTrigger'] + ), + ); +} + /** * Get the grants array which contains all the privilege types * and relevent grant messages @@ -1730,9 +1786,11 @@ function PMA_getListOfPrivilegesAndComparedPrivileges() /** * Get the HTML for user form and check the privileges for a particular database. * + * @param string $db database name + * * @return string $html_output */ -function PMA_getHtmlForSpecificDbPrivileges() +function PMA_getHtmlForSpecificDbPrivileges($db) { // check the privileges for a particular database. $html_output = '
' @@ -1743,8 +1801,8 @@ function PMA_getHtmlForSpecificDbPrivileges() . sprintf( __('Users having access to "%s"'), '' - . htmlspecialchars($_REQUEST['checkprivs']) + . PMA_URL_getCommon($db) . '">' + . htmlspecialchars($db) . '' ) . "\n" @@ -1767,7 +1825,7 @@ function PMA_getHtmlForSpecificDbPrivileges() $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`' .' FROM `mysql`.`db`' - .' WHERE \'' . PMA_Util::sqlAddSlashes($_REQUEST['checkprivs']) + .' WHERE \'' . PMA_Util::sqlAddSlashes($db) . "'" .' LIKE `Db`' .' AND NOT (' . $list_of_compared_privileges. ')) ' @@ -1784,7 +1842,7 @@ function PMA_getHtmlForSpecificDbPrivileges() $found = true; } $html_output .= PMA_getHtmlTableBodyForSpecificDbPrivs( - $found, $row, $odd_row, $res + $db, $found, $row, $odd_row, $res ); $html_output .= '' . '' @@ -1807,11 +1865,11 @@ function PMA_getHtmlForSpecificDbPrivileges() . PMA_URL_getCommon( array( 'adduser' => 1, - 'dbname' => $_REQUEST['checkprivs'], + 'dbname' => $db, ) ) .'" rel="' - . PMA_URL_getCommon(array('checkprivs' => $_REQUEST['checkprivs'])) + . PMA_URL_getCommon(array('checkprivsdb' => $db)) . '" class="ajax" name="db_specific">' . "\n" . PMA_Util::getIcon('b_usradd.png') . ' ' . __('Add user') . '' . "\n"; @@ -1824,6 +1882,7 @@ function PMA_getHtmlForSpecificDbPrivileges() /** * Get HTML snippet for table body of specific database privileges * + * @param boolean $db database * @param boolean $found whether user found or not * @param array $row array of rows from mysql, * db table with list of privileges @@ -1832,7 +1891,7 @@ function PMA_getHtmlForSpecificDbPrivileges() * * @return string $html_output */ -function PMA_getHtmlTableBodyForSpecificDbPrivs($found, $row, $odd_row, +function PMA_getHtmlTableBodyForSpecificDbPrivs($db, $found, $row, $odd_row, $res ) { $html_output = '' . "\n"; @@ -1874,11 +1933,7 @@ function PMA_getHtmlTableBodyForSpecificDbPrivs($found, $row, $odd_row, . ' '; if (! isset($current['Db']) || $current['Db'] == '*') { $html_output .= __('global'); - } elseif ( - $current['Db'] == PMA_Util::escapeMysqlWildcards( - $_REQUEST['checkprivs'] - ) - ) { + } elseif ($current['Db'] == PMA_Util::escapeMysqlWildcards($db)) { $html_output .= __('database-specific'); } else { $html_output .= __('wildcard'). ': ' @@ -1933,6 +1988,260 @@ function PMA_getHtmlTableBodyForSpecificDbPrivs($found, $row, $odd_row, return $html_output; } +/** + * Get the HTML for user form and check the privileges for a particular table. + * + * @param string $db database name + * @param string $table table name + * + * @return string $html_output + */ +function PMA_getHtmlForSpecificTablePrivileges($db, $table) +{ + // check the privileges for a particular database. + $html_output = '' + . '
'; + $html_output .= '' + . PMA_Util::getIcon('b_usrcheck.png') + . ' ' + . sprintf( + __('Users having access to "%s"'), + '' + . htmlspecialchars($db) . '.' . htmlspecialchars($table) + . '' + ) + . "\n" + . ''; + + $html_output .= '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . ''; + + list($list_of_privileges, $list_of_compared_privileges) + = PMA_getListOfPrivilegesAndComparedPrivileges(); + $sql_query = + "(" + . " SELECT " . $list_of_privileges . ", '*' AS `Db`" + . " FROM `mysql`.`user`" + . " WHERE NOT (" . $list_of_compared_privileges . ")" + . ")" + . " UNION " + . "(" + . " SELECT " . $list_of_privileges . ", `Db`" + . " FROM `mysql`.`db`" + . " WHERE `Db` LIKE '" . PMA_Util::sqlAddSlashes($db) . "'" + . " AND NOT (" . $list_of_compared_privileges. ")" + . ")" + . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC;"; + $res = $GLOBALS['dbi']->query($sql_query); + + $privMap = array(); + while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { + $user = $row['User']; + $host = $row['Host']; + if (! isset($privMap[$user])) { + $privMap[$user] = array(); + } + if (! isset($privMap[$user][$host])) { + $privMap[$user][$host] = array(); + } + $privMap[$user][$host][] = $row; + } + + $sql_query = "SELECT `User`, `Host`, `Db`, `Table_name`, `Table_priv`" + . " FROM `mysql`.`tables_priv`" + . " WHERE `Db` LIKE '" . PMA_Util::sqlAddSlashes($db) . "'" + . " AND `Table_name` LIKE '" . PMA_Util::sqlAddSlashes($table) . "'" + . " AND NOT (`Table_priv` = '' AND Column_priv = '')" + . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC, `Table_priv` ASC;"; + $res = $GLOBALS['dbi']->query($sql_query); + while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { + $user = $row['User']; + $host = $row['Host']; + if (! isset($privMap[$user])) { + $privMap[$user] = array(); + } + if (! isset($privMap[$user][$host])) { + $privMap[$user][$host] = array(); + } + $privMap[$user][$host][] = $row; + } + + $html_output .= PMA_getHtmlTableBodyForSpecificTablePrivs($db, $table, $privMap); + $html_output .= '
' . __('User') . '' . __('Host') . '' . __('Type') . '' . __('Privileges') . '' . __('Grant') . '' . __('Action') . '
' + . '
' + . '
'; + + // Offer to create a new user for the current database + $html_output .= '
' + . '' . _pgettext('Create new user', 'New') . ''; + $html_output .= '' + . PMA_Util::getIcon('b_usradd.png') . __('Add user') . ''; + + $html_output .= '
'; + return $html_output; +} + +/** + * Get HTML snippet for table body of specific table privileges + * + * @param boolean $db database + * @param boolean $db table + * @param boolean $privMap priviledge map + * + * @return string $html_output + */ +function PMA_getHtmlTableBodyForSpecificTablePrivs($db, $table, $privMap) { + $html_output = ''; + $odd_row = true; + if (! empty($privMap)) { + foreach ($privMap as $current_user => $val) { + foreach ($val as $current_host => $current_privileges) { + $html_output .= ''; + + // user + $html_output .= ' 1) { + $html_output .= ' rowspan="' . count($current_privileges) . '"'; + } + $html_output .= '>'; + if (empty($current_user)) { + $html_output .= '' . __('Any') . ''; + } else { + $html_output .= htmlspecialchars($current_user); + } + $html_output .= ''; + + // host + $html_output .= ' 1) { + $html_output .= ' rowspan="' . count($current_privileges) . '"'; + } + $html_output .= '>'; + $html_output .= htmlspecialchars($current_host); + $html_output .= ''; + + for ($i = 0; $i < count($current_privileges); $i++) { + $current = $current_privileges[$i]; + + // type + $html_output .= ''; + if ($current['Db'] == '*') { + $html_output .= __('global'); + } elseif ($current['Db'] == PMA_Util::escapeMysqlWildcards($db)) { + if (isset($current['Table_name']) + && $current['Table_name'] == PMA_Util::escapeMysqlWildcards($table) + ) { + $html_output .= __('table-specific'); + } else { + $html_output .= __('database-specific'); + } + } else { + $html_output .= __('wildcard'). ': ' + . '' . htmlspecialchars($current['Db']) . ''; + } + $html_output .= ''; + + // privileges + $html_output .= ''; + if (isset($current['Table_name'])) { + $privList = explode(',', $current['Table_priv']); + $privs = array(); + $grantsArr = PMA_getTableGrantsArray(); + foreach($grantsArr as $grant) { + $privs[$grant[0]] = 'N'; + foreach ($privList as $priv) { + if ($grant[0] == $priv) { + $privs[$grant[0]] = 'Y'; + } + } + } + $html_output .= '' + . join( + ',', + PMA_extractPrivInfo($privs, true, true) + ) + . ''; + } else { + $html_output .= '' + . join( + ',', + PMA_extractPrivInfo($current, true) + ) + . ''; + } + $html_output .= ''; + + // grant + $html_output .= ''; + $containsGrant = false; + if (isset($current['Table_name'])) { + $privList = explode(',', $current['Table_priv']); + foreach ($privList as $priv) { + if ($priv == 'Grant') { + $containsGrant = true; + } + } + } else { + $containsGrant = $current['Grant_priv'] == 'Y'; + } + $html_output .= ($containsGrant ? __('Yes') : __('No')); + $html_output .= ''; + + // action + $html_output .= ''; + $html_output .= PMA_getUserEditLink( + $current_user, + $current_host, + (isset($current['Db']) && $current['Db'] != '*') ? $current['Db'] : '', + (isset($current['Table_name']) && $current['Table_name'] != '*') ? $current['Table_name'] : '' + ); + $html_output .= ''; + + $html_output .= ''; + if (($i + 1) < count($current_privileges)) { + $html_output .= ''; + } + } + $odd_row = ! $odd_row; + } + } + } else { + $html_output .= '' + . '' + . ' ' . __('No user found.') + . '' + . ''; + } + $html_output .= ''; + + return $html_output; +} + /** * Returns edit link for a user. * @@ -3415,7 +3724,7 @@ function PMA_getHtmlHeaderForDisplayUserProperties( . __('Edit Privileges:') . ' ' . __('User'); - if (isset($dbname)) { + if (! empty($dbname)) { $html_output .= ' addHTML( PMA_getHtmlForUserGroupDialog( - isset($username)? $username : null, + isset($username)? $username : null, $cfgRelation['menuswork'] ) ); @@ -328,10 +328,26 @@ if (isset($_REQUEST['export']) } } -if (empty($_REQUEST['adduser']) - && (! isset($_REQUEST['checkprivs']) - || ! strlen($_REQUEST['checkprivs'])) -) { +if (isset($_REQUEST['adduser'])) { + // Add user + $response->addHTML( + PMA_getHtmlForAddUser((isset($dbname) ? $dbname : '')) + ); +} elseif (isset($_REQUEST['checkprivsdb'])) { + if (isset($_REQUEST['checkprivstable'])) { + // check the privileges for a particular table. + $response->addHTML( + PMA_getHtmlForSpecificTablePrivileges( + $_REQUEST['checkprivsdb'], $_REQUEST['checkprivstable'] + ) + ); + } else { + // check the privileges for a particular database. + $response->addHTML( + PMA_getHtmlForSpecificDbPrivileges($_REQUEST['checkprivsdb']) + ); + } +} else { if (! isset($username)) { // No username is given --> display the overview $response->addHTML( @@ -358,17 +374,7 @@ if (empty($_REQUEST['adduser']) ) ); } -} elseif (isset($_REQUEST['adduser'])) { - // Add user - $response->addHTML( - PMA_getHtmlForAddUser((isset($dbname) ? $dbname : '')) - ); -} else { - // check the privileges for a particular database. - $response->addHTML( - PMA_getHtmlForSpecificDbPrivileges() - ); -} // end if (empty($_REQUEST['adduser']) && empty($checkprivs))... elseif... else... +} if ((empty($_REQUEST['viewing_mode']) || $_REQUEST['viewing_mode'] != 'db') && $GLOBALS['cfgRelation']['menuswork'] From d19049cb817da9f01ebf9bb757d32c477e797cb0 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sat, 31 Aug 2013 13:23:24 +0530 Subject: [PATCH 02/88] Show sub menus only in Users page --- libraries/Menu.class.php | 1 + server_privileges.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 08d8af7700..87ebca45d3 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -535,6 +535,7 @@ class PMA_Menu array('server_privileges.php', 'server_user_groups.php') ); } + $tabs['rights']['args']['viewing_mode'] = 'server'; $tabs['export']['icon'] = 'b_export.png'; $tabs['export']['link'] = 'server_export.php'; diff --git a/server_privileges.php b/server_privileges.php index 7e6b91c51c..83f0f32b82 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -27,7 +27,7 @@ $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_privileges.js'); -if ((empty($_REQUEST['viewing_mode']) || $_REQUEST['viewing_mode'] != 'db') +if ((isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'server') && $GLOBALS['cfgRelation']['menuswork'] ) { $response->addHTML('
'); @@ -376,7 +376,7 @@ if (isset($_REQUEST['adduser'])) { } } -if ((empty($_REQUEST['viewing_mode']) || $_REQUEST['viewing_mode'] != 'db') +if ((isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'server') && $GLOBALS['cfgRelation']['menuswork'] ) { $response->addHTML('
'); From bd29b3ff85418bb0bec633650d7ad3f12eba38f1 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sat, 31 Aug 2013 13:24:34 +0530 Subject: [PATCH 03/88] Go to DefaultTabTable --- libraries/server_privileges.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 83a67cc2ad..f97f9a6950 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2006,7 +2006,7 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) . ' ' . sprintf( __('Users having access to "%s"'), - '
$db, From 5b18bd044aea5dbc088358192751178cc060a802 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sat, 31 Aug 2013 13:32:07 +0530 Subject: [PATCH 04/88] Use !empty() to avoid empty queries being executed --- libraries/server_privileges.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index f97f9a6950..8111ab6682 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -3340,11 +3340,11 @@ function PMA_updatePrivileges($username, $hostname, $tablename, $dbname) // See https://sourceforge.net/p/phpmyadmin/bugs/3270/ $sql_query0 = ''; } - if (isset($sql_query1) && ! $GLOBALS['dbi']->tryQuery($sql_query1)) { + if (! empty($sql_query1) && ! $GLOBALS['dbi']->tryQuery($sql_query1)) { // this one may fail, too... $sql_query1 = ''; } - if (isset($sql_query2)) { + if (! empty($sql_query2)) { $GLOBALS['dbi']->query($sql_query2); } else { $sql_query2 = ''; From 9c14c833d93f1cb19f34d92625f3c0c5cf1a79f8 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sat, 31 Aug 2013 14:00:33 +0530 Subject: [PATCH 05/88] Reuse code from table specific privilege table for the db specific privilege table --- libraries/server_privileges.lib.php | 168 ++++++---------------------- 1 file changed, 33 insertions(+), 135 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 8111ab6682..add910db87 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1837,13 +1837,21 @@ function PMA_getHtmlForSpecificDbPrivileges($db) .' `Host` ASC,' .' `Db` ASC;'; $res = $GLOBALS['dbi']->query($sql_query); - $row = $GLOBALS['dbi']->fetchAssoc($res); - if ($row) { - $found = true; + + $privMap = array(); + while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { + $user = $row['User']; + $host = $row['Host']; + if (! isset($privMap[$user])) { + $privMap[$user] = array(); + } + if (! isset($privMap[$user][$host])) { + $privMap[$user][$host] = array(); + } + $privMap[$user][$host][] = $row; } - $html_output .= PMA_getHtmlTableBodyForSpecificDbPrivs( - $db, $found, $row, $odd_row, $res - ); + + $html_output .= PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db); $html_output .= '' . '' . '' . "\n"; @@ -1879,115 +1887,6 @@ function PMA_getHtmlForSpecificDbPrivileges($db) return $html_output; } -/** - * Get HTML snippet for table body of specific database privileges - * - * @param boolean $db database - * @param boolean $found whether user found or not - * @param array $row array of rows from mysql, - * db table with list of privileges - * @param boolean $odd_row whether odd or not - * @param string $res ran sql query - * - * @return string $html_output - */ -function PMA_getHtmlTableBodyForSpecificDbPrivs($db, $found, $row, $odd_row, - $res -) { - $html_output = '' . "\n"; - if ($found) { - while (true) { - // prepare the current user - $current_privileges = array(); - $current_user = $row['User']; - $current_host = $row['Host']; - while ($row - && $current_user == $row['User'] - && $current_host == $row['Host'] - ) { - $current_privileges[] = $row; - $row = $GLOBALS['dbi']->fetchAssoc($res); - } - $html_output .= '' . "\n" - . ' 1) { - $html_output .= ' rowspan="' . count($current_privileges) . '"'; - } - $html_output .= '>' - . (empty($current_user) - ? '' . __('Any') . '' - : htmlspecialchars($current_user)) . "\n" - . '' . "\n"; - - $html_output .= ' 1) { - $html_output .= ' rowspan="' . count($current_privileges) . '"'; - } - $html_output .= '>' - . htmlspecialchars($current_host) . '' . "\n"; - for ($i = 0; $i < count($current_privileges); $i++) { - $current = $current_privileges[$i]; - $html_output .= '' . "\n" - . ' '; - if (! isset($current['Db']) || $current['Db'] == '*') { - $html_output .= __('global'); - } elseif ($current['Db'] == PMA_Util::escapeMysqlWildcards($db)) { - $html_output .= __('database-specific'); - } else { - $html_output .= __('wildcard'). ': ' - . '' . htmlspecialchars($current['Db']) . ''; - } - $html_output .= "\n" - . '' . "\n"; - - $html_output .='' . "\n" - . '' . "\n" - . '' - . join( - ',' . "\n" . ' ', - PMA_extractPrivInfo($current, true) - ) - . "\n" - . '' . "\n" - . '' . "\n"; - - $html_output .= '' . "\n" - . '' . ($current['Grant_priv'] == 'Y' ? __('Yes') : __('No')) - . "\n" - . '' . "\n" - . '' . "\n"; - $html_output .= PMA_getUserEditLink( - $current_user, $current_host, - (isset($current['Db']) && $current['Db'] != '*') - ? $current['Db'] : '' - ); - $html_output .= '' . "\n" - . ' ' . "\n"; - if (($i + 1) < count($current_privileges)) { - $html_output .= '' - . "\n"; - } - } - if (empty($row)) { - break; - } - $odd_row = ! $odd_row; - } - } else { - $html_output .= '' . "\n" - . '' . "\n" - . ' ' . __('No user found.') . "\n" - . '' . "\n" - . '' . "\n"; - } - $html_output .= '' . "\n"; - - return $html_output; -} - /** * Get the HTML for user form and check the privileges for a particular table. * @@ -1998,12 +1897,11 @@ function PMA_getHtmlTableBodyForSpecificDbPrivs($db, $found, $row, $odd_row, */ function PMA_getHtmlForSpecificTablePrivileges($db, $table) { - // check the privileges for a particular database. - $html_output = '
' - . '
'; + // check the privileges for a particular table. + $html_output = ''; + $html_output .= '
'; $html_output .= '' . PMA_Util::getIcon('b_usrcheck.png') - . ' ' . sprintf( __('Users having access to "%s"'), ''; - $html_output .= '' - . '' + $html_output .= '
'; + $html_output .= '' . '' . '' . '' @@ -2042,7 +1939,7 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) . "(" . " SELECT " . $list_of_privileges . ", `Db`" . " FROM `mysql`.`db`" - . " WHERE `Db` LIKE '" . PMA_Util::sqlAddSlashes($db) . "'" + . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" . " AND NOT (" . $list_of_compared_privileges. ")" . ")" . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC;"; @@ -2063,11 +1960,12 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) $sql_query = "SELECT `User`, `Host`, `Db`, `Table_name`, `Table_priv`" . " FROM `mysql`.`tables_priv`" - . " WHERE `Db` LIKE '" . PMA_Util::sqlAddSlashes($db) . "'" - . " AND `Table_name` LIKE '" . PMA_Util::sqlAddSlashes($table) . "'" + . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" + . " AND '" . PMA_Util::sqlAddSlashes($table) . "' LIKE `Table_name`" . " AND NOT (`Table_priv` = '' AND Column_priv = '')" . " ORDER BY `User` ASC, `Host` ASC, `Db` ASC, `Table_priv` ASC;"; $res = $GLOBALS['dbi']->query($sql_query); + while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { $user = $row['User']; $host = $row['Host']; @@ -2080,10 +1978,10 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) $privMap[$user][$host][] = $row; } - $html_output .= PMA_getHtmlTableBodyForSpecificTablePrivs($db, $table, $privMap); - $html_output .= '
' . __('User') . '' . __('Host') . '' . __('Type') . '
' - . '
' - . ''; + $html_output .= PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table); + $html_output .= ''; + $html_output .= '
'; + $html_output .= ''; // Offer to create a new user for the current database $html_output .= '
' @@ -2106,15 +2004,15 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) } /** - * Get HTML snippet for table body of specific table privileges + * Get HTML snippet for table body of specific database or table privileges * - * @param boolean $db database - * @param boolean $db table * @param boolean $privMap priviledge map + * @param boolean $db database + * @param boolean $table table * * @return string $html_output */ -function PMA_getHtmlTableBodyForSpecificTablePrivs($db, $table, $privMap) { +function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = null) { $html_output = ''; $odd_row = true; if (! empty($privMap)) { @@ -2189,7 +2087,7 @@ function PMA_getHtmlTableBodyForSpecificTablePrivs($db, $table, $privMap) { $html_output .= '' . join( ',', - PMA_extractPrivInfo($current, true) + PMA_extractPrivInfo($current, true, false) ) . ''; } @@ -2233,7 +2131,7 @@ function PMA_getHtmlTableBodyForSpecificTablePrivs($db, $table, $privMap) { } else { $html_output .= '' . '' - . ' ' . __('No user found.') + . __('No user found.') . '' . ''; } From 1f86a3496afad250ac6bc65d762db7e8ec72795f Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sat, 31 Aug 2013 14:07:05 +0530 Subject: [PATCH 06/88] Fix typo --- libraries/server_privileges.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index add910db87..5e3f400fc3 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -217,12 +217,12 @@ function PMA_getTableGrantsArray() $GLOBALS['strPrivDescAlter'] ), array( - 'Create view', + 'Create View', 'CREATE_VIEW', $GLOBALS['strPrivDescCreateView'] ), array( - 'Show viwew', + 'Show view', 'SHOW_VIEW', $GLOBALS['strPrivDescShowView'] ), From d9954b3d6ae83f232ebb9f276d64415a971e5ca9 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Mon, 2 Sep 2013 21:46:38 +0800 Subject: [PATCH 07/88] add UT for PMA_tbl_relation --- libraries/tbl_relation.lib.php | 4 +- test/libraries/PMA_tbl_relation_test.php | 266 ++++++++++++++++++++++- 2 files changed, 260 insertions(+), 10 deletions(-) diff --git a/libraries/tbl_relation.lib.php b/libraries/tbl_relation.lib.php index 6440aae568..cf69b0b046 100644 --- a/libraries/tbl_relation.lib.php +++ b/libraries/tbl_relation.lib.php @@ -193,8 +193,8 @@ function PMA_getHtmlForCommonForm($db, $table, $columns, $cfgRelation, * @param array $columns columns * @param array $cfgRelation configuration relation * @param string $tbl_storage_engine table storage engine - * @param array $existrel db, table, column - * @param array $existrel_foreign db, table, column + * @param array $existrel existed relations + * @param array $existrel_foreign existed relations for foreign keys * @param array $options_array options array * @param string $db current database * @param string $table current table diff --git a/test/libraries/PMA_tbl_relation_test.php b/test/libraries/PMA_tbl_relation_test.php index fe332fae42..1526f3b93e 100644 --- a/test/libraries/PMA_tbl_relation_test.php +++ b/test/libraries/PMA_tbl_relation_test.php @@ -11,6 +11,10 @@ */ require_once 'libraries/tbl_relation.lib.php'; require_once 'libraries/Util.class.php'; +require_once 'libraries/url_generating.lib.php'; +require_once 'libraries/database_interface.inc.php'; +require_once 'libraries/php-gettext/gettext.inc'; +require_once 'libraries/relation.lib.php'; /** * Tests for libraries/tbl_relation.lib.php @@ -19,6 +23,25 @@ require_once 'libraries/Util.class.php'; */ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase { + /** + * Configures environment + * + * @return void + */ + protected function setUp() + { + $GLOBALS['server'] = 0; + + $GLOBALS['pma'] = new DataBasePMAMock(); + $GLOBALS['pma']->databases = new DataBaseMock(); + + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['dbi'] = $dbi; + } + /** * Tests for PMA_generateRelationalDropdown() method. * @@ -72,12 +95,12 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase // test for selected value not found in values array and its escaping $this->assertContains( - '', PMA_generateRelationalDropdown('name', $values, 'valu<4') ); } - + /** * Tests for PMA_generateDropdown() method. * @@ -90,7 +113,7 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase $select_name = "select_name"; $choices = array("choice1", "choice2"); $selected_value = ""; - + $html_output = PMA_generateDropdown( $dropdown_question, $select_name, $choices, $selected_value ); @@ -115,7 +138,7 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase $html_output ); } - + /** * Tests for PMA_backquoteSplit() method. * @@ -131,7 +154,7 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase PMA_backquoteSplit($text) ); } - + /** * Tests for PMA_getSQLToCreateForeignKey() method. * @@ -149,15 +172,15 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase $sql = PMA_getSQLToCreateForeignKey( $table, $field, $foreignDb, $foreignTable, $foreignField ); - $sql_excepted = 'ALTER TABLE `PMA_table` ADD ' - . 'FOREIGN KEY (`PMA_field`) REFERENCES ' + $sql_excepted = 'ALTER TABLE `PMA_table` ADD ' + . 'FOREIGN KEY (`PMA_field`) REFERENCES ' . '`foreignDb`.`foreignTable`(`foreignField`);'; $this->assertEquals( $sql_excepted, $sql ); } - + /** * Tests for PMA_getSQLToDropForeignKey() method. * @@ -174,5 +197,232 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase PMA_getSQLToDropForeignKey($table, $fk) ); } + + /** + * Tests for PMA_getHtmlForCommonForm() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForCommonForm() + { + $db = "pma_db"; + $table = "pma_table"; + $columns = array( + array("Field" => "Field1") + ); + $cfgRelation = array( + 'displaywork' => true, + 'relwork' => true, + 'displaywork' => true, + ); + $tbl_storage_engine = "InnerDB"; + $existrel = array(); + $existrel_foreign = array(); + $options_array = array(); + + $save_row = array(); + foreach ($columns as $row) { + $save_row[] = $row; + } + + $html = PMA_getHtmlForCommonForm( + $db, $table, $columns, $cfgRelation, + $tbl_storage_engine, $existrel, $existrel_foreign, $options_array + ); + + //case 1: PMA_getHtmlForCommonFormHeader + $this->assertContains( + PMA_getHtmlForCommonFormHeader($db, $table), + $html + ); + + $this->assertContains( + PMA_URL_getHiddenInputs($db, $table), + $html + ); + + //case 2: PMA_getHtmlForCommonFormRows + $this->assertContains( + __('Relations'), + $html + ); + + $this->assertContains( + __('Column'), + $html + ); + + $this->assertContains( + __('Internal relation'), + $html + ); + + $this->assertContains( + __('Choose column to display:'), + $html + ); + + //case 3: PMA_getHtmlForCommonFormTableHeaders + $this->assertContains( + PMA_getHtmlForCommonFormTableHeaders($cfgRelation, $tbl_storage_engine), + $html + ); + + //case 4: PMA_getHtmlForRow + $row = PMA_getHtmlForRow( + $save_row, 0, true, $cfgRelation, $existrel, $db, + $tbl_storage_engine, $existrel_foreign, $options_array + ); + $this->assertContains( + $row, + $html + ); + + //case 5: PMA_getHtmlForDisplayFieldInfos + $this->assertContains( + PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row), + $html + ); + + //case 6: PMA_getHtmlForCommonFormFooter + $this->assertContains( + PMA_getHtmlForCommonFormFooter(), + $html + ); + } + + /** + * Tests for PMA_getHtmlForDisplayFieldInfos() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForDisplayFieldInfos() + { + $db = "pma_db"; + $table = "pma_table"; + $save_row = array( + array("Field" => "Field1"), + array("Field" => "Field2"), + ); + + $html = PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row); + + $this->assertContains( + __('Choose column to display:'), + $html + ); + $this->assertContains( + htmlspecialchars($save_row[0]['Field']), + $html + ); + $this->assertContains( + htmlspecialchars($save_row[1]['Field']), + $html + ); + } + + /** + * Tests for PMA_getQueryForDisplayUpdate() method. + * + * @return void + * @test + */ + public function testPMAGetQueryForDisplayUpdate() + { + $disp = true; + $display_field = ''; + $db = "pma_db"; + $table = "pma_table"; + $cfgRelation = array( + 'displaywork' => true, + 'relwork' => true, + 'displaywork' => true, + 'table_info' => 'table_info', + ); + + $GLOBALS['cfgRelation']['db'] = 'global_db'; + + //case 1: $disp == true && $display_field == '' + $query = PMA_getQueryForDisplayUpdate( + $disp, $display_field, $db, $table, $cfgRelation + ); + $query_expect = "DELETE FROM `global_db`.`table_info` " + . "WHERE db_name = 'pma_db' AND table_name = 'pma_table'"; + $this->assertEquals( + $query_expect, + $query + ); + + //case 2: $disp == true && $display_field == 'display_field' + $display_field == 'display_field'; + $query = PMA_getQueryForDisplayUpdate( + $disp, $display_field, $db, $table, $cfgRelation + ); + $query_expect = "DELETE FROM `global_db`.`table_info` " + . "WHERE db_name = 'pma_db' AND table_name = 'pma_table'"; + $this->assertEquals( + $query_expect, + $query + ); + + //case 3: $disp == false && $display_field == 'display_field' + $disp = false; + $display_field = 'display_field'; + $query = PMA_getQueryForDisplayUpdate( + $disp, $display_field, $db, $table, $cfgRelation + ); + $query_expect = "INSERT INTO `global_db`.`table_info`" + . "(db_name, table_name, display_field)" + . " VALUES('pma_db','pma_table','display_field')"; + $this->assertEquals( + $query_expect, + $query + ); + + //case 4: $disp == false && $display_field == '' + $disp = false; + $display_field = ''; + $query = PMA_getQueryForDisplayUpdate( + $disp, $display_field, $db, $table, $cfgRelation + ); + $query_expect = ''; + $this->assertEquals( + $query_expect, + $query + ); + } +} + +/** + * Mock class for DataBasePMAMock + * + * @package PhpMyAdmin-test + */ +Class DataBasePMAMock +{ + var $databases; +} + +/** + * Mock class for DataBaseMock + * + * @package PhpMyAdmin-test + */ +Class DataBaseMock +{ + /** + * mock function to return table is existed + * + * @param string $name table name + * + * @return bool + */ + function exists($name) + { + return true; + } } ?> + From 675dfba8336244aa97292a3439eaa0ca1aa89bde Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Mon, 2 Sep 2013 22:52:44 +0800 Subject: [PATCH 08/88] fix redefined error --- test/libraries/PMA_tbl_relation_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/libraries/PMA_tbl_relation_test.php b/test/libraries/PMA_tbl_relation_test.php index 1526f3b93e..82383ba426 100644 --- a/test/libraries/PMA_tbl_relation_test.php +++ b/test/libraries/PMA_tbl_relation_test.php @@ -32,8 +32,8 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase { $GLOBALS['server'] = 0; - $GLOBALS['pma'] = new DataBasePMAMock(); - $GLOBALS['pma']->databases = new DataBaseMock(); + $GLOBALS['pma'] = new DataBasePMAMockForTblRelation(); + $GLOBALS['pma']->databases = new DataBaseMockForTblRelation(); $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() @@ -400,7 +400,7 @@ class PMA_TblRelationTest extends PHPUnit_Framework_TestCase * * @package PhpMyAdmin-test */ -Class DataBasePMAMock +Class DataBasePMAMockForTblRelation { var $databases; } @@ -410,7 +410,7 @@ Class DataBasePMAMock * * @package PhpMyAdmin-test */ -Class DataBaseMock +Class DataBaseMockForTblRelation { /** * mock function to return table is existed From 574cf34d4fbade4d928154efe0192d149842d84f Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Tue, 3 Sep 2013 21:54:10 +0800 Subject: [PATCH 09/88] add Unit test case for DBIDrizzle --- test/classes/dbi/DBIDrizzle_test.php | 181 +++++++++++++++++++++++++-- 1 file changed, 173 insertions(+), 8 deletions(-) diff --git a/test/classes/dbi/DBIDrizzle_test.php b/test/classes/dbi/DBIDrizzle_test.php index 99cae9f7e3..060b2e3c98 100644 --- a/test/classes/dbi/DBIDrizzle_test.php +++ b/test/classes/dbi/DBIDrizzle_test.php @@ -15,10 +15,9 @@ * * @package PhpMyAdmin-test */ -class Drizzle -{ -} +define("DRIZZLE_CAPABILITIES_COMPRESS", 2); +define("DRIZZLE_CAPABILITIES_SSL", 4); /** * function to return drizzle_version @@ -38,6 +37,7 @@ require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Index.class.php'; require_once 'libraries/database_interface.inc.php'; require_once 'libraries/dbi/DBIDrizzle.class.php'; +require_once 'libraries/Theme.class.php'; /** * Tests for PMA_DBI_Drizzle class @@ -59,7 +59,30 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase * @return void */ protected function setUp() - { + { + $GLOBALS['cfg']['Server']['host'] = "localhost"; + $GLOBALS['cfg']['Server']['socket'] = "socket"; + $GLOBALS['cfg']['Server']['port'] = 4080; + $GLOBALS['cfg']['Server']['connect_type'] = "http"; + $GLOBALS['cfg']['PersistentConnections'] = false; + $GLOBALS['cfg']['Server']['compress'] = true; + $GLOBALS['cfg']['Server']['ssl'] = false; + $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; + $GLOBALS['cfg']['ActionLinksMode'] = "both"; + $GLOBALS['cfg']['DefaultTabDatabase'] = 'db_structure.php'; + $GLOBALS['pmaThemeImage'] = 'image'; + + //$_SESSION + $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); + $_SESSION['PMA_Theme'] = new PMA_Theme(); + + //Mock DBI, just for postConnect usage + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['dbi'] = $dbi; + $this->object = new PMA_DBI_Drizzle(); } @@ -88,7 +111,7 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase $this->assertEquals( false, $this->object->realMultiQuery(null, "select * from PMA") - ); + ); } /** @@ -105,7 +128,7 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase $this->assertEquals( false, $this->object->selectDb("PMA") - ); + ); } /** @@ -121,12 +144,12 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase $this->assertEquals( false, $this->object->moreResults() - ); + ); //PHP's 'mysql' extension does not support multi_queries $this->assertEquals( false, $this->object->nextResult() - ); + ); } /** @@ -174,4 +197,146 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase $this->object->storeResult() ); } + + /** + * Test for connect + * + * @return void + * + * @group medium + */ + public function testConnect() + { + $user = "PMA_user"; + $password = "pma_password"; + $is_controluser = false; + $server = null; + + //$server = null; + $link = $this->object->connect($user, $password); + $this->assertEquals( + "DrizzleCon_addUds", + $link->getType() + ); + + //$server['host'] = 'host' + $server['host'] = 'host'; + $link = $this->object->connect($user, $password); + $this->assertEquals( + "DrizzleCon_addUds", + $link->getType() + ); + + //selectDb + $dbname = "dbname"; + $this->assertEquals( + "selectDb" . $dbname, + $this->object->selectDb($dbname, $link) + ); + + //realQuery + $query = "query"; + $options = false; + $this->assertEquals( + "query" . $query, + $this->object->realQuery($query, $link, $options) + ); + } } + +class Drizzle +{ + /** + * Constructor + */ + public function __construct() + { + + } + + /** + * Creates a new connection using unix domain socket + * + * @param string $uds socket + * @param string $user username + * @param string $password password + * @param string $db database name + * @param integer $options connection options + * + * @return Mock_Con + */ + public function addUds($uds, $user, $password, $db, $options) + { + return new Mock_Con("DrizzleCon_addUds"); + } + + /** + * Creates a new database conection using TCP + * + * @param string $host Drizzle host + * @param integer $port Drizzle port + * @param string $user username + * @param string $password password + * @param string $db database name + * @param integer $options connection options + * + * @return Mock_Con + */ + public function addTcp($host, $port, $user, $password, $db, $options) + { + return new Mock_Con("DrizzleCon_addTcp"); + } + +} + +class Mock_Con +{ + var $type; + + /** + * Constructor + * + * @param string $type type + */ + public function __construct($type) + { + $this->type = $type; + } + + + /** + * Creates a new database conection using TCP + * + * @return Mock_Con + */ + public function getType() + { + return $this->type; + } + + /** + * selectDb + * + * @param string $dbname database name + * + * @return string + */ + public function selectDb($dbname) + { + return "selectDb" . $dbname; + } + + /** + * query + * + * @param string $query query string + * @param int $buffer_mode buffer mode + * + * @return string + */ + public function query($query, $buffer_mode) + { + return "query" . $query; + } +} + From 9a394408563709c35fdfaa7907dbf6a73acce029 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Tue, 3 Sep 2013 23:01:39 +0800 Subject: [PATCH 10/88] add more case for DBIDrizzle --- test/classes/dbi/DBIDrizzle_test.php | 100 ++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/test/classes/dbi/DBIDrizzle_test.php b/test/classes/dbi/DBIDrizzle_test.php index 060b2e3c98..570ab8a1c1 100644 --- a/test/classes/dbi/DBIDrizzle_test.php +++ b/test/classes/dbi/DBIDrizzle_test.php @@ -205,7 +205,7 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase * * @group medium */ - public function testConnect() + public function testDBIFunction() { $user = "PMA_user"; $password = "pma_password"; @@ -241,9 +241,58 @@ class PMA_DBI_Drizzle_Test extends PHPUnit_Framework_TestCase "query" . $query, $this->object->realQuery($query, $link, $options) ); + + //fetchArray + $result = $link; + $this->assertEquals( + "fetchRow " . PMA_Drizzle::FETCH_BOTH, + $this->object->fetchArray($result) + ); + + //fetchAssoc + $result = $link; + $this->assertEquals( + "fetchRow " . PMA_Drizzle::FETCH_ASSOC, + $this->object->fetchAssoc($result) + ); + + //fetchRow + $result = $link; + $this->assertEquals( + "fetchRow " . PMA_Drizzle::FETCH_NUM, + $this->object->fetchRow($result) + ); + + //dataSeek + $result = $link; + $offset = 10; + $this->assertEquals( + "seek" . $offset, + $this->object->dataSeek($result, 10) + ); + + //numRows + $result = $link; + $this->assertEquals( + "numRows", + $this->object->numRows($result) + ); + + //numFields + $result = $link; + $this->assertEquals( + "numColumns", + $this->object->numFields($result) + ); + } } +/** + * Mock class for Drizzle + * + * @package PhpMyAdmin-test + */ class Drizzle { /** @@ -289,6 +338,11 @@ class Drizzle } +/** + * Mock class for Mock_Connection + * + * @package PhpMyAdmin-test + */ class Mock_Con { var $type; @@ -338,5 +392,49 @@ class Mock_Con { return "query" . $query; } + + /** + * fetchRow + * + * @param string $mode fetch mode + * + * @return string + */ + public function fetchRow($mode) + { + return "fetchRow " . $mode; + } + + /** + * $offset + * + * @param int $offset offset + * + * @return string + */ + public function seek($offset) + { + return "seek" . $offset; + } + + /** + * numRows + * + * @return string + */ + public function numRows() + { + return "numRows"; + } + + /** + * numColumns + * + * @return string + */ + public function numColumns() + { + return "numColumns"; + } } From 7c96afbf1abc61b414409f7f617237cc354da26a Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Wed, 4 Sep 2013 07:07:05 +0530 Subject: [PATCH 11/88] Tests for changing icon based on link target --- .../navigation/PMA_Node_Table_test.php | 34 ++++++++++++++++++- .../classes/navigation/PMA_Node_View_test.php | 3 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/test/classes/navigation/PMA_Node_Table_test.php b/test/classes/navigation/PMA_Node_Table_test.php index 99a0866f46..587644eeda 100644 --- a/test/classes/navigation/PMA_Node_Table_test.php +++ b/test/classes/navigation/PMA_Node_Table_test.php @@ -19,7 +19,7 @@ class Node_Table_Test extends PHPUnit_Framework_TestCase { /** * SetUp for test cases - * + * * @return void */ public function setup() @@ -47,5 +47,37 @@ class Node_Table_Test extends PHPUnit_Framework_TestCase $parent->links['text'] ); } + + /** + * Tests whether the node icon is properly set based on the icon target. + * + * @param string $target target of the icon + * @param string $imageName name of the image that should be set + * + * @return void + * @dataProvider providerForTestIcon + */ + public function testIcon($target, $imageName) + { + $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = $target; + $node = PMA_NodeFactory::getInstance('Node_Table'); + $this->assertContains($imageName, $node->icon); + } + + /** + * Data provider for testIcon(). + * + * @return array data for testIcon() + */ + public function providerForTestIcon() + { + return array( + array('tbl_structure.php', 'b_props'), + array('tbl_select.php', 'b_search'), + array('tbl_change.php', 'b_insrow'), + array('tbl_sql.php', 'b_sql'), + array('sql.php', 'b_browse'), + ); + } } ?> diff --git a/test/classes/navigation/PMA_Node_View_test.php b/test/classes/navigation/PMA_Node_View_test.php index 293a388a35..b41fac0002 100644 --- a/test/classes/navigation/PMA_Node_View_test.php +++ b/test/classes/navigation/PMA_Node_View_test.php @@ -19,7 +19,7 @@ class Node_View_Test extends PHPUnit_Framework_TestCase { /** * SetUp for test cases - * + * * @return void */ public function setup() @@ -46,6 +46,7 @@ class Node_View_Test extends PHPUnit_Framework_TestCase 'sql.php', $parent->links['text'] ); + $this->assertContains('b_props', $node->icon); } } ?> From 71ab6de74c9ffb3906ca13e659bcab33faad0e32 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Wed, 4 Sep 2013 07:21:55 +0530 Subject: [PATCH 12/88] Tests for use of a text area when input of size $cfg['LimitChars'] is not enough --- test/libraries/PMA_insert_edit_test.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/libraries/PMA_insert_edit_test.php b/test/libraries/PMA_insert_edit_test.php index 042666d8a3..c733dc8ea0 100644 --- a/test/libraries/PMA_insert_edit_test.php +++ b/test/libraries/PMA_insert_edit_test.php @@ -1199,6 +1199,28 @@ class PMA_InsertEditTest extends PHPUnit_Framework_TestCase ); // case 5 + $GLOBALS['cfg']['ProtectBinary'] = false; + $GLOBALS['cfg']['LongtextDoubleTextarea'] = true; + $GLOBALS['cfg']['LimitChars'] = 100; + $column['is_blob'] = false; + $column['len'] = 255; + $column['is_char'] = false; + $GLOBALS['cfg']['TextareaRows'] = 20; + $GLOBALS['cfg']['TextareaCols'] = 10; + + $result = PMA_getBinaryAndBlobColumn( + $column, '1223', null, 20, 'a', 'b', 'c', 2, 1, 1, '/', null, + 'foo', true + ); + + $this->assertEquals( + "\na\n" + . '', + $result + ); + + // case 6 $column['is_blob'] = false; $column['len'] = 10; $GLOBALS['cfg']['LimitChars'] = 40; From 12fc6ae454b287626343a4b8198aa61b1988354d Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Wed, 4 Sep 2013 07:28:10 +0530 Subject: [PATCH 13/88] Test classes added for navigation panel highlight feature --- test/classes/navigation/PMA_Node_Database_test.php | 5 +++-- test/classes/navigation/PMA_Node_Table_Container_test.php | 3 ++- test/classes/navigation/PMA_Node_Table_test.php | 1 + test/classes/navigation/PMA_Node_View_Container_test.php | 3 ++- test/classes/navigation/PMA_Node_View_test.php | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/classes/navigation/PMA_Node_Database_test.php b/test/classes/navigation/PMA_Node_Database_test.php index b21cb1da3c..747d6e4f1b 100644 --- a/test/classes/navigation/PMA_Node_Database_test.php +++ b/test/classes/navigation/PMA_Node_Database_test.php @@ -19,7 +19,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase { /** * SetUp for test cases - * + * * @return void */ public function setup() @@ -31,7 +31,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase /** * Test for __construct - * + * * @return void */ public function testConstructor() @@ -45,6 +45,7 @@ class Node_Database_Test extends PHPUnit_Framework_TestCase 'db_structure.php', $parent->links['text'] ); + $this->assertContains('database', $parent->classes); } } ?> diff --git a/test/classes/navigation/PMA_Node_Table_Container_test.php b/test/classes/navigation/PMA_Node_Table_Container_test.php index 9a091e2767..2eee4c743c 100644 --- a/test/classes/navigation/PMA_Node_Table_Container_test.php +++ b/test/classes/navigation/PMA_Node_Table_Container_test.php @@ -19,7 +19,7 @@ class Node_Table_Container_Test extends PHPUnit_Framework_TestCase { /** * SetUp for test cases - * + * * @return void */ public function setup() @@ -47,6 +47,7 @@ class Node_Table_Container_Test extends PHPUnit_Framework_TestCase $parent->links['text'] ); $this->assertEquals('tables', $parent->real_name); + $this->assertContains('tableContainer', $parent->classes); } } ?> diff --git a/test/classes/navigation/PMA_Node_Table_test.php b/test/classes/navigation/PMA_Node_Table_test.php index 587644eeda..ddde44ba4f 100644 --- a/test/classes/navigation/PMA_Node_Table_test.php +++ b/test/classes/navigation/PMA_Node_Table_test.php @@ -46,6 +46,7 @@ class Node_Table_Test extends PHPUnit_Framework_TestCase 'sql.php', $parent->links['text'] ); + $this->assertContains('table', $parent->classes); } /** diff --git a/test/classes/navigation/PMA_Node_View_Container_test.php b/test/classes/navigation/PMA_Node_View_Container_test.php index 1ce0e79dac..2c7f515836 100644 --- a/test/classes/navigation/PMA_Node_View_Container_test.php +++ b/test/classes/navigation/PMA_Node_View_Container_test.php @@ -19,7 +19,7 @@ class Node_View_Container_Test extends PHPUnit_Framework_TestCase { /** * SetUp for test cases - * + * * @return void */ public function setup() @@ -47,6 +47,7 @@ class Node_View_Container_Test extends PHPUnit_Framework_TestCase $parent->links['text'] ); $this->assertEquals('views', $parent->real_name); + $this->assertContains('viewContainer', $parent->classes); } } ?> diff --git a/test/classes/navigation/PMA_Node_View_test.php b/test/classes/navigation/PMA_Node_View_test.php index b41fac0002..3b3eb53545 100644 --- a/test/classes/navigation/PMA_Node_View_test.php +++ b/test/classes/navigation/PMA_Node_View_test.php @@ -47,6 +47,7 @@ class Node_View_Test extends PHPUnit_Framework_TestCase $parent->links['text'] ); $this->assertContains('b_props', $node->icon); + $this->assertContains('view', $parent->classes); } } ?> From 252d067fc1e734e52584ff6f4c2380fb477ded6c Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 4 Sep 2013 07:52:07 -0400 Subject: [PATCH 14/88] Fix codestyle --- db_datadict.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db_datadict.php b/db_datadict.php index 6a17a57af8..f08a5c4779 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -207,10 +207,11 @@ foreach ($tables as $table) { } $column_name = $row['Field']; + $tmp_column = $analyzed_sql[0]['create_table_fields'][$column_name]; if (PMA_MYSQL_INT_VERSION < 50025 - && ! empty($analyzed_sql[0]['create_table_fields'][$column_name]['type']) - && $analyzed_sql[0]['create_table_fields'][$column_name]['type'] == 'TIMESTAMP' - && $analyzed_sql[0]['create_table_fields'][$column_name]['timestamp_not_null'] + && ! empty($tmp_column['type']) + && $tmp_column['type'] == 'TIMESTAMP' + && $tmp_column['timestamp_not_null'] ) { // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as // having the NULL attribute, but SHOW CREATE TABLE says the From 2593087a1540cddbc4b5d8f8e18a92a93a0b773f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Nowi=C5=84ski?= Date: Tue, 3 Sep 2013 23:11:14 +0200 Subject: [PATCH 15/88] Translated using Weblate (Polish) Currently translated at 92.9% (2526 of 2720) --- po/pl.po | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/po/pl.po b/po/pl.po index aec2c82e5d..6194bdcf6e 100644 --- a/po/pl.po +++ b/po/pl.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-03 19:11+0200\n" +"PO-Revision-Date: 2013-09-03 23:11+0200\n" "Last-Translator: Tomasz Nowiński \n" "Language-Team: Polish \n" "Language: pl\n" @@ -1755,7 +1755,7 @@ msgstr "Edytuj" #: js/messages.php:273 msgid "No rows selected" -msgstr "Nie żadnych wybrano rekordów" +msgstr "Nie wybrano żadnego rekordu" #: js/messages.php:274 libraries/DisplayResults.class.php:4983 #: libraries/structure.lib.php:1374 libraries/structure.lib.php:2062 @@ -12165,7 +12165,7 @@ msgstr "Kolumny przeniesiono pomyślnie." #: libraries/structure.lib.php:2571 #, php-format msgid "The column name '%s' is a MySQL reserved keyword." -msgstr "" +msgstr "Nazwa kolumny '%s' jest słowem kluczowym MySQL." #: libraries/tbl_columns_definition_form.lib.php:72 #, fuzzy @@ -13173,10 +13173,9 @@ msgid "Choose column to display:" msgstr "Wybierz kolumny do wyświetlenia" #: tbl_structure.php:111 -#, fuzzy #| msgid "No rows selected" msgid "No column selected." -msgstr "Nie żadnych wybrano rekordów" +msgstr "Nie wybrano żadnej kolumny." #: tbl_tracking.php:136 #, php-format From 7bc96697a1360649b7c5380b41d19daf5fd18dec Mon Sep 17 00:00:00 2001 From: xmujay Date: Wed, 4 Sep 2013 21:38:46 +0800 Subject: [PATCH 16/88] add UT for PMA_server_binlog and PMA_server_database --- test/libraries/PMA_server_binlog_test.php | 62 ++++++++++++++++++++ test/libraries/PMA_server_databases_test.php | 38 ++++++++++++ 2 files changed, 100 insertions(+) diff --git a/test/libraries/PMA_server_binlog_test.php b/test/libraries/PMA_server_binlog_test.php index 33d6739dd8..66d6304138 100644 --- a/test/libraries/PMA_server_binlog_test.php +++ b/test/libraries/PMA_server_binlog_test.php @@ -19,6 +19,7 @@ require_once 'libraries/Message.class.php'; require_once 'libraries/sanitizing.lib.php'; require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/js_escape.lib.php'; +require_once 'libraries/database_interface.inc.php'; /** * PMA_ServerBinlog_Test class @@ -202,4 +203,65 @@ class PMA_ServerBinlog_Test extends PHPUnit_Framework_TestCase $html ); } + + /** + * Test for PMA_getAllLogItemInfo + * + * @return void + */ + public function testPMAGetAllLogItemInfo() + { + //Mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fetchAssoc = array( + 'Info' => 'Info', + 'Log_name' => 'Log_name', + 'Pos' => 'Pos', + 'Event_type' => 'Event_type', + 'Server_id' => 'Server_id', + 'Orig_log_pos' => 'Orig_log_pos', + 'End_log_pos' => 'End_log_pos', + ); + $dbi->expects($this->at(0))->method('fetchAssoc') + ->will($this->returnValue($fetchAssoc)); + + $dbi->expects($this->at(1))->method('fetchAssoc') + ->will($this->returnValue(false)); + + $GLOBALS['dbi'] = $dbi; + $GLOBALS['cfg']['LimitChars'] = 2; + + $result = array(); + $dontlimitchars = ";"; + + $html = PMA_getAllLogItemInfo($result, $dontlimitchars); + $value = $fetchAssoc; + $this->assertContains( + $value['Log_name'], + $html + ); + $this->assertContains( + $value['Pos'], + $html + ); + $this->assertContains( + $value['Event_type'], + $html + ); + $this->assertContains( + $value['Server_id'], + $html + ); + $this->assertContains( + $value['Orig_log_pos'], + $html + ); + $this->assertContains( + htmlspecialchars($value['Info']), + $html + ); + } } diff --git a/test/libraries/PMA_server_databases_test.php b/test/libraries/PMA_server_databases_test.php index c65754c751..474cf1e8d5 100644 --- a/test/libraries/PMA_server_databases_test.php +++ b/test/libraries/PMA_server_databases_test.php @@ -245,4 +245,42 @@ class PMA_ServerDatabases_Test extends PHPUnit_Framework_TestCase $sort_order ); } + + /** + * Test for PMA_getHtmlForColumnOrder + * + * @return void + */ + public function testPMAGetHtmlForColumnOrder() + { + //Mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['dbi'] = $dbi; + + $column_order = array( + "first_database" => array( + 'format' => 'byte', + 'footer' => '10333', + ) + ); + $first_database = array( + "first_database" => "db1" + ); + $html = PMA_getHtmlForColumnOrder($column_order, $first_database); + $stat = $column_order["first_database" ]; + list($value, $unit) + = PMA_Util::formatByteDown($stat['footer'], 3, 1); + $this->assertContains( + $value, + $html + ); + $this->assertContains( + $unit, + $html + ); + + } } From 9c9de0caa10b9dee082b1cf8a4f1b5f66bf923b1 Mon Sep 17 00:00:00 2001 From: Mauricio Bastos Date: Wed, 4 Sep 2013 22:22:18 +0200 Subject: [PATCH 17/88] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (2719 of 2720) --- po/pt_BR.po | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index a222d9868b..6c873d2ac6 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-08-26 03:51+0200\n" +"PO-Revision-Date: 2013-09-04 22:22+0200\n" "Last-Translator: Mauricio Bastos \n" "Language-Team: Portuguese (Brazil) " "\n" @@ -10388,10 +10388,9 @@ msgid "Table level tabs" msgstr "Guias de Tabelas" #: libraries/server_privileges.lib.php:3663 -#, fuzzy #| msgid "Views" msgid "View users" -msgstr "Views" +msgstr "Ver usuários" #: libraries/server_privileges.lib.php:3700 #: libraries/server_privileges.lib.php:3761 @@ -10415,22 +10414,19 @@ msgid "Group name:" msgstr "Nome do Grupo:" #: libraries/server_privileges.lib.php:3819 -#, fuzzy #| msgid "Server version" msgid "Server-level tabs" -msgstr "Versão do servidor" +msgstr "Guias do Servidor" #: libraries/server_privileges.lib.php:3822 -#, fuzzy #| msgid "Database server" msgid "Database-level tabs" -msgstr "Servidor de banco de dados" +msgstr "Guias do Banco de Dados" #: libraries/server_privileges.lib.php:3825 -#, fuzzy #| msgid "Table comments" msgid "Table-level tabs" -msgstr "Comentários da tabela" +msgstr "Guias de Tabelas" #: libraries/server_privileges.lib.php:3936 msgid "The selected user was not found in the privilege table." From e641aa4dc071c77965d4ece15f4fd2fe046940f5 Mon Sep 17 00:00:00 2001 From: Rodrigo Souza Date: Wed, 4 Sep 2013 22:24:14 +0200 Subject: [PATCH 18/88] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (2720 of 2720) --- po/pt_BR.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index 6c873d2ac6..9f2507eedd 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-04 22:22+0200\n" -"Last-Translator: Mauricio Bastos \n" +"PO-Revision-Date: 2013-09-04 22:24+0200\n" +"Last-Translator: Rodrigo Souza \n" "Language-Team: Portuguese (Brazil) " "\n" "Language: pt_BR\n" @@ -12618,7 +12618,7 @@ msgstr "" "disponíveis neste sistema." #: setup/lib/index.lib.php:226 -#, fuzzy, php-format +#, php-format #| msgid "" #| "%sLogin cookie validity%s greater than 1440 seconds may cause random " #| "session invalidation if %ssession.gc_maxlifetime%s is lower than its " @@ -12627,9 +12627,9 @@ msgid "" "%sLogin cookie validity%s greater than %ssession.gc_maxlifetime%s may cause " "random session invalidation (currently session.gc_maxlifetime is %d)." msgstr "" -"A %svalidação dos cookies de login%s com mais de 1440 segundos pode causar " -"invalidação aleatória de sessão caso a %ssession.gc_maxlifetime%s seja menor " -"que seu valor (atualmente %d)." +"A %svalidação dos cookies de login%s com mais de %ssession.gc_maxlifetime%s " +"pode causar invalidação aleatória de sessão (atualmente a " +"session.gc_maslifetime é %d)." #: setup/lib/index.lib.php:228 #, php-format From 6693a9ebb3faddacc36b4311dacea76fe8443883 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Thu, 5 Sep 2013 07:24:50 +0530 Subject: [PATCH 19/88] Proceed only if the database is found --- js/navigation.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/js/navigation.js b/js/navigation.js index 6d26c5e52e..4806f43730 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -313,17 +313,19 @@ function PMA_showCurrentNavigation() var $dbItem = highlightLoadedItem( $('#pma_navigation_tree > div'), db, 'database', false, false ); - // open the table in the tree and select it - var $expander = $dbItem.children('div:first').children('a.expander'); - // if not loaded or loaded but collapsed - if (! $expander.hasClass('loaded') - || $expander.find('img').is('.ic_b_plus') - ) { - expandTreeNode($expander, function() { + if ($dbItem) { + // open the table in the tree and select it + var $expander = $dbItem.children('div:first').children('a.expander'); + // if not loaded or loaded but collapsed + if (! $expander.hasClass('loaded') + || $expander.find('img').is('.ic_b_plus') + ) { + expandTreeNode($expander, function() { + loadAndHighlightTableOrView($dbItem, table); + }); + } else { loadAndHighlightTableOrView($dbItem, table); - }); - } else { - loadAndHighlightTableOrView($dbItem, table); + } } } else if (db) { // if we are at the database level // open in the tree and select the database From 869cd62141a40b70143f1b2761c1be1026da0592 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Thu, 5 Sep 2013 07:35:19 +0530 Subject: [PATCH 20/88] Fix typing mistake --- test/classes/navigation/PMA_Node_View_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/navigation/PMA_Node_View_test.php b/test/classes/navigation/PMA_Node_View_test.php index 3b3eb53545..aa4a7210b9 100644 --- a/test/classes/navigation/PMA_Node_View_test.php +++ b/test/classes/navigation/PMA_Node_View_test.php @@ -46,7 +46,7 @@ class Node_View_Test extends PHPUnit_Framework_TestCase 'sql.php', $parent->links['text'] ); - $this->assertContains('b_props', $node->icon); + $this->assertContains('b_props', $parent->icon); $this->assertContains('view', $parent->classes); } } From c1fbdc446ced1bfcea5e4d374f1d6668af335973 Mon Sep 17 00:00:00 2001 From: xmujay Date: Thu, 5 Sep 2013 10:05:29 +0800 Subject: [PATCH 21/88] UTs for PMA_tbl_printview --- test/libraries/PMA_tbl_printview_test.php | 403 ++++++++++++++++++++++ 1 file changed, 403 insertions(+) create mode 100644 test/libraries/PMA_tbl_printview_test.php diff --git a/test/libraries/PMA_tbl_printview_test.php b/test/libraries/PMA_tbl_printview_test.php new file mode 100644 index 0000000000..c47d136342 --- /dev/null +++ b/test/libraries/PMA_tbl_printview_test.php @@ -0,0 +1,403 @@ +getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['dbi'] = $dbi; + } + + /** + * Tests for PMA_getHtmlForTablesInfo() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForTablesInfo() + { + $the_tables = array("PMA_table1", "PMA_table2"); + + $html = PMA_getHtmlForTablesInfo($the_tables); + + $this->assertContains( + __('Showing tables:'), + $html + ); + $this->assertContains( + "`PMA_table1`, `PMA_table2`", + $html + ); + } + + /** + * Tests for PMA_getHtmlForPrintViewFooter() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForPrintViewFooter() + { + $html = PMA_getHtmlForPrintViewFooter(); + + $this->assertContains( + '', + $html + ); + $this->assertContains( + "PMA_disable_floating_menubar", + $html + ); + } + + /** + * Tests for PMA_getHtmlForRowStatistics() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForRowStatistics() + { + $showtable = array( + 'Row_format' => "Fixed", + 'Rows' => 10, + 'Avg_row_length' => 123, + 'Data_length' => 345, + 'Auto_increment' => 1234, + 'Create_time' => "today", + 'Update_time' => "time2", + 'Check_time' => "yesterday", + ); + $cell_align_left = "cell_align_left"; + $avg_size = 12; + $avg_unit = 45; + $mergetable = false; + + $html = PMA_getHtmlForRowStatistics( + $showtable, $cell_align_left, $avg_size, $avg_unit, $mergetable + ); + + $this->assertContains( + __('Row Statistics:'), + $html + ); + + //validation 1 : Row_format + $this->assertContains( + __('Format'), + $html + ); + $this->assertContains( + $cell_align_left, + $html + ); + //$showtable['Row_format'] == 'Fixed' + $this->assertContains( + __('static'), + $html + ); + + //validation 2 : Avg_row_length + $length = PMA_Util::formatNumber( + $showtable['Avg_row_length'], 0 + ); + $this->assertContains( + $length, + $html + ); + $this->assertContains( + __('Row size'), + $html + ); + $this->assertContains( + $avg_size . ' ' . $avg_unit, + $html + ); + + //validation 3 : Auto_increment + $average = PMA_Util::formatNumber( + $showtable['Auto_increment'], 0 + ); + $this->assertContains( + $average, + $html + ); + $this->assertContains( + __('Next autoindex'), + $html + ); + + //validation 4 : Create_time + $time = PMA_Util::localisedDate( + strtotime($showtable['Create_time']) + ); + $this->assertContains( + __('Creation'), + $html + ); + $this->assertContains( + $time, + $html + ); + + //validation 5 : Update_time + $time = PMA_Util::localisedDate( + strtotime($showtable['Update_time']) + ); + $this->assertContains( + __('Last update'), + $html + ); + $this->assertContains( + $time, + $html + ); + + //validation 6 : Check_time + $time = PMA_Util::localisedDate( + strtotime($showtable['Check_time']) + ); + $this->assertContains( + __('Last check'), + $html + ); + $this->assertContains( + $time, + $html + ); + } + + /** + * Tests for PMA_getHtmlForSpaceUsage() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForSpaceUsage() + { + $data_size = '10'; + $data_unit = '11'; + $index_size = '12'; + $index_unit = '13'; + $free_size = '14'; + $free_unit = '15'; + $effect_size = '16'; + $effect_unit = '17'; + $tot_size = '18'; + $tot_unit = '19'; + $mergetable = false; + + $html = PMA_getHtmlForSpaceUsage( + $data_size, $data_unit, $index_size, $index_unit, + $free_size, $free_unit, $effect_size, $effect_unit, + $tot_size, $tot_unit, $mergetable + ); + + //validation 1 : title + $this->assertContains( + __('Space usage:'), + $html + ); + + //validation 2 : $data_size & $data_unit + $this->assertContains( + $data_size, + $html + ); + $this->assertContains( + $data_unit, + $html + ); + + //validation 3 : $index_size & $index_unit + $this->assertContains( + $index_size, + $html + ); + $this->assertContains( + $index_unit, + $html + ); + + //validation 4 : Overhead + $this->assertContains( + __('Overhead'), + $html + ); + $this->assertContains( + $free_size, + $html + ); + $this->assertContains( + $free_unit, + $html + ); + + //validation 5 : Effective + $this->assertContains( + __('Effective'), + $html + ); + $this->assertContains( + $effect_size, + $html + ); + $this->assertContains( + $effect_unit, + $html + ); + + //validation 6 : $tot_size & $tot_unit + $this->assertContains( + $tot_size, + $html + ); + $this->assertContains( + $tot_unit, + $html + ); + + } + + /** + * Tests for PMA_getHtmlForSpaceUsageAndRowStatistics() method. + * + * @return void + * @test + */ + public function testPMAGetHtmlForSpaceUsageAndRowStatistics() + { + $showtable = array( + 'Row_format' => "Fixed", + 'Rows' => 10, + 'Avg_row_length' => 123, + 'Data_length' => 345, + 'Auto_increment' => 1234, + 'Create_time' => "today", + 'Update_time' => "time2", + 'Check_time' => "yesterday", + 'Data_length' => 10, + 'Index_length' => 12334, + 'Data_length' => 4567, + 'Data_free' => 3456, + 'Check_time' => 1234, + ); + $db = "pma_db"; + $table = "pma_table"; + $cell_align_left = "cell_align_left"; + + $html = PMA_getHtmlForSpaceUsageAndRowStatistics( + $showtable, $db, $table, $cell_align_left + ); + + //validation 1 : $data_size, $data_unit + list($data_size, $data_unit) = PMA_Util::formatByteDown( + $showtable['Data_length'] + ); + $this->assertContains( + $data_size, + $html + ); + $this->assertContains( + $data_unit, + $html + ); + + //validation 2 : $data_size, $data_unit + list($index_size, $index_unit) + = PMA_Util::formatByteDown( + $showtable['Index_length'] + ); + $this->assertContains( + $data_size, + $html + ); + $this->assertContains( + $data_unit, + $html + ); + + //validation 3 : $free_size, $free_unit + list($free_size, $free_unit) + = PMA_Util::formatByteDown( + $showtable['Data_free'] + ); + $this->assertContains( + $free_size, + $html + ); + $this->assertContains( + $free_unit, + $html + ); + + //validation 4 : $effect_size, $effect_unit + list($effect_size, $effect_unit) + = PMA_Util::formatByteDown( + $showtable['Data_length'] + $showtable['Index_length'] + - $showtable['Data_free'] + ); + $this->assertContains( + $effect_size, + $html + ); + $this->assertContains( + $effect_unit, + $html + ); + + //validation 5 : $effect_size, $effect_unit + list($tot_size, $tot_unit) = PMA_Util::formatByteDown( + $showtable['Data_length'] + $showtable['Index_length'] + ); + $this->assertContains( + $tot_size, + $html + ); + $this->assertContains( + $tot_unit, + $html + ); + } +} + +?> + From 059d2e2d10d68cfbe742ffe2fce262f15f2cc04b Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Thu, 5 Sep 2013 07:58:12 +0530 Subject: [PATCH 22/88] Rights tab should only be accessible to super users --- libraries/Menu.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 87ebca45d3..4c4ee18ebf 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -534,8 +534,8 @@ class PMA_Menu basename($GLOBALS['PMA_PHP_SELF']), array('server_privileges.php', 'server_user_groups.php') ); + $tabs['rights']['args']['viewing_mode'] = 'server'; } - $tabs['rights']['args']['viewing_mode'] = 'server'; $tabs['export']['icon'] = 'b_export.png'; $tabs['export']['link'] = 'server_export.php'; From ac47f1235762b0a98f5932e0705dd0954f47a2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Nowi=C5=84ski?= Date: Tue, 3 Sep 2013 23:11:15 +0200 Subject: [PATCH 23/88] Translated using Weblate (Polish) Currently translated at 99.2% (2588 of 2609) --- po/pl.po | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/po/pl.po b/po/pl.po index 6c279f6100..3a477dade9 100644 --- a/po/pl.po +++ b/po/pl.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.6-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-29 15:07+0200\n" -"PO-Revision-Date: 2013-04-10 00:41+0200\n" -"Last-Translator: Jakub S \n" +"PO-Revision-Date: 2013-09-03 23:11+0200\n" +"Last-Translator: Tomasz Nowiński \n" "Language-Team: Polish \n" "Language: pl\n" "MIME-Version: 1.0\n" @@ -13,7 +13,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 1.5-dev\n" +"X-Generator: Weblate 1.7-dev\n" #: browse_foreigners.php:51 browse_foreigners.php:75 js/messages.php:344 #: libraries/DisplayResults.class.php:813 @@ -1723,7 +1723,7 @@ msgstr "Pokaż okno zapytań" #: js/messages.php:274 tbl_row_action.php:21 msgid "No rows selected" -msgstr "Nie żadnych wybrano rekordów" +msgstr "Nie wybrano żadnego rekordu" #: js/messages.php:275 libraries/DisplayResults.class.php:5052 #: libraries/structure.lib.php:1378 libraries/structure.lib.php:2056 @@ -7483,9 +7483,9 @@ msgstr "Przeładuj ramki nawigacji" #, php-format msgid "%s other result found" msgid_plural "%s other results found" -msgstr[0] "%s zanleziono inny wynik" -msgstr[1] "%s zanleziono innych wyników" -msgstr[2] "%s zanleziono inne wyniki" +msgstr[0] "Znaleziono %s inny wynik" +msgstr[1] "Znaleziono %s inne wyniki" +msgstr[2] "Znaleziono %s innych wyników" #: libraries/navigation/NavigationTree.class.php:1043 msgid "filter databases by name" @@ -12353,15 +12353,14 @@ msgid "No index defined! Create one below" msgstr "Brak zdefiniowanego indeksu!" #: tbl_structure.php:125 -#, fuzzy #| msgid "No rows selected" msgid "No column selected." -msgstr "Nie żadnych wybrano rekordów" +msgstr "Nie wybrano żadnej kolumny." #: tbl_structure.php:149 #, php-format msgid "The column name '%s' is a MySQL reserved keyword." -msgstr "" +msgstr "Nazwa kolumny '%s' jest słowem kluczowym MySQL." #: tbl_tracking.php:135 #, php-format From 2b979badd25fd12853f7d004255cd923f64881f0 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 5 Sep 2013 07:41:39 -0400 Subject: [PATCH 24/88] This new code should be excluded from running under the test suite --- export.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/export.php b/export.php index 944b383002..a856fd53f3 100644 --- a/export.php +++ b/export.php @@ -6,18 +6,17 @@ * @package PhpMyAdmin */ -/** - * If we are sending the export file (as opposed to just displaying it - * as text), we have to bypass the usual PMA_Response mechanism - */ -if ($_POST['output_format'] == 'sendit') { - define('PMA_BYPASS_GET_INSTANCE', 1); -} - /** * Get the variables sent or posted to this script and a core script */ if (!defined('TESTSUITE')) { + /** + * If we are sending the export file (as opposed to just displaying it + * as text), we have to bypass the usual PMA_Response mechanism + */ + if ($_POST['output_format'] == 'sendit') { + define('PMA_BYPASS_GET_INSTANCE', 1); + } require_once 'libraries/common.inc.php'; require_once 'libraries/zip.lib.php'; require_once 'libraries/plugin_interface.lib.php'; From 607a0393d8952ef50c2694594a56ee933cbbf3b2 Mon Sep 17 00:00:00 2001 From: xmujay Date: Thu, 5 Sep 2013 20:32:07 +0800 Subject: [PATCH 25/88] UTs for PMA_server_privileges --- test/libraries/PMA_server_privileges_test.php | 162 +++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/test/libraries/PMA_server_privileges_test.php b/test/libraries/PMA_server_privileges_test.php index 0e27d21de4..911594618f 100644 --- a/test/libraries/PMA_server_privileges_test.php +++ b/test/libraries/PMA_server_privileges_test.php @@ -22,7 +22,7 @@ require_once 'libraries/Message.class.php'; require_once 'libraries/Response.class.php'; require_once 'libraries/relation.lib.php'; require_once 'libraries/server_privileges.lib.php'; - +define("PMA_USR_BROWSER_AGENT", 1); /** * PMA_ServerPrivileges_Test class * @@ -57,12 +57,22 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase $GLOBALS['cfg']['Server']['pmadb'] = 'pmadb'; $GLOBALS['cfg']['Server']['usergroups'] = 'usergroups'; $GLOBALS['cfg']['Server']['users'] = 'users'; + $GLOBALS['cfg']['ActionLinksMode'] = "both"; + $GLOBALS['cfg']['DefaultTabDatabase'] = 'db_structure.php'; + $GLOBALS['cfg']['QueryWindowHeight'] = 100; + $GLOBALS['cfg']['QueryWindowWidth'] = 100; + $GLOBALS['cfg']['PmaAbsoluteUri'] = "PmaAbsoluteUri"; + $GLOBALS['cfg']['DefaultTabTable'] = "db_structure.php"; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = "db_structure.php"; + $GLOBALS['cfg']['Confirm'] = "Confirm"; $GLOBALS['table'] = "table"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['server'] = 1; $GLOBALS['username'] = "pma_username"; + $GLOBALS['collation_connection'] = "collation_connection"; + $GLOBALS['text_dir'] = "text_dir"; //$_POST $_POST['pred_password'] = 'none'; @@ -70,6 +80,12 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); + $pmaconfig = $this->getMockBuilder('PMA_Config') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['PMA_Config'] = $pmaconfig; + //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() @@ -294,6 +310,38 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase } + /** + * Test for PMA_getHtmlForUserGroupDialog + * + * @return void + */ + public function testPMAGetHtmlForUserGroupDialog() + { + $username = "pma_username"; + $is_menuswork = true; + $_REQUEST['edit_user_group_dialog'] = "edit_user_group_dialog"; + $GLOBALS['is_ajax_request'] = false; + + //PMA_getHtmlForUserGroupDialog + $html = PMA_getHtmlForUserGroupDialog($username, $is_menuswork); + $this->assertContains( + '
$username); + $html_output = PMA_URL_getHiddenInputs($params); + $this->assertContains( + $html_output, + $html + ); + //__('User group') + $this->assertContains( + __('User group'), + $html + ); + } + /** * Test for PMA_getHtmlToChooseUserGroup * @@ -323,6 +371,118 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase ); } + /** + * Test for PMA_getHtmlForDisplayResourceLimits + * + * @return void + */ + public function testPMAGetHtmlForDisplayResourceLimits() + { + $row = array( + 'max_questions' => 'max_questions', + 'max_updates' => 'max_updates', + 'max_connections' => 'max_connections', + 'max_user_connections' => 'max_user_connections', + ); + + //PMA_getHtmlForDisplayResourceLimits + $html = PMA_getHtmlForDisplayResourceLimits($row); + $this->assertContains( + '' . __('Resource limits') . '', + $html + ); + $this->assertContains( + __('Note: Setting these options to 0 (zero) removes the limit.'), + $html + ); + $this->assertContains( + 'MAX QUERIES PER HOUR', + $html + ); + $this->assertContains( + $row['max_connections'], + $html + ); + $this->assertContains( + $row['max_updates'], + $html + ); + $this->assertContains( + $row['max_connections'], + $html + ); + $this->assertContains( + $row['max_user_connections'], + $html + ); + $this->assertContains( + __('Limits the number of simultaneous connections the user may have.'), + $html + ); + $this->assertContains( + __('Limits the number of simultaneous connections the user may have.'), + $html + ); + } + + /** + * Test for PMA_getSqlQueryForDisplayPrivTable + * + * @return void + */ + public function testPMAGetSqlQueryForDisplayPrivTable() + { + $username = "pma_username"; + $db = '*'; + $table = "pma_table"; + $hostname = "pma_hostname"; + + //$db == '*' + $ret = PMA_getSqlQueryForDisplayPrivTable( + $db, $table, $username, $hostname + ); + $sql = "SELECT * FROM `mysql`.`user`" + ." WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + ." AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';"; + $this->assertEquals( + $sql, + $ret + ); + + //$table == '*' + $db = "pma_db"; + $table = "*"; + $ret = PMA_getSqlQueryForDisplayPrivTable( + $db, $table, $username, $hostname + ); + $sql = "SELECT * FROM `mysql`.`db`" + ." WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + ." AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "'" + ." AND '" . PMA_Util::unescapeMysqlWildcards($db) . "'" + ." LIKE `Db`;"; + $this->assertEquals( + $sql, + $ret + ); + + //$table == 'pma_table' + $db = "pma_db"; + $table = "pma_table"; + $ret = PMA_getSqlQueryForDisplayPrivTable( + $db, $table, $username, $hostname + ); + $sql = "SELECT `Table_priv`" + ." FROM `mysql`.`tables_priv`" + ." WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + ." AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "'" + ." AND `Db` = '" . PMA_Util::unescapeMysqlWildcards($db) . "'" + ." AND `Table_name` = '" . PMA_Util::sqlAddSlashes($table) . "';"; + $this->assertEquals( + $sql, + $ret + ); + } + /** * Test for PMA_getDataForChangeOrCopyUser * From 21eda1c2c42d28370b91c99017dcee7eef9691fd Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 5 Sep 2013 12:31:23 -0400 Subject: [PATCH 26/88] 4.0.6 release --- ChangeLog | 2 +- README | 2 +- doc/conf.py | 2 +- libraries/Config.class.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5a677c1c3..27f1af2c68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ phpMyAdmin - ChangeLog ====================== -4.0.6.0 (not yet released) +4.0.6.0 (2013-09-05) - bug #4036 Call to undefined function mb_detect_encoding (clarify the doc) - bug Missing hints when changing a column's structure - bug #4048 Cannot select foreign value in Search diff --git a/README b/README index 49d5d82d3b..09dbef08e6 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ phpMyAdmin - Readme =================== -Version 4.0.6-rc2 +Version 4.0.6 A set of PHP-scripts to manage MySQL over the web. diff --git a/doc/conf.py b/doc/conf.py index 476e591072..04dd40bda5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -49,7 +49,7 @@ copyright = u'2012 - 2013, The phpMyAdmin devel team' # built documents. # # The short X.Y version. -version = '4.0.6-rc2' +version = '4.0.6' # The full version, including alpha/beta/rc tags. release = version diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 86b7dd1501..8ee567a113 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -102,7 +102,7 @@ class PMA_Config */ function checkSystem() { - $this->set('PMA_VERSION', '4.0.6-rc2'); + $this->set('PMA_VERSION', '4.0.6'); /** * @deprecated */ From edcf5a031c2f094e4d17e1ad90b9647d5ae93226 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 5 Sep 2013 12:32:23 -0400 Subject: [PATCH 27/88] Fix merge conflict --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f52b5700cd..c28a6058f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ phpMyAdmin - ChangeLog - bug #3993 Sorting in database overview with statistics doesn't work - bug Handle the situation where PHP_SELF is not set -4.0.6.0 (not yet released) +4.0.6.0 (2013-09-05) - bug #4036 Call to undefined function mb_detect_encoding (clarify the doc) - bug Missing hints when changing a column's structure - bug #4048 Cannot select foreign value in Search From cfdc45c037e2fcf8624e09fe48263c8c3414b90b Mon Sep 17 00:00:00 2001 From: Isaac Bennetch Date: Thu, 5 Sep 2013 12:54:20 -0400 Subject: [PATCH 28/88] ChangeLog for 2666ee50232afb8693553d7e4690b730fda1778a --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 887a56d5ee..62f34a1a53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,7 @@ phpMyAdmin - ChangeLog + [setup] rfe #1452 Use type="password" for server passwords + rfe #1451 HTML5 input tag enhancements - bug #1193 Text field too small when editing a row longer than $cfg['LimitChars'] ++ Privileges tab for table level 4.0.7.0 (not yet released) - bug #3993 Sorting in database overview with statistics doesn't work From f0585a2693ad73f77544d78ab4abe48d182add1d Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 6 Sep 2013 02:55:34 +0530 Subject: [PATCH 29/88] Fix reload flag on database change --- libraries/sql.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 98b67c6455..6639c4ec28 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -2284,7 +2284,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, $sql_limit_to_append = ''; } - $reload = PMA_hasCurrentDbChanged($db); + $GLOBALS['reload'] = PMA_hasCurrentDbChanged($db); // Execute the query list($result, $num_rows, $unlim_num_rows, $profiling_results, From c9268f80ad4bea38965af9a47d53538b12a91769 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Fri, 6 Sep 2013 07:22:00 +0530 Subject: [PATCH 30/88] Adhere to coding style --- libraries/server_privileges.lib.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index d7018f2865..67e83daf1b 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -183,6 +183,11 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false, $tablePrivs = false return $privs; } // end of the 'PMA_extractPrivInfo()' function +/** + * Returns an array of table grants and their descriptions + * + * @return array array of table grants + */ function PMA_getTableGrantsArray() { return array( @@ -1929,8 +1934,7 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges(); - $sql_query = - "(" + $sql_query = "(" . " SELECT " . $list_of_privileges . ", '*' AS `Db`" . " FROM `mysql`.`user`" . " WHERE NOT (" . $list_of_compared_privileges . ")" @@ -1978,7 +1982,9 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) $privMap[$user][$host][] = $row; } - $html_output .= PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table); + $html_output .= PMA_getHtmlTableBodyForSpecificDbOrTablePrivs( + $privMap, $db, $table + ); $html_output .= ''; $html_output .= '
'; $html_output .= ''; @@ -2012,13 +2018,15 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) * * @return string $html_output */ -function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = null) { +function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = null) +{ $html_output = ''; $odd_row = true; if (! empty($privMap)) { foreach ($privMap as $current_user => $val) { foreach ($val as $current_host => $current_privileges) { - $html_output .= ''; + $html_output .= ''; // user $html_output .= ''; + $html_output .= '' + . __('Any') . ''; } else { $html_output .= htmlspecialchars($current_user); } @@ -2059,7 +2068,9 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n } } else { $html_output .= __('wildcard'). ': ' - . '' . htmlspecialchars($current['Db']) . ''; + . '' + . htmlspecialchars($current['Db']) + . ''; } $html_output .= ''; @@ -2069,7 +2080,7 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n $privList = explode(',', $current['Table_priv']); $privs = array(); $grantsArr = PMA_getTableGrantsArray(); - foreach($grantsArr as $grant) { + foreach ($grantsArr as $grant) { $privs[$grant[0]] = 'N'; foreach ($privList as $priv) { if ($grant[0] == $priv) { From 0c284306596c6f5a50c053e369044a35974c59b0 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Fri, 6 Sep 2013 07:29:44 +0530 Subject: [PATCH 31/88] Wildcards are not applicable to table privileges --- libraries/server_privileges.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 67e83daf1b..b4c3ddf0cb 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2060,7 +2060,7 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n $html_output .= __('global'); } elseif ($current['Db'] == PMA_Util::escapeMysqlWildcards($db)) { if (isset($current['Table_name']) - && $current['Table_name'] == PMA_Util::escapeMysqlWildcards($table) + && $current['Table_name'] == $table ) { $html_output .= __('table-specific'); } else { From 17de8a6a49d4ff77edcd2f380bb3de855332222c Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Fri, 6 Sep 2013 07:35:09 +0530 Subject: [PATCH 32/88] Shorten a lines exceeding 85 characters --- libraries/server_privileges.lib.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index b4c3ddf0cb..b94dba1128 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2000,8 +2000,9 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) 'tablename' => $table ) ) - .'" rel="' - . PMA_URL_getCommon(array('checkprivsdb' => $db, 'checkprivstable' => $table)) + . '" rel="' . PMA_URL_getCommon( + array('checkprivsdb' => $db, 'checkprivstable' => $table) + ) . '" class="ajax" name="table_specific">' . PMA_Util::getIcon('b_usradd.png') . __('Add user') . '
'; @@ -2122,11 +2123,16 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n // action $html_output .= ''; + $specific_db = (isset($current['Db']) && $current['Db'] != '*') + ? $current['Db'] : ''; + $specific_table = (isset($current['Table_name']) + && $current['Table_name'] != '*') + ? $current['Table_name'] : ''; $html_output .= PMA_getUserEditLink( $current_user, $current_host, - (isset($current['Db']) && $current['Db'] != '*') ? $current['Db'] : '', - (isset($current['Table_name']) && $current['Table_name'] != '*') ? $current['Table_name'] : '' + $specific_db, + $specific_table ); $html_output .= ''; From 33b9ebc16ae9aa6c03e425f4b00bb6f1c4520efa Mon Sep 17 00:00:00 2001 From: xmujay Date: Fri, 6 Sep 2013 14:50:32 +0800 Subject: [PATCH 33/88] remove unneeded constant which have defined in common files --- test/libraries/PMA_server_privileges_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libraries/PMA_server_privileges_test.php b/test/libraries/PMA_server_privileges_test.php index 911594618f..ffc6a5ee78 100644 --- a/test/libraries/PMA_server_privileges_test.php +++ b/test/libraries/PMA_server_privileges_test.php @@ -22,7 +22,7 @@ require_once 'libraries/Message.class.php'; require_once 'libraries/Response.class.php'; require_once 'libraries/relation.lib.php'; require_once 'libraries/server_privileges.lib.php'; -define("PMA_USR_BROWSER_AGENT", 1); + /** * PMA_ServerPrivileges_Test class * From c38da98d4ad762962f954a7a0048fa3a0f565de9 Mon Sep 17 00:00:00 2001 From: Spun Nakandala Date: Fri, 6 Sep 2013 21:00:16 +0530 Subject: [PATCH 34/88] added browse_foreigners.lib.php and extracted methods from browse_foreigners to it. --- browse_foreigners.php | 322 +--------------------- libraries/browse_foreigners.lib.php | 408 ++++++++++++++++++++++++++++ 2 files changed, 422 insertions(+), 308 deletions(-) create mode 100644 libraries/browse_foreigners.lib.php diff --git a/browse_foreigners.php b/browse_foreigners.php index 946c1ce2f2..a35b403d0d 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -8,19 +8,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/transformations.lib.php'; - -/** - * Sets globals from $_REQUEST - */ -$request_params = array( - 'field' -); - -foreach ($request_params as $one_request_param) { - if (isset($_REQUEST[$one_request_param])) { - $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; - } -} +require_once 'libraries/browse_foreigners.lib.php'; PMA_Util::checkParameters(array('db', 'table', 'field')); @@ -36,311 +24,29 @@ $header->setBodyId('body_browse_foreigners'); $cfgRelation = PMA_getRelationsParam(); $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : false); - -$override_total = true; - -if (! isset($_REQUEST['pos'])) { - $pos = 0; -} else { - $pos = $_REQUEST['pos']; -} - -$foreign_limit = 'LIMIT ' . $pos . ', ' . $GLOBALS['cfg']['MaxRows'] . ' '; -if (isset($foreign_navig) && $foreign_navig == __('Show all')) { - unset($foreign_limit); -} +$foreign_limit = PMA_getForeignLimit( + isset($foreign_navig) ? $foreign_navig : null +); $foreignData = PMA_getForeignData( - $foreigners, $field, $override_total, + $foreigners, $_REQUEST['field'], true, isset($_REQUEST['foreign_filter']) ? $_REQUEST['foreign_filter'] - : '', $foreign_limit -); - -$gotopage = ''; -$showall = ''; - -if (is_array($foreignData['disp_row'])) { - - if ($cfg['ShowAll'] - && ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) - ) { - $showall = ''; - } - - $session_max_rows = $GLOBALS['cfg']['MaxRows']; - $pageNow = @floor($pos / $session_max_rows) + 1; - $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows); - - if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) { - $gotopage = PMA_Util::pageselector( - 'pos', - $session_max_rows, - $pageNow, - $nbTotalPage, - 200, - 5, - 5, - 20, - 10, - __('Page number:') - ); - } -} - -// When coming from Table/Zoom search -if (isset($_REQUEST['fromsearch'])) { - // In table or zoom search, input fields are named "criteriaValues" - $element_name = " var field = 'criteriaValues';\n"; -} else { - // In insert/edit, input fields are named "fields" - $element_name = " var field = 'fields';\n"; -} - -if (isset($_REQUEST['rownumber'])) { - $element_name .= " var element_name = field + '[multi_edit][" - . htmlspecialchars($_REQUEST['rownumber']) . "][' + fieldmd5 + ']';\n" - . " var null_name = field_null + '[multi_edit][" - . htmlspecialchars($_REQUEST['rownumber']) . "][' + fieldmd5 + ']';\n"; -} else { - $element_name .= "var element_name = field + '[]'"; -} -$error = PMA_jsFormat( - __( - 'The target browser window could not be updated. ' - . 'Maybe you have closed the parent window, or ' - . 'your browser\'s security settings are ' - . 'configured to block cross-window updates.' - ) + : '', + isset($foreign_limit) ? $foreign_limit : null ); -if (! isset($_REQUEST['fieldkey']) || ! is_numeric($_REQUEST['fieldkey'])) { - $fieldkey = 0; -} else { - $fieldkey = $_REQUEST['fieldkey']; -} - -$code = <<getScripts()->addCode($code); // HTML output -$output = '
' - . '
' - . PMA_URL_getHiddenInputs($db, $table) - . '' - . ''; +$html = PMA_getHtmlForRelationalFieldSelection( + $db, $table, $_REQUEST['field'], $foreignData, + isset($fieldkey) ? $fieldkey : null, + isset($data) ? $data : null +); -if (isset($_REQUEST['rownumber'])) { - $output .= ''; -} -$output .= '' - . '' - . '' - . '' - . '' - . '' . $gotopage . '' - . '' . $showall . '' - . '
' - . '
'; - -$output .= ''; - -if (is_array($foreignData['disp_row'])) { - $header = ' - - - - - - '; - - $output .= '' . $header . '' . "\n" - . '' . $header . '' . "\n" - . '' . "\n"; - - $values = array(); - $keys = array(); - foreach ($foreignData['disp_row'] as $relrow) { - if ($foreignData['foreign_display'] != false) { - $values[] = $relrow[$foreignData['foreign_display']]; - } else { - $values[] = ''; - } - - $keys[] = $relrow[$foreignData['foreign_field']]; - } - - asort($keys); - - $hcount = 0; - $odd_row = true; - $val_ordered_current_row = 0; - $val_ordered_current_equals_data = false; - $key_ordered_current_equals_data = false; - foreach ($keys as $key_ordered_current_row => $value) { - $hcount++; - - if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) { - $output .= $header; - $hcount = 0; - $odd_row = true; - } - - $key_ordered_current_key = $keys[$key_ordered_current_row]; - $key_ordered_current_val = $values[$key_ordered_current_row]; - - $val_ordered_current_key = $keys[$val_ordered_current_row]; - $val_ordered_current_val = $values[$val_ordered_current_row]; - - $val_ordered_current_row++; - - if ($GLOBALS['PMA_String']->strlen($val_ordered_current_val) <= $cfg['LimitChars']) { - $val_ordered_current_val = htmlspecialchars( - $val_ordered_current_val - ); - $val_ordered_current_val_title = ''; - } else { - $val_ordered_current_val_title = htmlspecialchars( - $val_ordered_current_val - ); - $val_ordered_current_val = htmlspecialchars( - $GLOBALS['PMA_String']->substr($val_ordered_current_val, 0, $cfg['LimitChars']) - . '...' - ); - } - if ($GLOBALS['PMA_String']->strlen($key_ordered_current_val) <= $cfg['LimitChars']) { - $key_ordered_current_val = htmlspecialchars( - $key_ordered_current_val - ); - $key_ordered_current_val_title = ''; - } else { - $key_ordered_current_val_title = htmlspecialchars( - $key_ordered_current_val - ); - $key_ordered_current_val = htmlspecialchars( - $GLOBALS['PMA_String']->substr( - $key_ordered_current_val, 0, $cfg['LimitChars'] - ) . '...' - ); - } - - if (! empty($data)) { - $val_ordered_current_equals_data = $val_ordered_current_key == $data; - $key_ordered_current_equals_data = $key_ordered_current_key == $data; - } - - $output .= ''; - $odd_row = ! $odd_row; - - $output .= ''; - - $output .= ''; - - $output .= ''; - - $output .= ''; - - $output .= ''; - $output .= ''; - } // end while -} - -$output .= '' - . '
' . __('Keyname') . '' . __('Description') . '' . __('Description') . '' . __('Keyname') . '
' - . ($key_ordered_current_equals_data ? '' : '') - . '' - . htmlspecialchars($key_ordered_current_key) - . '' . ($key_ordered_current_equals_data ? '' : '') - . '' - . ($key_ordered_current_equals_data ? '' : '') - . '' - . $key_ordered_current_val . '' - . ($key_ordered_current_equals_data ? '' : '') - . '' - . '' - . ($val_ordered_current_equals_data ? '' : '') - . '' - . $val_ordered_current_val . '' - . ($val_ordered_current_equals_data ? '' : '') - . '' - . ($val_ordered_current_equals_data ? '' : '') - . '' - . htmlspecialchars($val_ordered_current_key) - . '' . ($val_ordered_current_equals_data ? '' : '') - . '
'; - -$response->addHtml($output); +$response->addHtml($html); ?> diff --git a/libraries/browse_foreigners.lib.php b/libraries/browse_foreigners.lib.php new file mode 100644 index 0000000000..01d148bcf3 --- /dev/null +++ b/libraries/browse_foreigners.lib.php @@ -0,0 +1,408 @@ +' + . '
' + . PMA_URL_getHiddenInputs($db, $table) + . '' + . ''; + + if (isset($_REQUEST['rownumber'])) { + $output .= ''; + } + $output .= '' + . '' + . '' + . '' + . '' + . '' . $gotopage . '' + . '' . $showall . '' + . '
' + . ''; + + $output .= ''; + + if (is_array($foreignData['disp_row'])) { + $header = ' + + + + + + '; + + $output .= '' . $header . '' . "\n" + . '' . $header . '' . "\n" + . '' . "\n"; + + $values = array(); + $keys = array(); + foreach ($foreignData['disp_row'] as $relrow) { + if ($foreignData['foreign_display'] != false) { + $values[] = $relrow[$foreignData['foreign_display']]; + } else { + $values[] = ''; + } + + $keys[] = $relrow[$foreignData['foreign_field']]; + } + + asort($keys); + + $hcount = 0; + $odd_row = true; + $val_ordered_current_row = 0; + $val_ordered_current_equals_data = false; + $key_ordered_current_equals_data = false; + foreach ($keys as $key_ordered_current_row => $value) { + $hcount++; + + if ($GLOBALS['cfg']['RepeatCells'] > 0 + && $hcount > $GLOBALS['cfg']['RepeatCells'] + ) { + $output .= $header; + $hcount = 0; + $odd_row = true; + } + + $key_ordered_current_key = $keys[$key_ordered_current_row]; + $key_ordered_current_val = $values[$key_ordered_current_row]; + + $val_ordered_current_key = $keys[$val_ordered_current_row]; + $val_ordered_current_val = $values[$val_ordered_current_row]; + + $val_ordered_current_row++; + + $pmaString = $GLOBALS['PMA_String']; + $limitChars = $GLOBALS['cfg']['LimitChars']; + if ($pmaString->strlen($val_ordered_current_val) <= $limitChars) { + $val_ordered_current_val = htmlspecialchars( + $val_ordered_current_val + ); + $val_ordered_current_val_title = ''; + } else { + $val_ordered_current_val_title = htmlspecialchars( + $val_ordered_current_val + ); + $val_ordered_current_val = htmlspecialchars( + $pmaString->substr( + $val_ordered_current_val, 0, $limitChars + ) + . '...' + ); + } + if ($pmaString->strlen($key_ordered_current_val) <= $limitChars) { + $key_ordered_current_val = htmlspecialchars( + $key_ordered_current_val + ); + $key_ordered_current_val_title = ''; + } else { + $key_ordered_current_val_title = htmlspecialchars( + $key_ordered_current_val + ); + $key_ordered_current_val = htmlspecialchars( + $pmaString->substr( + $key_ordered_current_val, 0, $limitChars + ) . '...' + ); + } + + if (! empty($data)) { + $val_ordered_current_equals_data + = $val_ordered_current_key == $data; + $key_ordered_current_equals_data + = $key_ordered_current_key == $data; + } + + $output .= ''; + $odd_row = ! $odd_row; + + $output .= ''; + + $output .= ''; + + $output .= ''; + + $output .= ''; + + $output .= ''; + $output .= ''; + } // end while + } + $output .= '' + . '
' . __('Keyname') . '' . __('Description') . '' . __('Description') . '' . __('Keyname') . '
' + . ($key_ordered_current_equals_data ? '' : '') + . '' + . htmlspecialchars($key_ordered_current_key) + . '' . ($key_ordered_current_equals_data ? '' : '') + . '' + . ($key_ordered_current_equals_data ? '' : '') + . '' + . $key_ordered_current_val . '' + . ($key_ordered_current_equals_data ? '' : '') + . '' + . '' + . ($val_ordered_current_equals_data ? '' : '') + . '' + . $val_ordered_current_val . '' + . ($val_ordered_current_equals_data ? '' : '') + . '' + . ($val_ordered_current_equals_data ? '' : '') + . '' + . htmlspecialchars($val_ordered_current_key) + . '' . ($val_ordered_current_equals_data ? '' : '') + . '
'; + + return $output; +} + +/** + * Function to get javascript code to handle display selection for relational + * field values + * + * @return string + */ +function PMA_getJsScriptToHandleSelectRelationalFields() +{ + $element_name = PMA_getElementName(); + $fieldkey = PMA_getFieldKey(); + $error = PMA_getJsError(); + $code = << $GLOBALS['cfg']['MaxRows']) + ) { + $showall = ''; + } + } + + return $showall; +} + +/** + * Function to get html for the goto page option + * + * @param array $foreignData foreign data + * + * @return string + */ +function PMA_getHtmlForGotoPage($foreignData) +{ + $gotopage = ''; + isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0; + if (is_array($foreignData['disp_row'])) { + $session_max_rows = $GLOBALS['cfg']['MaxRows']; + $pageNow = @floor($pos / $session_max_rows) + 1; + $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows); + + if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) { + $gotopage = PMA_Util::pageselector( + 'pos', + $session_max_rows, + $pageNow, + $nbTotalPage, + 200, + 5, + 5, + 20, + 10, + __('Page number:') + ); + } + } + return $gotopage; +} + +/** + * Function to get foreign limit + * + * @param string $foreign_navig foreign navigation + * + * @return string + */ +function PMA_getForeignLimit($foreign_navig) +{ + if (isset($foreign_navig) && $foreign_navig == __('Show all')) { + return null; + } + isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0; + return 'LIMIT ' . $pos . ', ' . $GLOBALS['cfg']['MaxRows'] . ' '; +} +?> From c6c3883ff4d988390d625d1e4e189e0ed32b4610 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 6 Sep 2013 17:37:52 +0200 Subject: [PATCH 35/88] fix coding style : indentation --- tbl_relation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tbl_relation.php b/tbl_relation.php index 2dc55d9ad8..748fa40a6a 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -93,12 +93,12 @@ $multi_edit_columns_name = isset($_REQUEST['fields_name']) // u p d a t e s f o r I n t e r n a l r e l a t i o n s if (isset($_POST['destination_db']) && $cfgRelation['relwork']) { - PMA_handleUpdatesForInternalRelations( + PMA_handleUpdatesForInternalRelations( $_POST['destination_db'], $multi_edit_columns_name, $_POST['destination_table'], $_POST['destination_column'], $cfgRelation, $db, $table, isset($existrel) ? $existrel : null - ); + ); } // end if (updates for internal relations) $html_output = ''; From 2b4de460b3f77b9f0ff806a76a95233924f8e136 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 6 Sep 2013 17:38:45 +0200 Subject: [PATCH 36/88] fix coding style, spacing --- libraries/server_privileges.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index d7018f2865..34c849409f 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2069,7 +2069,7 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n $privList = explode(',', $current['Table_priv']); $privs = array(); $grantsArr = PMA_getTableGrantsArray(); - foreach($grantsArr as $grant) { + foreach ($grantsArr as $grant) { $privs[$grant[0]] = 'N'; foreach ($privList as $priv) { if ($grant[0] == $priv) { From a9c04994a63d926caf335f92ac4ff338a7b6d49c Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 6 Sep 2013 17:45:01 +0200 Subject: [PATCH 37/88] fix coding style : add spaces between function arguments, wrap long lines --- test/classes/dbi/DBIMysql_test.php | 42 ++++++++++++++++++++--------- test/classes/dbi/DBIMysqli_test.php | 42 ++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/test/classes/dbi/DBIMysql_test.php b/test/classes/dbi/DBIMysql_test.php index 20de3f0e6f..556edd6d17 100644 --- a/test/classes/dbi/DBIMysql_test.php +++ b/test/classes/dbi/DBIMysql_test.php @@ -85,18 +85,36 @@ class PMA_DBI_Mysql_Test extends PHPUnit_Framework_TestCase $this->markTestSkipped("Cannot redefine function"); } //FOR UT, we just test the right mysql client API is called - runkit_function_redefine('mysql_pconnect','','return "mysql_pconnect";'); - runkit_function_redefine('mysql_connect','','return "mysql_connect";'); - runkit_function_redefine('mysql_query','','return "mysql_query";'); - runkit_function_redefine('mysql_fetch_array','','return "mysql_fetch_array";'); - runkit_function_redefine('mysql_data_seek','','return "mysql_data_seek";'); - runkit_function_redefine('mysql_get_host_info','','return "mysql_get_host_info";'); - runkit_function_redefine('mysql_get_proto_info','','return "mysql_get_proto_info";'); - runkit_function_redefine('mysql_field_flags','','return "mysql_field_flags";'); - runkit_function_redefine('mysql_field_name','','return "mysql_field_name";'); - runkit_function_redefine('mysql_field_len','','return "mysql_field_len";'); - runkit_function_redefine('mysql_num_fields','','return "mysql_num_fields";'); - runkit_function_redefine('mysql_affected_rows','','return "mysql_affected_rows";'); + runkit_function_redefine('mysql_pconnect', '', 'return "mysql_pconnect";'); + runkit_function_redefine('mysql_connect', '', 'return "mysql_connect";'); + runkit_function_redefine('mysql_query', '', 'return "mysql_query";'); + runkit_function_redefine( + 'mysql_fetch_array', '', 'return "mysql_fetch_array";' + ); + runkit_function_redefine( + 'mysql_data_seek', '', 'return "mysql_data_seek";' + ); + runkit_function_redefine( + 'mysql_get_host_info', '', 'return "mysql_get_host_info";' + ); + runkit_function_redefine( + 'mysql_get_proto_info', '', 'return "mysql_get_proto_info";' + ); + runkit_function_redefine( + 'mysql_field_flags', '', 'return "mysql_field_flags";' + ); + runkit_function_redefine( + 'mysql_field_name', '', 'return "mysql_field_name";' + ); + runkit_function_redefine( + 'mysql_field_len', '', 'return "mysql_field_len";' + ); + runkit_function_redefine( + 'mysql_num_fields', '', 'return "mysql_num_fields";' + ); + runkit_function_redefine( + 'mysql_affected_rows', '', 'return "mysql_affected_rows";' + ); //test for fieldFlags $result = array("table1", "table2"); diff --git a/test/classes/dbi/DBIMysqli_test.php b/test/classes/dbi/DBIMysqli_test.php index 0554f48473..cb1087e03b 100644 --- a/test/classes/dbi/DBIMysqli_test.php +++ b/test/classes/dbi/DBIMysqli_test.php @@ -85,18 +85,36 @@ class PMA_DBI_Mysqli_Test extends PHPUnit_Framework_TestCase } //FOR UT, we just test the right mysql client API is called - runkit_function_redefine('mysqli_real_connect','','return "mysqli_real_connect";'); - runkit_function_redefine('mysqli_init','','return "mysqli_init";'); - runkit_function_redefine('mysqli_options','','return "mysqli_options";'); - runkit_function_redefine('mysqli_query','','return "mysqli_query";'); - runkit_function_redefine('mysqli_multi_query','','return "mysqli_multi_query";'); - runkit_function_redefine('mysqli_fetch_array','','return "mysqli_fetch_array";'); - runkit_function_redefine('mysqli_data_seek','','return "mysqli_data_seek";'); - runkit_function_redefine('mysqli_more_results','','return "mysqli_more_results";'); - runkit_function_redefine('mysqli_next_result','','return "mysqli_next_result";'); - runkit_function_redefine('mysqli_get_host_info','','return "mysqli_get_host_info";'); - runkit_function_redefine('mysqli_get_proto_info','','return "mysqli_get_proto_info";'); - runkit_function_redefine('mysqli_get_client_info','','return "mysqli_get_client_info";'); + runkit_function_redefine( + 'mysqli_real_connect', '', 'return "mysqli_real_connect";' + ); + runkit_function_redefine('mysqli_init', '', 'return "mysqli_init";'); + runkit_function_redefine('mysqli_options', '', 'return "mysqli_options";'); + runkit_function_redefine('mysqli_query', '', 'return "mysqli_query";'); + runkit_function_redefine( + 'mysqli_multi_query', '', 'return "mysqli_multi_query";' + ); + runkit_function_redefine( + 'mysqli_fetch_array', '', 'return "mysqli_fetch_array";' + ); + runkit_function_redefine( + 'mysqli_data_seek', '', 'return "mysqli_data_seek";' + ); + runkit_function_redefine( + 'mysqli_more_results', '', 'return "mysqli_more_results";' + ); + runkit_function_redefine( + 'mysqli_next_result', '', 'return "mysqli_next_result";' + ); + runkit_function_redefine( + 'mysqli_get_host_info', '', 'return "mysqli_get_host_info";' + ); + runkit_function_redefine( + 'mysqli_get_proto_info', '', 'return "mysqli_get_proto_info";' + ); + runkit_function_redefine( + 'mysqli_get_client_info', '', 'return "mysqli_get_client_info";' + ); $user = 'PMA_user'; $password = 'PMA_password'; From 58f933817864c6a60384bc8636f3c3202519533b Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 6 Sep 2013 17:48:06 +0200 Subject: [PATCH 38/88] cleanup whitespace --- test/libraries/PMA_relation_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libraries/PMA_relation_test.php b/test/libraries/PMA_relation_test.php index 9ff1cd5233..4baa8567aa 100644 --- a/test/libraries/PMA_relation_test.php +++ b/test/libraries/PMA_relation_test.php @@ -136,7 +136,7 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase ); // $cfg['Servers'][$i]['table_info'] $result = "\$cfg['Servers'][\$i]['table_info'] ... " - . "" + . "" . "not OK"; $this->assertContains( $result, From a6ca1f05b6ba73547d15938854e47d735eaf851a Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 6 Sep 2013 17:50:32 +0200 Subject: [PATCH 39/88] fix coding style : opening brace should be on a new line --- libraries/server_privileges.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 34c849409f..74efd27e82 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2012,7 +2012,8 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) * * @return string $html_output */ -function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = null) { +function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = null) +{ $html_output = ''; $odd_row = true; if (! empty($privMap)) { From 4b43310d6f7e285129151ba023d30e1bae862cd2 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Fri, 6 Sep 2013 17:53:54 +0200 Subject: [PATCH 40/88] fix coding style : use lowercase null --- libraries/config.default.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/config.default.php b/libraries/config.default.php index f7d4465974..8bfa21a80c 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -150,35 +150,35 @@ $cfg['Servers'][$i]['ssl'] = false; * * @global string $cfg['Servers'][$i]['ssl_key'] */ -$cfg['Servers'][$i]['ssl_key'] = NULL; +$cfg['Servers'][$i]['ssl_key'] = null; /** * Path to the cert file when using SSL for connecting to the MySQL server * * @global string $cfg['Servers'][$i]['ssl_cert'] */ -$cfg['Servers'][$i]['ssl_cert'] = NULL; +$cfg['Servers'][$i]['ssl_cert'] = null; /** * Path to the CA file when using SSL for connecting to the MySQL server * * @global string $cfg['Servers'][$i]['ssl_ca'] */ -$cfg['Servers'][$i]['ssl_ca'] = NULL; +$cfg['Servers'][$i]['ssl_ca'] = null; /** * Directory containing trusted SSL CA certificates in PEM format * * @global string $cfg['Servers'][$i]['ssl_ca_path'] */ -$cfg['Servers'][$i]['ssl_ca_path'] = NULL; +$cfg['Servers'][$i]['ssl_ca_path'] = null; /** * List of allowable ciphers for SSL connections to the MySQL server * * @global string $cfg['Servers'][$i]['ssl_ciphers'] */ -$cfg['Servers'][$i]['ssl_ciphers'] = NULL; +$cfg['Servers'][$i]['ssl_ciphers'] = null; /** * How to connect to MySQL server ('tcp' or 'socket') From aca7522b5392f7a439ed23a6d637ff4d89952463 Mon Sep 17 00:00:00 2001 From: Spun Nakandala Date: Fri, 6 Sep 2013 21:43:55 +0530 Subject: [PATCH 41/88] error corrected --- browse_foreigners.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/browse_foreigners.php b/browse_foreigners.php index a35b403d0d..81a19e9a0e 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -10,6 +10,19 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/transformations.lib.php'; require_once 'libraries/browse_foreigners.lib.php'; +/** + * Sets globals from $_REQUEST + */ +$request_params = array( + 'field' +); + +foreach ($request_params as $one_request_param) { + if (isset($_REQUEST[$one_request_param])) { + $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; + } +} + PMA_Util::checkParameters(array('db', 'table', 'field')); $response = PMA_Response::getInstance(); From 07444b47088c552efdeb5e6bf38618f178a9ab66 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Fri, 6 Sep 2013 21:46:53 +0530 Subject: [PATCH 42/88] Properly identify grant type --- libraries/server_privileges.lib.php | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index b94dba1128..2668a99524 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1828,14 +1828,14 @@ function PMA_getHtmlForSpecificDbPrivileges($db) list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges(); - $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`' + $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`, \'d\' AS `Type`' .' FROM `mysql`.`db`' .' WHERE \'' . PMA_Util::sqlAddSlashes($db) . "'" .' LIKE `Db`' .' AND NOT (' . $list_of_compared_privileges. ')) ' .'UNION ' - .'(SELECT ' . $list_of_privileges . ', \'*\' AS `Db`' + .'(SELECT ' . $list_of_privileges . ', \'*\' AS `Db`, \'g\' AS `Type`' .' FROM `mysql`.`user` ' .' WHERE NOT (' . $list_of_compared_privileges . ')) ' .' ORDER BY `User` ASC,' @@ -1935,13 +1935,13 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges(); $sql_query = "(" - . " SELECT " . $list_of_privileges . ", '*' AS `Db`" + . " SELECT " . $list_of_privileges . ", '*' AS `Db`, 'g' AS `Type`" . " FROM `mysql`.`user`" . " WHERE NOT (" . $list_of_compared_privileges . ")" . ")" . " UNION " . "(" - . " SELECT " . $list_of_privileges . ", `Db`" + . " SELECT " . $list_of_privileges . ", `Db`, 'd' AS `Type`" . " FROM `mysql`.`db`" . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" . " AND NOT (" . $list_of_compared_privileges. ")" @@ -1962,7 +1962,7 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) $privMap[$user][$host][] = $row; } - $sql_query = "SELECT `User`, `Host`, `Db`, `Table_name`, `Table_priv`" + $sql_query = "SELECT `User`, `Host`, `Db`, 't' AS `Type`, `Table_name`, `Table_priv`" . " FROM `mysql`.`tables_priv`" . " WHERE '" . PMA_Util::sqlAddSlashes($db) . "' LIKE `Db`" . " AND '" . PMA_Util::sqlAddSlashes($table) . "' LIKE `Table_name`" @@ -1991,7 +1991,7 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) // Offer to create a new user for the current database $html_output .= '
' - . '' . _pgettext('Create new user', 'New') . ''; + . '' . _pgettext('Create new user', 'New') . ''; $html_output .= ' Date: Fri, 6 Sep 2013 22:25:38 +0530 Subject: [PATCH 45/88] Handle sub tabs properly --- libraries/server_privileges.lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index b1c4ac99cf..85cdd47e9c 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -4526,11 +4526,13 @@ function PMA_getHtmlForSubMenusOnUsersPage($selfUrl) $items = array( array( 'name' => __('Users overview'), - 'url' => 'server_privileges.php' + 'url' => 'server_privileges.php', + 'specific_params' => '&viewing_mode=server' ), array( 'name' => __('User groups'), - 'url' => 'server_user_groups.php' + 'url' => 'server_user_groups.php', + 'specific_params' => '' ) ); @@ -4542,7 +4544,8 @@ function PMA_getHtmlForSubMenusOnUsersPage($selfUrl) } $retval .= '
  • '; $retval .= ''; + $retval .= ' href="' . $item['url'] + . '?' . $url_params . $item['specific_params'] . '">'; $retval .= $item['name']; $retval .= ''; $retval .= '
  • '; From fd32385236bf9d6bc064f8ced60557de15a15d45 Mon Sep 17 00:00:00 2001 From: Spun Nakandala Date: Fri, 6 Sep 2013 23:14:15 +0530 Subject: [PATCH 46/88] added method PMA_getHtmlForColumnElement --- libraries/browse_foreigners.lib.php | 99 +++++++++++++++-------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/libraries/browse_foreigners.lib.php b/libraries/browse_foreigners.lib.php index 01d148bcf3..ff5f45c783 100644 --- a/libraries/browse_foreigners.lib.php +++ b/libraries/browse_foreigners.lib.php @@ -152,59 +152,29 @@ function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignDat $output .= ''; $odd_row = ! $odd_row; - $output .= '' - . ($key_ordered_current_equals_data ? '' : '') - . '' - . htmlspecialchars($key_ordered_current_key) - . '' . ($key_ordered_current_equals_data ? '' : '') - . ''; - - $output .= '' - . ($key_ordered_current_equals_data ? '' : '') - . '' - . $key_ordered_current_val . '' - . ($key_ordered_current_equals_data ? '' : '') - . ''; - + $output .= PMA_getHtmlForColumnElement( + 'class="nowrap"', $key_ordered_current_equals_data, + $key_ordered_current_key, $key_ordered_current_val_title, $field + ); + + $output .= PMA_getHtmlForColumnElement( + '', $key_ordered_current_equals_data, + $key_ordered_current_val, $key_ordered_current_val_title, $field + ); + $output .= '' . ''; - $output .= '' - . ($val_ordered_current_equals_data ? '' : '') - . '' - . $val_ordered_current_val . '' - . ($val_ordered_current_equals_data ? '' : '') - . ''; + $output .= PMA_getHtmlForColumnElement( + '', $val_ordered_current_equals_data, + $val_ordered_current_val, $val_ordered_current_val_title, $field + ); - $output .= '' - . ($val_ordered_current_equals_data ? '' : '') - . '' - . htmlspecialchars($val_ordered_current_key) - . '' . ($val_ordered_current_equals_data ? '' : '') - . ''; + $output .= PMA_getHtmlForColumnElement( + 'class="nowrap"', $val_ordered_current_equals_data, + $val_ordered_current_key, $val_ordered_current_val_title, $field + ); $output .= ''; } // end while } @@ -214,6 +184,39 @@ function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignDat return $output; } +/** + * Function to get html for each column element + * @param string $cssClass class="nowrap" or '' + * @param bool $currentEqualsData whether current equals data + * @param string $currentKey current key + * @param string $currentTitle current title + * @param string $field field + * + * @return string + */ +function PMA_getHtmlForColumnElement($cssClass, $currentEqualsData, $currentKey, + $currentTitle, $field +){ + $output = '' + . ($currentEqualsData ? '' : '') + . ''; + if ($cssClass == '') { + $currentKey = htmlspecialchars($currentKey); + } + + $output .= $currentKey . '' + . ($currentEqualsData ? '' : '') + . ''; + + return $output; +} + /** * Function to get javascript code to handle display selection for relational * field values From bad43d7706873f4299c32c9e844733c02b8740e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 11:19:33 +0200 Subject: [PATCH 47/88] Translated using Weblate (Portuguese) Currently translated at 47.1% (1281 of 2720) --- po/pt.po | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/po/pt.po b/po/pt.po index ea0192b237..7663c3bcf2 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-08-23 11:34+0200\n" -"Last-Translator: Michal Čihař \n" +"PO-Revision-Date: 2013-09-07 11:19+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -36,9 +36,10 @@ msgid "" "parent window, or your browser's security settings are configured to block " "cross-window updates." msgstr "" -"A janela de destino no seu browser não pode ser actualizada. Talvez tenha " -"fechado a janela que a originou, ou as configurações de segurança do seu " -"browser encontram-se definidas para não permitir actualizações entre janelas." +"Não foi possível actualizar a janela de destino do seu navegador. Talvez " +"você tenha fechado a janela que a originou, ou as configurações de segurança " +"do seu navegador encontram-se definidas para não permitir actualizações " +"entre janelas." #: browse_foreigners.php:184 msgid "Search:" @@ -85,7 +86,7 @@ msgstr "Executar" #: browse_foreigners.php:202 browse_foreigners.php:206 #: libraries/Index.class.php:560 tbl_tracking.php:383 msgid "Keyname" -msgstr "Nome do Índice" +msgstr "Nome da chave" #: browse_foreigners.php:203 browse_foreigners.php:205 #: libraries/server_collations.lib.php:36 @@ -98,7 +99,7 @@ msgstr "Descrição" #: browse_foreigners.php:289 browse_foreigners.php:301 #: browse_foreigners.php:317 browse_foreigners.php:329 msgid "Use this value" -msgstr "Usar este valor" +msgstr "Utilizar este valor" #: changelog.php:36 license.php:28 #, php-format @@ -106,8 +107,8 @@ msgid "" "The %s file is not available on this system, please visit www.phpmyadmin.net " "for more information." msgstr "" -"O ficheiro %s não está disponível no seu sistema, por favor visite www." -"phpmyadmin.net para mais informações." +"O ficheiro %s não está disponível no seu sistema. Para mais informações, " +"visite www.phpmyadmin.net." #: db_create.php:61 #, php-format @@ -116,7 +117,7 @@ msgstr "A base de dados %1$s foi criada." #: db_datadict.php:52 libraries/operations.lib.php:32 msgid "Database comment: " -msgstr "Comentário da Base de Dados: " +msgstr "Comentário da base de dados: " #: db_datadict.php:159 libraries/schema/Pdf_Relation_Schema.class.php:1352 #: libraries/tbl_columns_definition_form.lib.php:70 tbl_printview.php:120 From d9f29f7211f87ba5881e3765650b9470858e9197 Mon Sep 17 00:00:00 2001 From: Jose Machado Date: Sat, 7 Sep 2013 11:20:17 +0200 Subject: [PATCH 48/88] Translated using Weblate (Portuguese) Currently translated at 47.1% (1282 of 2720) --- po/pt.po | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/po/pt.po b/po/pt.po index 7663c3bcf2..2e4d9f3be9 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 11:19+0200\n" -"Last-Translator: João Rodrigues \n" +"PO-Revision-Date: 2013-09-07 11:20+0200\n" +"Last-Translator: Jose Machado \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -121,10 +121,9 @@ msgstr "Comentário da base de dados: " #: db_datadict.php:159 libraries/schema/Pdf_Relation_Schema.class.php:1352 #: libraries/tbl_columns_definition_form.lib.php:70 tbl_printview.php:120 -#, fuzzy #| msgid "Table comments" msgid "Table comments:" -msgstr "Comentários da tabela" +msgstr "Comentários da tabela:" #: db_datadict.php:168 libraries/Index.class.php:564 #: libraries/TableSearch.class.php:185 libraries/TableSearch.class.php:1231 From 5abd3a0438785abc3f3c123153b0ef6f197a0d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 11:42:20 +0200 Subject: [PATCH 49/88] Translated using Weblate (Portuguese) Currently translated at 48.5% (1320 of 2720) - --- po/pt.po | 146 +++++++++++++++++++++++++------------------------------ 1 file changed, 65 insertions(+), 81 deletions(-) diff --git a/po/pt.po b/po/pt.po index 2e4d9f3be9..f9a5367ca9 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 11:20+0200\n" -"Last-Translator: Jose Machado \n" +"PO-Revision-Date: 2013-09-07 11:42+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -197,7 +197,7 @@ msgstr "Nulo" #: libraries/tbl_columns_definition_form.lib.php:288 tbl_printview.php:133 #: tbl_tracking.php:329 msgid "Default" -msgstr "Omissão" +msgstr "Predefinido" #: db_datadict.php:173 libraries/plugins/export/ExportHtmlword.class.php:406 #: libraries/plugins/export/ExportLatex.class.php:515 @@ -206,7 +206,7 @@ msgstr "Omissão" #: libraries/schema/Pdf_Relation_Schema.class.php:1384 #: libraries/schema/Pdf_Relation_Schema.class.php:1407 tbl_printview.php:135 msgid "Links to" -msgstr "Links para" +msgstr "Ligações para" #: db_datadict.php:175 db_printview.php:53 #: libraries/config/messages.inc.php:94 libraries/config/messages.inc.php:109 @@ -282,16 +282,16 @@ msgstr "Nenhuma tabela encontrada na base de dados." #: db_export.php:41 libraries/DbSearch.class.php:438 #: libraries/display_export.lib.php:42 msgid "Select All" -msgstr "Selecciona Todas" +msgstr "Seleccionar tudo" #: db_export.php:47 libraries/DbSearch.class.php:441 #: libraries/display_export.lib.php:48 msgid "Unselect All" -msgstr "Limpa Todas as Selecções" +msgstr "Desseleccionar tudo" #: db_operations.php:45 tbl_create.php:24 msgid "The database name is empty!" -msgstr "O nome da base de dados está vazia!" +msgstr "O nome da base de dados está vazio!" #: db_operations.php:130 #, php-format @@ -309,8 +309,8 @@ msgid "" "The phpMyAdmin configuration storage has been deactivated. To find out why " "click %shere%s." msgstr "" -"As configurações do phpMyAdmin para trabalhar com ligações entre Tabelas " -"foram desactivadas. Para saber porquê carregue %shere%s." +"O armazenamento da configuração do phpMyAdmin foi desactivado. Para saber " +"porquê clique %shere%s." #: db_printview.php:47 db_tracking.php:81 db_tracking.php:204 #: libraries/Menu.class.php:240 libraries/config/messages.inc.php:521 @@ -339,7 +339,7 @@ msgstr "Tamanho" #: db_printview.php:97 libraries/plugins/export/ExportSql.class.php:1115 #: libraries/structure.lib.php:731 msgid "in use" -msgstr "em uso" +msgstr "em utilização" #: db_printview.php:117 libraries/plugins/export/ExportSql.class.php:1041 #: libraries/schema/Pdf_Relation_Schema.class.php:1357 @@ -349,12 +349,12 @@ msgstr "Criação:" #: db_printview.php:126 libraries/plugins/export/ExportSql.class.php:1054 #: libraries/schema/Pdf_Relation_Schema.class.php:1362 msgid "Last update:" -msgstr "Última atualização:" +msgstr "Última actualização:" #: db_printview.php:135 libraries/plugins/export/ExportSql.class.php:1067 #: libraries/schema/Pdf_Relation_Schema.class.php:1367 msgid "Last check:" -msgstr "Última Verificação:" +msgstr "Última verificação:" #: db_printview.php:149 libraries/structure.lib.php:176 #, php-format @@ -530,10 +530,10 @@ msgid "SRID:" msgstr "SRID:" #: gis_data_editor.php:184 -#, fuzzy, php-format +#, php-format #| msgid "Geometry" msgid "Geometry %d:" -msgstr "Geometria" +msgstr "Geometria %d:" #: gis_data_editor.php:206 msgid "Point:" @@ -561,22 +561,21 @@ msgid "Add a point" msgstr "Adicionar um ponto" #: gis_data_editor.php:262 -#, fuzzy, php-format +#, php-format #| msgid "Linestring" msgid "Linestring %d:" -msgstr "Segmento de Reta" +msgstr "Segmento de reta %d:" #: gis_data_editor.php:265 gis_data_editor.php:341 -#, fuzzy #| msgid "Outer Ring" msgid "Outer ring:" -msgstr "Anel Exterior" +msgstr "Anel exterior:" #: gis_data_editor.php:267 gis_data_editor.php:343 -#, fuzzy, php-format +#, php-format #| msgid "Inner Ring" msgid "Inner ring %d:" -msgstr "Anel Interior" +msgstr "Anel interior %d:" #: gis_data_editor.php:303 msgid "Add a linestring" @@ -587,10 +586,10 @@ msgid "Add an inner ring" msgstr "Adicionar um anel interior" #: gis_data_editor.php:325 -#, fuzzy, php-format +#, php-format #| msgid "Polygon" msgid "Polygon %d:" -msgstr "Polígono" +msgstr "Polígono %d:" #: gis_data_editor.php:384 js/messages.php:325 msgid "Add a polygon" @@ -701,9 +700,8 @@ msgid "Back" msgstr "Voltar" #: index.php:115 libraries/Footer.class.php:72 -#, fuzzy msgid "phpMyAdmin Demo Server" -msgstr "Documentação do phpMyAdmin" +msgstr "Servidor demonstrativo do phpMyAdmin" #: index.php:119 #, php-format @@ -712,6 +710,9 @@ msgid "" "change root, debian-sys-maint and pma users. More information is available " "at %s." msgstr "" +"Está a utilizar um servidor demonstrativo. Pode fazer tudo o que quiser, " +"excepto, alterar os utilizadores root, debian-sys-maint e pma. Para mais " +"informações, veja %s." #: index.php:129 msgid "General Settings" @@ -743,62 +744,54 @@ msgid "Server:" msgstr "Servidor:" #: index.php:256 -#, fuzzy #| msgid "Server type" msgid "Server type:" -msgstr "Tipo de servidor" +msgstr "Tipo de servidor:" #: index.php:260 libraries/plugins/export/ExportLatex.class.php:225 #: libraries/plugins/export/ExportSql.class.php:630 #: libraries/plugins/export/ExportXml.class.php:198 -#, fuzzy #| msgid "Server version" msgid "Server version:" -msgstr "Versão do servidor" +msgstr "Versão do servidor:" #: index.php:264 -#, fuzzy #| msgid "Protocol version" msgid "Protocol version:" -msgstr "Versão do protocolo" +msgstr "Versão do protocolo:" #: index.php:268 -#, fuzzy #| msgid "User" msgid "User:" -msgstr "Utilizador" +msgstr "Utilizador:" #: index.php:273 -#, fuzzy #| msgid "Server charset" msgid "Server charset:" -msgstr "Conjunto de caracteres do servidor" +msgstr "Conjunto de caracteres do servidor:" #: index.php:285 msgid "Web server" msgstr "Servidor web" #: index.php:298 -#, fuzzy #| msgid "Database client version" msgid "Database client version:" -msgstr "Versão do cliente de base de dados" +msgstr "Versão do cliente de base de dados:" #: index.php:302 -#, fuzzy #| msgid "PHP extension" msgid "PHP extension:" -msgstr "Extensão de PHP" +msgstr "Extensão de PHP:" #: index.php:316 msgid "Show PHP information" msgstr "Mostra informação do PHP" #: index.php:339 -#, fuzzy #| msgid "Version information" msgid "Version information:" -msgstr "Informação de Versão" +msgstr "Informação da versão:" #: index.php:348 libraries/Util.class.php:429 libraries/Util.class.php:496 #: libraries/config/FormDisplay.tpl.php:149 @@ -886,7 +879,6 @@ msgstr "" "(blowfish_secret)." #: index.php:491 -#, fuzzy #| msgid "" #| "Directory [code]config[/code], which is used by the setup script, still " #| "exists in your phpMyAdmin directory. You should remove it once phpMyAdmin " @@ -897,9 +889,11 @@ msgid "" "once phpMyAdmin has been configured. Otherwise the security of your server " "may be compromised by unauthorized people downloading your configuration." msgstr "" -"A pasta [code]config[/code], que é usado pelo script de instalação, ainda " -"existe na sua pasta phpMyAdmin. Deverá remover esta pasta depois de ter " -"configurado o phpMyAdmin." +"A pasta [code]config[/code], que é utilizada pelo script de instalação, " +"ainda existe na sua pasta phpMyAdmin. É altamente recomendado que remova " +"esta pasta depois de ter configurado o phpMyAdmin. Caso contrário, a " +"segurança do seu servidor pode ser comprometida por pessoas não autorizadas " +"ao transferir a configuração." #: index.php:501 #, php-format @@ -935,7 +929,7 @@ msgstr "Os comandos \"DROP DATABASE\" estão inibidos." #: js/messages.php:35 msgid "Confirm" -msgstr "" +msgstr "Confirmar" #: js/messages.php:36 #, php-format @@ -967,24 +961,23 @@ msgid "This operation could take a long time. Proceed anyway?" msgstr "Esta operação poderá demorar. Deseja prosseguir?" #: js/messages.php:44 -#, fuzzy, php-format +#, php-format #| msgid "Do you really want to execute \"%s\"?" msgid "Do you really want to delete user group \"%s\"?" -msgstr "Você realmente deseja executar \"%s\"?" +msgstr "Deseja realmente eliminar o grupo de utilizadores \"%s\"?" #: js/messages.php:47 msgid "Missing value in the form!" msgstr "Nº de dados insuficiente!" #: js/messages.php:48 -#, fuzzy #| msgid "Not a valid port number" msgid "Please enter a valid number" -msgstr "Número de porta inválido" +msgstr "Introduza um número válido" #: js/messages.php:49 msgid "Please enter a valid length" -msgstr "" +msgstr "Introduza um comprimento válido" #: js/messages.php:50 msgid "Add Index" @@ -1781,16 +1774,14 @@ msgid "Show search criteria" msgstr "Mostrar critérios de busca" #: js/messages.php:286 -#, fuzzy #| msgid "Hide search criteria" msgid "Hide find and replace criteria" -msgstr "Esconder critérios de buca" +msgstr "Esconder critérios de localizar e substituir" #: js/messages.php:287 -#, fuzzy #| msgid "Show search criteria" msgid "Show find and replace criteria" -msgstr "Mostrar critérios de busca" +msgstr "Mostrar critérios de localizar e substituir" #: js/messages.php:290 libraries/TableSearch.class.php:212 msgid "Zoom Search" @@ -2003,10 +1994,9 @@ msgid "Hide Panel" msgstr "Esconder Painel" #: js/messages.php:379 -#, fuzzy #| msgid "Show logo in left frame" msgid "Show hidden navigation tree items" -msgstr "Mostrar logotipo no quadro da esquerda" +msgstr "Mostrar a navegação em árvore escondida" #: js/messages.php:382 msgid "The requested page was not found in the history, it may have expired." @@ -2335,12 +2325,12 @@ msgid "Unexpected characters on line %s." msgstr "Caracteres inesperados na linha %s." #: libraries/Advisor.class.php:437 -#, fuzzy, php-format +#, php-format #| msgid "Unexpected character on line %1$s. Expected tab, but found \"%2$s\"" msgid "Unexpected character on line %1$s. Expected tab, but found \"%2$s\"." msgstr "" -"Caractere inesperado na linha %1$s. Esperada tabulação, mas encontrado \"%2$s" -"\"" +"Carácter inesperado na linha %1$s. Era esperado uma tabulação, mas foi " +"encontrado \"%2$s\"." #: libraries/Advisor.class.php:470 msgid "per second" @@ -2394,28 +2384,24 @@ msgid "Descending" msgstr "Descendente" #: libraries/DBQbe.class.php:364 libraries/TableSearch.class.php:1282 -#, fuzzy #| msgid "Column" msgid "Column:" -msgstr "Coluna" +msgstr "Coluna:" #: libraries/DBQbe.class.php:406 -#, fuzzy #| msgid "Sort" msgid "Sort:" -msgstr "Ordenação" +msgstr "Ordenação:" #: libraries/DBQbe.class.php:468 -#, fuzzy #| msgid "Show" msgid "Show:" -msgstr "Mostrar" +msgstr "Mostrar:" #: libraries/DBQbe.class.php:513 -#, fuzzy #| msgid "Criteria" msgid "Criteria:" -msgstr "Critérios" +msgstr "Critérios:" #: libraries/DBQbe.class.php:576 msgid "Add/Delete criteria rows" @@ -2434,14 +2420,13 @@ msgid "Use Tables" msgstr "Usar Tabelas" #: libraries/DBQbe.class.php:653 libraries/DBQbe.class.php:757 -#, fuzzy #| msgid "Or" msgid "Or:" -msgstr "Ou" +msgstr "Ou:" #: libraries/DBQbe.class.php:657 libraries/DBQbe.class.php:742 msgid "And:" -msgstr "" +msgstr "E:" #: libraries/DBQbe.class.php:661 msgid "Ins" @@ -2452,18 +2437,17 @@ msgid "Del" msgstr "Elim" #: libraries/DBQbe.class.php:680 -#, fuzzy #| msgid "Modify" msgid "Modify:" -msgstr "Modificar" +msgstr "Modificar:" #: libraries/DBQbe.class.php:737 msgid "Ins:" -msgstr "" +msgstr "Ins:" #: libraries/DBQbe.class.php:752 msgid "Del:" -msgstr "" +msgstr "Elim:" #: libraries/DBQbe.class.php:1321 #, php-format @@ -2479,10 +2463,12 @@ msgid "" "The server is not responding (or the local server's socket is not correctly " "configured)." msgstr "" +"O servidor não está a responder (ou o socket do servidor local está mal " +"configurado)." #: libraries/DatabaseInterface.class.php:2033 msgid "The server is not responding." -msgstr "" +msgstr "O servidor não está a responder." #: libraries/DatabaseInterface.class.php:2038 msgid "Please check privileges of directory containing database." @@ -2490,7 +2476,7 @@ msgstr "" #: libraries/DatabaseInterface.class.php:2048 msgid "Details…" -msgstr "" +msgstr "Informações…" #: libraries/DbSearch.class.php:98 libraries/DbSearch.class.php:398 msgid "at least one of the words" @@ -2502,7 +2488,7 @@ msgstr "todas as palavras" #: libraries/DbSearch.class.php:100 libraries/DbSearch.class.php:406 msgid "the exact phrase" -msgstr "a frase exata" +msgstr "a frase exacta" #: libraries/DbSearch.class.php:101 libraries/DbSearch.class.php:407 msgid "as regular expression" @@ -12421,10 +12407,9 @@ msgid "FOREIGN KEY relation added" msgstr "Relação FOREIGN KEY adicionada" #: pmd_relation_new.php:84 -#, fuzzy #| msgid "Error: Relation not added." msgid "Error: Relational features are disabled!" -msgstr "Erro: Relação não adicionada." +msgstr "Erro: as características relacionais estão desactivadas!" #: pmd_relation_new.php:100 msgid "Internal relation added" @@ -13045,10 +13030,9 @@ msgid "Choose column to display:" msgstr "Escolha a coluna para mostrar" #: tbl_structure.php:111 -#, fuzzy #| msgid "No rows selected" msgid "No column selected." -msgstr "Nenhum registo(linha) seleccionado" +msgstr "Nenhuma coluna seleccionada." #: tbl_tracking.php:136 #, php-format From 09bbac38160ea5f2abed7ab9a86c93df38b315dd Mon Sep 17 00:00:00 2001 From: Filipe Batista Date: Sat, 7 Sep 2013 11:43:37 +0200 Subject: [PATCH 50/88] Translated using Weblate (Portuguese) Currently translated at 48.6% (1323 of 2720) --- po/pt.po | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/po/pt.po b/po/pt.po index f9a5367ca9..3ff09e4631 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 11:42+0200\n" -"Last-Translator: João Rodrigues \n" +"PO-Revision-Date: 2013-09-07 11:43+0200\n" +"Last-Translator: Filipe Batista \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -14132,10 +14132,9 @@ msgid "Slow launch time" msgstr "" #: libraries/advisory_rules.txt:386 -#, fuzzy #| msgid "long_query_time is set to %d second(s)." msgid "Slow_launch_threads is above 2s" -msgstr "long_query_time está configurado para %d segundo(s)" +msgstr "Slow_launch_threads está acima de 2s" #: libraries/advisory_rules.txt:387 #, fuzzy @@ -14146,10 +14145,10 @@ msgid "" msgstr "Tabelas em tracking" #: libraries/advisory_rules.txt:388 -#, fuzzy, php-format +#, php-format #| msgid "long_query_time is set to %d second(s)." msgid "slow_launch_time is set to %s" -msgstr "long_query_time está configurado para %d segundo(s)" +msgstr "slow_launch_time está definido como %s" #: libraries/advisory_rules.txt:392 #, fuzzy @@ -14253,10 +14252,9 @@ msgid "Is InnoDB disabled?" msgstr "" #: libraries/advisory_rules.txt:432 -#, fuzzy #| msgid "Could not save recent table" msgid "You do not have InnoDB enabled." -msgstr "Não foi possível salvar a tabela recente" +msgstr "Não possui a opção InnoDB abilitada." #: libraries/advisory_rules.txt:433 msgid "InnoDB is usually the better choice for table engines." From 6b6a9bd3da9789d9f1953f77578a18c08ecefee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 11:49:07 +0200 Subject: [PATCH 51/88] Translated using Weblate (Portuguese) Currently translated at 49.0% (1333 of 2720) --- po/pt.po | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/po/pt.po b/po/pt.po index 3ff09e4631..040faefd9a 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 11:43+0200\n" -"Last-Translator: Filipe Batista \n" +"PO-Revision-Date: 2013-09-07 11:49+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -2597,16 +2597,14 @@ msgstr "Fim" #: libraries/DisplayResults.class.php:900 libraries/display_export.lib.php:322 #: tbl_chart.php:245 -#, fuzzy #| msgid "Number of rows per page" msgid "Number of rows:" -msgstr "Número de registos por página" +msgstr "Número de registos:" #: libraries/DisplayResults.class.php:917 -#, fuzzy #| msgid "Mode" msgid "Mode:" -msgstr "Modo" +msgstr "Modo:" #: libraries/DisplayResults.class.php:919 msgid "horizontal" @@ -2730,16 +2728,16 @@ msgstr "" "%sdocumentação%s." #: libraries/DisplayResults.class.php:4865 -#, fuzzy, php-format +#, php-format #| msgid "Showing rows" msgid "Showing rows %1s - %2s" -msgstr "Mostrando registos" +msgstr "A mostrar registos de %1s - %2s" #: libraries/DisplayResults.class.php:4877 -#, fuzzy, php-format +#, php-format #| msgid "total" msgid "%d total" -msgstr "total" +msgstr "%d total" #: libraries/DisplayResults.class.php:4889 libraries/sql.lib.php:1641 #, php-format @@ -2871,10 +2869,9 @@ msgid "Currently running Git revision %1$s from the %2$s branch." msgstr "" #: libraries/Footer.class.php:83 -#, fuzzy #| msgid "Version information" msgid "Git information missing!" -msgstr "Informação de Versão" +msgstr "Falta informação!" #: libraries/Footer.class.php:163 libraries/Footer.class.php:167 #: libraries/Footer.class.php:170 @@ -3160,9 +3157,8 @@ msgid "Temporary data" msgstr "Dados temporários" #: libraries/ServerStatusData.class.php:194 -#, fuzzy msgid "Delayed inserts" -msgstr "Delayed inserts" +msgstr "Inserções atrasadas" #: libraries/ServerStatusData.class.php:195 msgid "Key cache" @@ -3281,16 +3277,14 @@ msgid "Target database `%s` was not found!" msgstr "A base de dados de destino `%s` não foi encontrada!" #: libraries/Table.class.php:1239 -#, fuzzy #| msgid "Invalid database" msgid "Invalid database:" -msgstr "Base de Dados inválida" +msgstr "Base de dados inválida:" #: libraries/Table.class.php:1253 -#, fuzzy #| msgid "Invalid table name" msgid "Invalid table name:" -msgstr "Nome de tabela inválido" +msgstr "Nome da tabela inválido:" #: libraries/Table.class.php:1288 #, php-format @@ -3396,11 +3390,10 @@ msgid "Additional search criteria" msgstr "Critérios de pesquisa adicionais" #: libraries/TableSearch.class.php:1149 -#, fuzzy #| msgid "Do a \"query by example\" (wildcard: \"%\")" msgid "Do a \"query by example\" (wildcard: \"%\") for two different columns" msgstr "" -"Faça uma \"pesquisa por formulário\" (caractere universal: \"%\") para duas " +"Faça uma \"pesquisa por formulário\" (carácter universal: \"%\") para duas " "colunas diferentes" #: libraries/TableSearch.class.php:1159 @@ -3408,9 +3401,8 @@ msgid "Do a \"query by example\" (wildcard: \"%\")" msgstr "Faça uma \"pesquisa por formulário\" (caractere universal: \"%\")" #: libraries/TableSearch.class.php:1210 -#, fuzzy msgid "Browse/Edit the points" -msgstr "Listar/Editar os pontos" +msgstr "Navegar/editar os pontos" #: libraries/TableSearch.class.php:1217 msgid "How to use" @@ -14254,7 +14246,7 @@ msgstr "" #: libraries/advisory_rules.txt:432 #| msgid "Could not save recent table" msgid "You do not have InnoDB enabled." -msgstr "Não possui a opção InnoDB abilitada." +msgstr "Não possui o InnoDB activo." #: libraries/advisory_rules.txt:433 msgid "InnoDB is usually the better choice for table engines." From 3531ad3c17fb85330e0bafa41f051529e334cf80 Mon Sep 17 00:00:00 2001 From: Jonadabe PT Date: Sat, 7 Sep 2013 11:49:24 +0200 Subject: [PATCH 52/88] Translated using Weblate (Portuguese) Currently translated at 49.0% (1334 of 2720) --- po/pt.po | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/po/pt.po b/po/pt.po index 040faefd9a..7ded369329 100644 --- a/po/pt.po +++ b/po/pt.po @@ -5,7 +5,7 @@ msgstr "" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" "PO-Revision-Date: 2013-09-07 11:49+0200\n" -"Last-Translator: João Rodrigues \n" +"Last-Translator: Jonadabe PT \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -3409,10 +3409,9 @@ msgid "How to use" msgstr "Como usar" #: libraries/TableSearch.class.php:1222 -#, fuzzy #| msgid "Reset" msgid "Reset zoom" -msgstr "Limpa" +msgstr "Restaurar ampliação" #: libraries/TableSearch.class.php:1279 #, fuzzy From 35f82918b29027b31f294696b1299381e7867836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 11:59:33 +0200 Subject: [PATCH 53/88] Translated using Weblate (Portuguese) Currently translated at 49.7% (1353 of 2720) --- po/pt.po | 59 ++++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/po/pt.po b/po/pt.po index 7ded369329..a369398aa5 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 11:49+0200\n" -"Last-Translator: Jonadabe PT \n" +"PO-Revision-Date: 2013-09-07 11:59+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -2472,7 +2472,7 @@ msgstr "O servidor não está a responder." #: libraries/DatabaseInterface.class.php:2038 msgid "Please check privileges of directory containing database." -msgstr "" +msgstr "Verifique quais os privilégios que o directório da base de dados tem." #: libraries/DatabaseInterface.class.php:2048 msgid "Details…" @@ -3166,7 +3166,7 @@ msgstr "Chave da cache" #: libraries/ServerStatusData.class.php:196 msgid "Joins" -msgstr "" +msgstr "Junções" #: libraries/ServerStatusData.class.php:198 msgid "Sorting" @@ -3199,16 +3199,16 @@ msgstr "Ver tabelas abertas" #: libraries/ServerStatusData.class.php:227 msgid "Show slave hosts" -msgstr "" +msgstr "Mostrar anfitriões secundários" #: libraries/ServerStatusData.class.php:234 #: libraries/replication_gui.lib.php:49 msgid "Show master status" -msgstr "" +msgstr "Ver estado do principal" #: libraries/ServerStatusData.class.php:237 msgid "Show slave status" -msgstr "" +msgstr "Ver estado do secundário" #: libraries/ServerStatusData.class.php:242 msgid "Flush query cache" @@ -3217,7 +3217,7 @@ msgstr "" #: libraries/ServerStatusData.class.php:261 #: libraries/engines/innodb.lib.php:144 msgid "InnoDB Status" -msgstr "Estado da InnoDB" +msgstr "Estado do InnoDB" #: libraries/ServerStatusData.class.php:368 msgid "Query statistics" @@ -3414,38 +3414,33 @@ msgid "Reset zoom" msgstr "Restaurar ampliação" #: libraries/TableSearch.class.php:1279 -#, fuzzy #| msgid "Replace NULL by" msgid "Replace with:" -msgstr "Substituir NULL por" +msgstr "Substituir por:" #: libraries/TableSearch.class.php:1339 msgid "Find and replace - preview" msgstr "" #: libraries/TableSearch.class.php:1343 -#, fuzzy #| msgid "Column" msgid "Count" -msgstr "Coluna" +msgstr "Contagem" #: libraries/TableSearch.class.php:1344 -#, fuzzy #| msgid "Linestring" msgid "Original string" -msgstr "Segmento de Reta" +msgstr "Segmento original" #: libraries/TableSearch.class.php:1345 -#, fuzzy #| msgid "Relations" msgid "Replaced string" -msgstr "Relações" +msgstr "Segmento de substituição" #: libraries/TableSearch.class.php:1369 -#, fuzzy #| msgid "Replicated" msgid "Replace" -msgstr "Replicado" +msgstr "Substituir" #: libraries/Theme.class.php:170 #, php-format @@ -3476,10 +3471,9 @@ msgid "Theme path not found for theme %s!" msgstr "Encontrado caminho inválido para o tema %s!" #: libraries/Theme_Manager.class.php:370 -#, fuzzy #| msgid "Theme" msgid "Theme:" -msgstr "Tema" +msgstr "Tema:" #: libraries/Types.class.php:297 msgid "" @@ -3720,25 +3714,22 @@ msgid "Numeric" msgstr "" #: libraries/Types.class.php:645 libraries/Types.class.php:979 -#, fuzzy #| msgid "Create an index" msgctxt "date and time types" msgid "Date and time" -msgstr "Criar um novo índice" +msgstr "Data e hora" #: libraries/Types.class.php:654 libraries/Types.class.php:982 -#, fuzzy #| msgid "Linestring" msgctxt "string types" msgid "String" -msgstr "Segmento de Reta " +msgstr "Segmento" #: libraries/Types.class.php:675 -#, fuzzy #| msgid "Total" msgctxt "spatial types" msgid "Spatial" -msgstr "Total" +msgstr "Espacial" #: libraries/Types.class.php:710 msgid "A 4-byte integer, range is -2,147,483,648 to 2,147,483,647" @@ -3788,10 +3779,9 @@ msgid "Max: %s%s" msgstr "Tamanho máximo: %s%s" #: libraries/Util.class.php:642 libraries/sql.lib.php:429 -#, fuzzy #| msgid "SQL query" msgid "SQL query:" -msgstr "Comando SQL" +msgstr "Comando SQL:" #: libraries/Util.class.php:686 libraries/rte/rte_events.lib.php:114 #: libraries/rte/rte_events.lib.php:123 libraries/rte/rte_events.lib.php:140 @@ -3997,7 +3987,6 @@ msgid "Could not load default configuration from: %1$s" msgstr "Não foi possível carregar configuração padrão de: \"%1$s\"" #: libraries/common.inc.php:597 -#, fuzzy #| msgid "" #| "The $cfg['PmaAbsoluteUri'] directive MUST be set in your " #| "configuration file!" @@ -4005,7 +3994,7 @@ msgid "" "The [code]$cfg['PmaAbsoluteUri'][/code] directive MUST be set in your " "configuration file!" msgstr "" -"A directiva $cfg['PmaAbsoluteUri'] TEM que ser definida no " +"A directiva [code]$cfg['PmaAbsoluteUri'][/code] TEM que ser definida no " "ficheiro de configuração!" #: libraries/common.inc.php:630 @@ -4021,10 +4010,10 @@ msgstr "" "configurações." #: libraries/common.inc.php:657 -#, fuzzy, php-format +#, php-format #| msgid "Server" msgid "Server %d" -msgstr "Servidor" +msgstr "Servidor %d" #: libraries/common.inc.php:854 msgid "Invalid authentication method set in configuration:" @@ -4053,17 +4042,15 @@ msgstr "Tecla numérica detectada" #: libraries/config.values.php:49 libraries/config.values.php:65 #: libraries/config.values.php:70 -#, fuzzy #| msgid "Ins" msgid "Icons" -msgstr "Ins" +msgstr "Ícones" #: libraries/config.values.php:50 libraries/config.values.php:66 #: libraries/config.values.php:71 -#, fuzzy #| msgid "Test" msgid "Text" -msgstr "Teste" +msgstr "Texto" #: libraries/config.values.php:51 libraries/config.values.php:59 #: libraries/config.values.php:67 libraries/config.values.php:72 From 9ff821f469518a139d52fb31e7e44174228ed590 Mon Sep 17 00:00:00 2001 From: Jonadabe PT Date: Sat, 7 Sep 2013 12:00:30 +0200 Subject: [PATCH 54/88] Translated using Weblate (Portuguese) Currently translated at 49.8% (1355 of 2720) --- po/pt.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/po/pt.po b/po/pt.po index a369398aa5..a2e3cbb32e 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 11:59+0200\n" -"Last-Translator: João Rodrigues \n" +"PO-Revision-Date: 2013-09-07 12:00+0200\n" +"Last-Translator: Jonadabe PT \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -3225,11 +3225,11 @@ msgstr "Estatísticas de comandos" #: libraries/ServerStatusData.class.php:372 msgid "All status variables" -msgstr "" +msgstr "Todas as variáveis de estado" #: libraries/ServerStatusData.class.php:376 msgid "Monitor" -msgstr "" +msgstr "Monitor" #: libraries/ServerStatusData.class.php:380 msgid "Advisor" From 24791835a587c50465a2d9a57c94711097611412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 12:01:51 +0200 Subject: [PATCH 55/88] Translated using Weblate (Portuguese) Currently translated at 49.9% (1358 of 2720) --- po/pt.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/po/pt.po b/po/pt.po index a2e3cbb32e..1d30ec9507 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 12:00+0200\n" -"Last-Translator: Jonadabe PT \n" +"PO-Revision-Date: 2013-09-07 12:01+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -3233,7 +3233,7 @@ msgstr "Monitor" #: libraries/ServerStatusData.class.php:380 msgid "Advisor" -msgstr "" +msgstr "Conselheiro" #: libraries/StorageEngine.class.php:216 msgid "" @@ -3345,7 +3345,7 @@ msgstr "Pesquisa de tabela" #: libraries/TableSearch.class.php:217 libraries/TableSearch.class.php:1170 msgid "Find and Replace" -msgstr "" +msgstr "Localizar e substituir" #: libraries/TableSearch.class.php:239 libraries/insert_edit.lib.php:1357 msgid "Edit/Insert" @@ -3420,7 +3420,7 @@ msgstr "Substituir por:" #: libraries/TableSearch.class.php:1339 msgid "Find and replace - preview" -msgstr "" +msgstr "Localizar e substituir (pré-visualização)" #: libraries/TableSearch.class.php:1343 #| msgid "Column" From e9056cf5f71903da03d69b52a96b3553190db1aa Mon Sep 17 00:00:00 2001 From: Jonadabe PT Date: Sat, 7 Sep 2013 12:02:34 +0200 Subject: [PATCH 56/88] Translated using Weblate (Portuguese) Currently translated at 50.0% (1359 of 2720) --- po/pt.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/po/pt.po b/po/pt.po index 1d30ec9507..06d7cf96f2 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 12:01+0200\n" -"Last-Translator: João Rodrigues \n" +"PO-Revision-Date: 2013-09-07 12:02+0200\n" +"Last-Translator: Jonadabe PT \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -3558,7 +3558,7 @@ msgstr "Uma data, intervalo suportado é %1$s até %2$s" #: libraries/Types.class.php:323 libraries/Types.class.php:726 #, php-format msgid "A date and time combination, supported range is %1$s to %2$s" -msgstr "" +msgstr "Uma combinação de data e hora, intervalo suportado é %1$s até %2$s" #: libraries/Types.class.php:325 msgid "" From 830de1ff038c4ed181c3473f30a8690bd86523db Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 7 Sep 2013 08:20:26 -0400 Subject: [PATCH 57/88] Fix codestyle --- libraries/config/ConfigFile.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index d1ce2d3a59..825dcd8675 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -128,7 +128,7 @@ class ConfigFile * Sets names of config options which will be placed in config file even if * they are set to their default values (use only full paths) * - * @param array $keys + * @param array $keys the names of the config options * * @return void */ @@ -173,7 +173,8 @@ class ConfigFile * {@link updateWithGlobalConfig()} or reading * by {@link getConfig()} or {@link getConfigArray()} * - * @param array $mapping + * @param array $mapping Contains the mapping of "Server/config options" + * to "Server/1/config options" * * @return void */ @@ -195,7 +196,7 @@ class ConfigFile /** * Sets configuration data (overrides old data) * - * @param array $cfg + * @param array $cfg Configuration options * * @return void */ From 620fc383a68ffb093920f4a939b8419f640624ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 12:12:32 +0200 Subject: [PATCH 58/88] Translated using Weblate (Portuguese) Currently translated at 50.1% (1364 of 2720) --- po/pt.po | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/po/pt.po b/po/pt.po index 06d7cf96f2..2e85d2aa54 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-08-18 06:16-0400\n" -"PO-Revision-Date: 2013-09-07 12:02+0200\n" -"Last-Translator: Jonadabe PT \n" +"PO-Revision-Date: 2013-09-07 12:12+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -3212,7 +3212,7 @@ msgstr "Ver estado do secundário" #: libraries/ServerStatusData.class.php:242 msgid "Flush query cache" -msgstr "" +msgstr "Libertar a cache da consulta" #: libraries/ServerStatusData.class.php:261 #: libraries/engines/innodb.lib.php:144 @@ -3479,18 +3479,24 @@ msgstr "Tema:" msgid "" "A 1-byte integer, signed range is -128 to 127, unsigned range is 0 to 255" msgstr "" +"Um inteiro de 1 byte, a gama atribuída é de -128 a 127, a gama não atribuída " +"é de 0 a 255" #: libraries/Types.class.php:299 msgid "" "A 2-byte integer, signed range is -32,768 to 32,767, unsigned range is 0 to " "65,535" msgstr "" +"Um inteiro de 2 byte, a gama atribuída é de -32,768 a 32,767, a gama não " +"atribuída é de 0 a 65,535" #: libraries/Types.class.php:301 msgid "" "A 3-byte integer, signed range is -8,388,608 to 8,388,607, unsigned range is " "0 to 16,777,215" msgstr "" +"Um inteiro de 3 byte, a gama atribuída é de -8,388,608 a 8,388,607, a gama " +"não atribuída é de 0 a 16,777,215" #: libraries/Types.class.php:303 msgid "" @@ -3503,6 +3509,9 @@ msgid "" "An 8-byte integer, signed range is -9,223,372,036,854,775,808 to " "9,223,372,036,854,775,807, unsigned range is 0 to 18,446,744,073,709,551,615" msgstr "" +"Um inteiro de 8 byte, a gama atribuída é de -9,223,372,036,854,775,808 a " +"9,223,372,036,854,775,807, a gama não atribuída é de 0 a " +"18,446,744,073,709,551,615" #: libraries/Types.class.php:307 libraries/Types.class.php:714 msgid "" @@ -3558,7 +3567,7 @@ msgstr "Uma data, intervalo suportado é %1$s até %2$s" #: libraries/Types.class.php:323 libraries/Types.class.php:726 #, php-format msgid "A date and time combination, supported range is %1$s to %2$s" -msgstr "Uma combinação de data e hora, intervalo suportado é %1$s até %2$s" +msgstr "Uma combinação de data e hora, o intervalo suportado é %1$s até %2$s" #: libraries/Types.class.php:325 msgid "" From e853e65077676e9d8b672c5275f7d80e694e6b5d Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Sat, 7 Sep 2013 23:01:06 +0200 Subject: [PATCH 59/88] fix coding style : closing brace should be on a new line --- libraries/navigation/NavigationHeader.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/navigation/NavigationHeader.class.php b/libraries/navigation/NavigationHeader.class.php index 7c9e8c3a7f..9faf605d7d 100644 --- a/libraries/navigation/NavigationHeader.class.php +++ b/libraries/navigation/NavigationHeader.class.php @@ -85,7 +85,8 @@ class PMA_NavigationHeader // prevent XSS, see PMASA-2013-9 // if link has protocol, allow only http and https if (preg_match('/^[a-z]+:/i', $logo_link) - && ! preg_match('/^https?:/i', $logo_link)) { + && ! preg_match('/^https?:/i', $logo_link) + ) { $logo_link = 'index.php'; } $retval .= ' object->exportHeader(); $result = ob_get_clean(); - $expected = - ''; $html_output .= '
    '; $html_output .= ''; @@ -1995,7 +1997,9 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) ) ) .'" rel="' - . PMA_URL_getCommon(array('checkprivsdb' => $db, 'checkprivstable' => $table)) + . PMA_URL_getCommon( + array('checkprivsdb' => $db, 'checkprivstable' => $table) + ) . '" class="ajax" name="table_specific">' . PMA_Util::getIcon('b_usradd.png') . __('Add user') . ''; @@ -2019,7 +2023,8 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n if (! empty($privMap)) { foreach ($privMap as $current_user => $val) { foreach ($val as $current_host => $current_privileges) { - $html_output .= ''; + $html_output .= ''; // user $html_output .= ''; + $html_output .= '' + . __('Any') . ''; } else { $html_output .= htmlspecialchars($current_user); } @@ -2060,7 +2066,8 @@ function PMA_getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db, $table = n } } else { $html_output .= __('wildcard'). ': ' - . '' . htmlspecialchars($current['Db']) . ''; + . '' . htmlspecialchars($current['Db']) + . ''; } $html_output .= ''; From 5e70597251683ed567c6f6e82a1194d1ddc311d8 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 8 Sep 2013 06:51:58 -0400 Subject: [PATCH 62/88] Fix codestyle --- index.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/index.php b/index.php index 64a808df61..50cabc4fd0 100644 --- a/index.php +++ b/index.php @@ -134,10 +134,8 @@ if ($server > 0 || count($cfg['Servers']) > 1 */ if ($cfg['ServerDefault'] == 0 || (! $cfg['NavigationDisplayServers'] - && (count($cfg['Servers']) > 1 - || ($server == 0 && count($cfg['Servers']) == 1) - ) - ) + && (count($cfg['Servers']) > 1 + || ($server == 0 && count($cfg['Servers']) == 1))) ) { echo '
  • '; include_once 'libraries/select_server.lib.php'; @@ -257,7 +255,9 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { 'li_server_type' ); PMA_printListItem( - __('Server version:') . ' ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT, + __('Server version:') + . ' ' + . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT, 'li_server_version' ); PMA_printListItem( @@ -272,12 +272,12 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { echo '
  • '; echo ' ' . __('Server charset:') . ' ' . ' ' - . ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']] . "\n" - . ' (' . $mysql_charset_map['utf-8'] . ')' . "\n" - . ' ' . "\n" - . '
  • ' . "\n"; - echo ' '; - echo ' '; + . ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']] + . ' (' . $mysql_charset_map['utf-8'] . ')' + . ' ' + . ' ' + . ' ' + . ' '; } if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) { @@ -290,7 +290,10 @@ if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) { if ($server > 0) { $client_version_str = $GLOBALS['dbi']->getClientInfo(); if (preg_match('#\d+\.\d+\.\d+#', $client_version_str) - && in_array($GLOBALS['cfg']['Server']['extension'], array('mysql', 'mysqli')) + && in_array( + $GLOBALS['cfg']['Server']['extension'], + array('mysql', 'mysqli') + ) ) { $client_version_str = 'libmysql - ' . $client_version_str; } @@ -500,7 +503,8 @@ if ($server > 0) { ) { $msg = PMA_Message::notice(__('The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click %shere%s.')); $msg->addParam( - '', + '', false ); $msg->addParam('', false); @@ -587,7 +591,9 @@ if (file_exists('libraries/language_stats.inc.php')) { && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold'] ) { trigger_error( - 'You are using an incomplete translation, please help to make it better by [a@http://www.phpmyadmin.net/home_page/improve.php#translate@_blank]contributing[/a].', + 'You are using an incomplete translation, please help to make it ' + . 'better by [a@http://www.phpmyadmin.net/home_page/improve.php' + . '#translate@_blank]contributing[/a].', E_USER_NOTICE ); } From afb393816dd2fcc8b1ddb402d644d8cbafe6e157 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 8 Sep 2013 07:16:59 -0400 Subject: [PATCH 63/88] bug #4080 Overwrite existing file not obeyed --- ChangeLog | 3 ++- export.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c28a6058f5..a7aeff64d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,8 @@ phpMyAdmin - ChangeLog 4.0.7.0 (not yet released) - bug #3993 Sorting in database overview with statistics doesn't work -- bug Handle the situation where PHP_SELF is not set +- bug Handle the situation where PHP_SELF is not set +- bug #4080 Overwrite existing file not obeyed 4.0.6.0 (2013-09-05) - bug #4036 Call to undefined function mb_detect_encoding (clarify the doc) diff --git a/export.php b/export.php index 065c0fbbd3..937478c683 100644 --- a/export.php +++ b/export.php @@ -502,7 +502,7 @@ if ($save_on_server) { . preg_replace('@[/\\\\]@', '_', $filename); unset($message); if (file_exists($save_filename) - && ((! $quick_export && empty($onserverover)) + && ((! $quick_export && empty($_REQUEST['onserverover'])) || ($quick_export && $_REQUEST['quick_export_onserverover'] != 'saveitover')) ) { From 97b44acfccc6d6ba40b75a393d616bd912860ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Sat, 7 Sep 2013 12:12:31 +0200 Subject: [PATCH 64/88] Translated using Weblate (Portuguese) Currently translated at 51.9% (1354 of 2609) --- po/pt.po | 130 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/po/pt.po b/po/pt.po index 9dc51abdea..03d69fe4c9 100644 --- a/po/pt.po +++ b/po/pt.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.6-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-29 15:07+0200\n" -"PO-Revision-Date: 2013-08-11 13:38+0200\n" -"Last-Translator: Michal Čihař \n" +"PO-Revision-Date: 2013-09-07 12:12+0200\n" +"Last-Translator: João Rodrigues \n" "Language-Team: Portuguese " "\n" "Language: pt\n" @@ -36,9 +36,10 @@ msgid "" "parent window, or your browser's security settings are configured to block " "cross-window updates." msgstr "" -"A janela de destino no seu browser não pode ser actualizada. Talvez tenha " -"fechado a janela que a originou, ou as configurações de segurança do seu " -"browser encontram-se definidas para não permitir actualizações entre janelas." +"Não foi possível actualizar a janela de destino do seu navegador. Talvez " +"você tenha fechado a janela que a originou, ou as configurações de segurança " +"do seu navegador encontram-se definidas para não permitir actualizações " +"entre janelas." #: browse_foreigners.php:182 libraries/Menu.class.php:280 #: libraries/Menu.class.php:365 libraries/Util.class.php:3245 @@ -87,7 +88,7 @@ msgstr "Executar" #: browse_foreigners.php:197 browse_foreigners.php:201 #: libraries/Index.class.php:561 tbl_tracking.php:381 msgid "Keyname" -msgstr "Nome do Índice" +msgstr "Nome da chave" #: browse_foreigners.php:198 browse_foreigners.php:200 #: server_collations.php:39 server_collations.php:51 server_engines.php:42 @@ -98,7 +99,7 @@ msgstr "Descrição" #: browse_foreigners.php:284 browse_foreigners.php:296 #: browse_foreigners.php:312 browse_foreigners.php:324 msgid "Use this value" -msgstr "Usar este valor" +msgstr "Utilizar este valor" #: changelog.php:36 license.php:28 #, php-format @@ -106,8 +107,8 @@ msgid "" "The %s file is not available on this system, please visit www.phpmyadmin.net " "for more information." msgstr "" -"O ficheiro %s não está disponível no seu sistema, por favor visite www." -"phpmyadmin.net para mais informações." +"O ficheiro %s não está disponível no seu sistema. Para mais informações, " +"visite www.phpmyadmin.net." #: db_create.php:74 #, php-format @@ -116,7 +117,7 @@ msgstr "A base de dados %1$s foi criada." #: db_datadict.php:51 libraries/operations.lib.php:36 msgid "Database comment: " -msgstr "Comentário da Base de Dados: " +msgstr "Comentário da base de dados: " #: db_datadict.php:157 libraries/operations.lib.php:808 #: libraries/schema/Pdf_Relation_Schema.class.php:1339 @@ -196,7 +197,7 @@ msgstr "Nulo" #: libraries/tbl_columns_definition_form.inc.php:107 tbl_printview.php:133 #: tbl_tracking.php:327 msgid "Default" -msgstr "Omissão" +msgstr "Predefinido" #: db_datadict.php:174 libraries/plugins/export/ExportHtmlword.class.php:404 #: libraries/plugins/export/ExportLatex.class.php:513 @@ -205,7 +206,7 @@ msgstr "Omissão" #: libraries/schema/Pdf_Relation_Schema.class.php:1371 #: libraries/schema/Pdf_Relation_Schema.class.php:1394 tbl_printview.php:135 msgid "Links to" -msgstr "Links para" +msgstr "Ligações para" #: db_datadict.php:176 db_printview.php:107 #: libraries/config/messages.inc.php:94 libraries/config/messages.inc.php:109 @@ -280,15 +281,15 @@ msgstr "Nenhuma tabela encontrada na base de dados." #: db_export.php:40 libraries/DbSearch.class.php:438 server_export.php:25 msgid "Select All" -msgstr "Selecciona Todas" +msgstr "Seleccionar tudo" #: db_export.php:45 libraries/DbSearch.class.php:441 server_export.php:30 msgid "Unselect All" -msgstr "Limpa Todas as Selecções" +msgstr "Desseleccionar tudo" #: db_operations.php:45 tbl_create.php:22 msgid "The database name is empty!" -msgstr "O nome da base de dados está vazia!" +msgstr "O nome da base de dados está vazio!" #: db_operations.php:129 #, php-format @@ -306,8 +307,8 @@ msgid "" "The phpMyAdmin configuration storage has been deactivated. To find out why " "click %shere%s." msgstr "" -"As configurações do phpMyAdmin para trabalhar com ligações entre Tabelas " -"foram desactivadas. Para saber porquê carregue %shere%s." +"O armazenamento da configuração do phpMyAdmin foi desactivado. Para saber " +"porquê clique %shere%s." #: db_printview.php:99 db_tracking.php:79 db_tracking.php:204 #: libraries/Menu.class.php:207 libraries/config/messages.inc.php:512 @@ -336,7 +337,7 @@ msgstr "Tamanho" #: db_printview.php:159 libraries/plugins/export/ExportSql.class.php:1032 #: libraries/structure.lib.php:731 msgid "in use" -msgstr "em uso" +msgstr "em utilização" #: db_printview.php:185 libraries/Util.class.php:4104 #: libraries/plugins/export/ExportSql.class.php:958 @@ -2389,7 +2390,7 @@ msgstr "todas as palavras" #: libraries/DbSearch.class.php:100 libraries/DbSearch.class.php:406 msgid "the exact phrase" -msgstr "a frase exata" +msgstr "a frase exacta" #: libraries/DbSearch.class.php:101 libraries/DbSearch.class.php:407 msgid "as regular expression" @@ -2623,16 +2624,16 @@ msgstr "" "%sdocumentação%s." #: libraries/DisplayResults.class.php:4927 -#, fuzzy, php-format +#, php-format #| msgid "Showing rows" msgid "Showing rows %1s - %2s" -msgstr "Mostrando registos" +msgstr "A mostrar registos de %1s - %2s" #: libraries/DisplayResults.class.php:4939 -#, fuzzy, php-format +#, php-format #| msgid "total" msgid "%d total" -msgstr "total" +msgstr "%d total" #: libraries/DisplayResults.class.php:4951 sql.php:945 #, php-format @@ -3018,9 +3019,8 @@ msgid "Temporary data" msgstr "Dados temporários" #: libraries/ServerStatusData.class.php:189 -#, fuzzy msgid "Delayed inserts" -msgstr "Delayed inserts" +msgstr "Inserções atrasadas" #: libraries/ServerStatusData.class.php:190 msgid "Key cache" @@ -3028,7 +3028,7 @@ msgstr "Chave da cache" #: libraries/ServerStatusData.class.php:191 msgid "Joins" -msgstr "" +msgstr "Junções" #: libraries/ServerStatusData.class.php:193 msgid "Sorting" @@ -3060,24 +3060,24 @@ msgstr "Ver tabelas abertas" #: libraries/ServerStatusData.class.php:214 msgid "Show slave hosts" -msgstr "" +msgstr "Mostrar anfitriões secundários" #: libraries/ServerStatusData.class.php:218 server_replication.php:170 msgid "Show master status" -msgstr "" +msgstr "Ver estado do principal" #: libraries/ServerStatusData.class.php:221 msgid "Show slave status" -msgstr "" +msgstr "Ver estado do secundário" #: libraries/ServerStatusData.class.php:226 msgid "Flush query cache" -msgstr "" +msgstr "Libertar a cache da consulta" #: libraries/ServerStatusData.class.php:241 #: libraries/engines/innodb.lib.php:148 msgid "InnoDB Status" -msgstr "Estado da InnoDB" +msgstr "Estado do InnoDB" #: libraries/ServerStatusData.class.php:343 msgid "Query statistics" @@ -3085,15 +3085,15 @@ msgstr "Estatísticas de comandos" #: libraries/ServerStatusData.class.php:347 msgid "All status variables" -msgstr "" +msgstr "Todas as variáveis de estado" #: libraries/ServerStatusData.class.php:351 msgid "Monitor" -msgstr "" +msgstr "Monitor" #: libraries/ServerStatusData.class.php:355 msgid "Advisor" -msgstr "" +msgstr "Conselheiro" #: libraries/StorageEngine.class.php:216 msgid "" @@ -3239,11 +3239,10 @@ msgid "Additional search criteria" msgstr "Critérios de pesquisa adicionais" #: libraries/TableSearch.class.php:1115 -#, fuzzy #| msgid "Do a \"query by example\" (wildcard: \"%\")" msgid "Do a \"query by example\" (wildcard: \"%\") for two different columns" msgstr "" -"Faça uma \"pesquisa por formulário\" (caractere universal: \"%\") para duas " +"Faça uma \"pesquisa por formulário\" (carácter universal: \"%\") para duas " "colunas diferentes" #: libraries/TableSearch.class.php:1125 @@ -3251,19 +3250,17 @@ msgid "Do a \"query by example\" (wildcard: \"%\")" msgstr "Faça uma \"pesquisa por formulário\" (caractere universal: \"%\")" #: libraries/TableSearch.class.php:1169 -#, fuzzy msgid "Browse/Edit the points" -msgstr "Listar/Editar os pontos" +msgstr "Navegar/editar os pontos" #: libraries/TableSearch.class.php:1176 msgid "How to use" msgstr "Como usar" #: libraries/TableSearch.class.php:1181 -#, fuzzy #| msgid "Reset" msgid "Reset zoom" -msgstr "Limpa" +msgstr "Restaurar ampliação" #: libraries/Theme.class.php:170 #, php-format @@ -3301,30 +3298,41 @@ msgstr "Tema" msgid "" "A 1-byte integer, signed range is -128 to 127, unsigned range is 0 to 255" msgstr "" +"Um inteiro de 1 byte, a gama atribuída é de -128 a 127, a gama não atribuída " +"é de 0 a 255" #: libraries/Types.class.php:298 msgid "" "A 2-byte integer, signed range is -32,768 to 32,767, unsigned range is 0 to " "65,535" msgstr "" +"Um inteiro de 2 byte, a gama atribuída é de -32,768 a 32,767, a gama não " +"atribuída é de 0 a 65,535" #: libraries/Types.class.php:300 msgid "" "A 3-byte integer, signed range is -8,388,608 to 8,388,607, unsigned range is " "0 to 16,777,215" msgstr "" +"Um inteiro de 3 byte, a gama atribuída é de -8,388,608 a 8,388,607, a gama " +"não atribuída é de 0 a 16,777,215" #: libraries/Types.class.php:302 msgid "" "A 4-byte integer, signed range is -2,147,483,648 to 2,147,483,647, unsigned " "range is 0 to 4,294,967,295." msgstr "" +"Um inteiro de 4 byte, a gama atribuída é de -2,147,483,648 a 2,147,483,647, " +"a gama não atribuída é de 0 a 4,294,967,295." #: libraries/Types.class.php:304 msgid "" "An 8-byte integer, signed range is -9,223,372,036,854,775,808 to " "9,223,372,036,854,775,807, unsigned range is 0 to 18,446,744,073,709,551,615" msgstr "" +"Um inteiro de 8 byte, a gama atribuída é de -9,223,372,036,854,775,808 a " +"9,223,372,036,854,775,807, a gama não atribuída é de 0 a " +"18,446,744,073,709,551,615" #: libraries/Types.class.php:306 libraries/Types.class.php:712 msgid "" @@ -3380,7 +3388,7 @@ msgstr "Uma data, intervalo suportado é %1$s até %2$s" #: libraries/Types.class.php:322 libraries/Types.class.php:724 #, php-format msgid "A date and time combination, supported range is %1$s to %2$s" -msgstr "" +msgstr "Uma combinação de data e hora, o intervalo suportado é %1$s até %2$s" #: libraries/Types.class.php:324 msgid "" @@ -3536,25 +3544,22 @@ msgid "Numeric" msgstr "" #: libraries/Types.class.php:643 libraries/Types.class.php:977 -#, fuzzy #| msgid "Create an index" msgctxt "date and time types" msgid "Date and time" -msgstr "Criar um novo índice" +msgstr "Data e hora" #: libraries/Types.class.php:652 libraries/Types.class.php:980 -#, fuzzy #| msgid "Linestring" msgctxt "string types" msgid "String" -msgstr "Segmento de Reta " +msgstr "Segmento" #: libraries/Types.class.php:673 -#, fuzzy #| msgid "Total" msgctxt "spatial types" msgid "Spatial" -msgstr "Total" +msgstr "Espacial" #: libraries/Types.class.php:708 msgid "A 4-byte integer, range is -2,147,483,648 to 2,147,483,647" @@ -3791,7 +3796,6 @@ msgid "Could not load default configuration from: %1$s" msgstr "Não foi possível carregar configuração padrão de: \"%1$s\"" #: libraries/common.inc.php:615 -#, fuzzy #| msgid "" #| "The $cfg['PmaAbsoluteUri'] directive MUST be set in your " #| "configuration file!" @@ -3799,7 +3803,7 @@ msgid "" "The [code]$cfg['PmaAbsoluteUri'][/code] directive MUST be set in your " "configuration file!" msgstr "" -"A directiva $cfg['PmaAbsoluteUri'] TEM que ser definida no " +"A directiva [code]$cfg['PmaAbsoluteUri'][/code] TEM que ser definida no " "ficheiro de configuração!" #: libraries/common.inc.php:648 @@ -3842,12 +3846,12 @@ msgstr "Tecla numérica detectada" #: libraries/config.values.php:49 libraries/config.values.php:64 #: libraries/config.values.php:69 msgid "Icons" -msgstr "" +msgstr "Ícones" #: libraries/config.values.php:50 libraries/config.values.php:65 #: libraries/config.values.php:70 msgid "Text" -msgstr "" +msgstr "Texto" #: libraries/config.values.php:51 libraries/config.values.php:58 #: libraries/config.values.php:66 libraries/config.values.php:71 @@ -6376,18 +6380,20 @@ msgid "" "The server is not responding (or the local server's socket is not correctly " "configured)." msgstr "" +"O servidor não está a responder (ou o socket do servidor local está mal " +"configurado)." #: libraries/database_interface.lib.php:2079 msgid "The server is not responding." -msgstr "" +msgstr "O servidor não está a responder." #: libraries/database_interface.lib.php:2084 msgid "Please check privileges of directory containing database." -msgstr "" +msgstr "Verifique quais os privilégios que o directório da base de dados tem." #: libraries/database_interface.lib.php:2094 msgid "Details…" -msgstr "" +msgstr "Informações…" #: libraries/dbi/drizzle-wrappers.lib.php:387 msgid "Can't seek in an unbuffered result set" @@ -6523,10 +6529,9 @@ msgid "Dump some row(s)" msgstr "" #: libraries/display_export.lib.php:165 -#, fuzzy #| msgid "Number of rows per page" msgid "Number of rows:" -msgstr "Número de registos por página" +msgstr "Número de registos:" #: libraries/display_export.lib.php:177 msgid "Row to begin at:" @@ -12279,10 +12284,9 @@ msgid "No index defined! Create one below" msgstr "Nenhum indíce definido!" #: tbl_structure.php:125 -#, fuzzy #| msgid "No rows selected" msgid "No column selected." -msgstr "Nenhum registo(linha) seleccionado" +msgstr "Nenhuma coluna seleccionada." #: tbl_structure.php:149 #, php-format @@ -13383,10 +13387,9 @@ msgid "Slow launch time" msgstr "" #: libraries/advisory_rules.txt:386 -#, fuzzy #| msgid "long_query_time is set to %d second(s)." msgid "Slow_launch_threads is above 2s" -msgstr "long_query_time está configurado para %d segundo(s)" +msgstr "Slow_launch_threads está acima de 2s" #: libraries/advisory_rules.txt:387 #, fuzzy @@ -13397,10 +13400,10 @@ msgid "" msgstr "Tabelas em tracking" #: libraries/advisory_rules.txt:388 -#, fuzzy, php-format +#, php-format #| msgid "long_query_time is set to %d second(s)." msgid "slow_launch_time is set to %s" -msgstr "long_query_time está configurado para %d segundo(s)" +msgstr "slow_launch_time está definido como %s" #: libraries/advisory_rules.txt:392 #, fuzzy @@ -13504,10 +13507,9 @@ msgid "Is InnoDB disabled?" msgstr "" #: libraries/advisory_rules.txt:432 -#, fuzzy #| msgid "Could not save recent table" msgid "You do not have InnoDB enabled." -msgstr "Não foi possível salvar a tabela recente" +msgstr "Não possui o InnoDB activo." #: libraries/advisory_rules.txt:433 msgid "InnoDB is usually the better choice for table engines." From 193f06b0afb88885409b21a8288a73e4414ac687 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 8 Sep 2013 07:26:13 -0400 Subject: [PATCH 65/88] Fix merge conflicts --- ChangeLog | 1 + export.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 62f34a1a53..d49b1e6431 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,7 @@ phpMyAdmin - ChangeLog 4.0.7.0 (not yet released) - bug #3993 Sorting in database overview with statistics doesn't work - bug Handle the situation where PHP_SELF is not set +- bug #4080 Overwrite existing file not obeyed 4.0.6.0 (2013-09-05) - bug #4036 Call to undefined function mb_detect_encoding (clarify the doc) diff --git a/export.php b/export.php index a856fd53f3..bfd1a9c177 100644 --- a/export.php +++ b/export.php @@ -503,7 +503,7 @@ if (!defined('TESTSUITE')) { . preg_replace('@[/\\\\]@', '_', $filename); unset($message); if (file_exists($save_filename) - && ((! $quick_export && empty($onserverover)) + && ((! $quick_export && empty($_REQUEST['onserverover'])) || ($quick_export && $_REQUEST['quick_export_onserverover'] != 'saveitover')) ) { From f7bf216e28b209b939071a6a22bedba759df2e81 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sun, 8 Sep 2013 22:58:47 +0530 Subject: [PATCH 66/88] Change the structure of `pma__usergroups` table --- examples/create_tables.sql | 40 ++--------------- examples/create_tables_drizzle.sql | 40 ++--------------- libraries/Menu.class.php | 13 +++--- libraries/server_privileges.lib.php | 67 ++++++++++++++++------------- 4 files changed, 48 insertions(+), 112 deletions(-) diff --git a/examples/create_tables.sql b/examples/create_tables.sql index ca23e71c06..0ac5654dc4 100644 --- a/examples/create_tables.sql +++ b/examples/create_tables.sql @@ -262,43 +262,9 @@ CREATE TABLE IF NOT EXISTS `pma__users` ( CREATE TABLE IF NOT EXISTS `pma__usergroups` ( `usergroup` varchar(64) NOT NULL, - `server_databases` enum('Y','N') NOT NULL DEFAULT 'N', - `server_sql` enum('Y','N') NOT NULL DEFAULT 'N', - `server_status` enum('Y','N') NOT NULL DEFAULT 'N', - `server_rights` enum('Y','N') NOT NULL DEFAULT 'N', - `server_export` enum('Y','N') NOT NULL DEFAULT 'N', - `server_import` enum('Y','N') NOT NULL DEFAULT 'N', - `server_settings` enum('Y','N') NOT NULL DEFAULT 'N', - `server_binlog` enum('Y','N') NOT NULL DEFAULT 'N', - `server_replication` enum('Y','N') NOT NULL DEFAULT 'N', - `server_vars` enum('Y','N') NOT NULL DEFAULT 'N', - `server_charset` enum('Y','N') NOT NULL DEFAULT 'N', - `server_plugins` enum('Y','N') NOT NULL DEFAULT 'N', - `server_engine` enum('Y','N') NOT NULL DEFAULT 'N', - `db_structure` enum('Y','N') NOT NULL DEFAULT 'N', - `db_sql` enum('Y','N') NOT NULL DEFAULT 'N', - `db_search` enum('Y','N') NOT NULL DEFAULT 'N', - `db_qbe` enum('Y','N') NOT NULL DEFAULT 'N', - `db_export` enum('Y','N') NOT NULL DEFAULT 'N', - `db_import` enum('Y','N') NOT NULL DEFAULT 'N', - `db_operation` enum('Y','N') NOT NULL DEFAULT 'N', - `db_privileges` enum('Y','N') NOT NULL DEFAULT 'N', - `db_routines` enum('Y','N') NOT NULL DEFAULT 'N', - `db_events` enum('Y','N') NOT NULL DEFAULT 'N', - `db_triggers` enum('Y','N') NOT NULL DEFAULT 'N', - `db_tracking` enum('Y','N') NOT NULL DEFAULT 'N', - `db_designer` enum('Y','N') NOT NULL DEFAULT 'N', - `table_browse` enum('Y','N') NOT NULL DEFAULT 'N', - `table_structure` enum('Y','N') NOT NULL DEFAULT 'N', - `table_sql` enum('Y','N') NOT NULL DEFAULT 'N', - `table_search` enum('Y','N') NOT NULL DEFAULT 'N', - `table_insert` enum('Y','N') NOT NULL DEFAULT 'N', - `table_export` enum('Y','N') NOT NULL DEFAULT 'N', - `table_import` enum('Y','N') NOT NULL DEFAULT 'N', - `table_operation` enum('Y','N') NOT NULL DEFAULT 'N', - `table_tracking` enum('Y','N') NOT NULL DEFAULT 'N', - `table_triggers` enum('Y','N') NOT NULL DEFAULT 'N', - PRIMARY KEY (`usergroup`) + `tab` varchar(64) NOT NULL, + `allowed` enum('Y','N') NOT NULL DEFAULT 'N', + PRIMARY KEY (`usergroup`,`tab`,`allowed`) ) COMMENT='User groups with configured menu items' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; diff --git a/examples/create_tables_drizzle.sql b/examples/create_tables_drizzle.sql index 4bbb9c34d5..698a15949d 100644 --- a/examples/create_tables_drizzle.sql +++ b/examples/create_tables_drizzle.sql @@ -248,43 +248,9 @@ CREATE TABLE IF NOT EXISTS `pma__users` ( CREATE TABLE IF NOT EXISTS `pma__usergroups` ( `usergroup` varchar(64) NOT NULL, - `server_databases` enum('Y','N') NOT NULL DEFAULT 'N', - `server_sql` enum('Y','N') NOT NULL DEFAULT 'N', - `server_status` enum('Y','N') NOT NULL DEFAULT 'N', - `server_rights` enum('Y','N') NOT NULL DEFAULT 'N', - `server_export` enum('Y','N') NOT NULL DEFAULT 'N', - `server_import` enum('Y','N') NOT NULL DEFAULT 'N', - `server_settings` enum('Y','N') NOT NULL DEFAULT 'N', - `server_binlog` enum('Y','N') NOT NULL DEFAULT 'N', - `server_replication` enum('Y','N') NOT NULL DEFAULT 'N', - `server_vars` enum('Y','N') NOT NULL DEFAULT 'N', - `server_charset` enum('Y','N') NOT NULL DEFAULT 'N', - `server_plugins` enum('Y','N') NOT NULL DEFAULT 'N', - `server_engine` enum('Y','N') NOT NULL DEFAULT 'N', - `db_structure` enum('Y','N') NOT NULL DEFAULT 'N', - `db_sql` enum('Y','N') NOT NULL DEFAULT 'N', - `db_search` enum('Y','N') NOT NULL DEFAULT 'N', - `db_qbe` enum('Y','N') NOT NULL DEFAULT 'N', - `db_export` enum('Y','N') NOT NULL DEFAULT 'N', - `db_import` enum('Y','N') NOT NULL DEFAULT 'N', - `db_operation` enum('Y','N') NOT NULL DEFAULT 'N', - `db_privileges` enum('Y','N') NOT NULL DEFAULT 'N', - `db_routines` enum('Y','N') NOT NULL DEFAULT 'N', - `db_events` enum('Y','N') NOT NULL DEFAULT 'N', - `db_triggers` enum('Y','N') NOT NULL DEFAULT 'N', - `db_tracking` enum('Y','N') NOT NULL DEFAULT 'N', - `db_designer` enum('Y','N') NOT NULL DEFAULT 'N', - `table_browse` enum('Y','N') NOT NULL DEFAULT 'N', - `table_structure` enum('Y','N') NOT NULL DEFAULT 'N', - `table_sql` enum('Y','N') NOT NULL DEFAULT 'N', - `table_search` enum('Y','N') NOT NULL DEFAULT 'N', - `table_insert` enum('Y','N') NOT NULL DEFAULT 'N', - `table_export` enum('Y','N') NOT NULL DEFAULT 'N', - `table_import` enum('Y','N') NOT NULL DEFAULT 'N', - `table_operation` enum('Y','N') NOT NULL DEFAULT 'N', - `table_tracking` enum('Y','N') NOT NULL DEFAULT 'N', - `table_triggers` enum('Y','N') NOT NULL DEFAULT 'N', - PRIMARY KEY (`usergroup`) + `tab` varchar(64) NOT NULL, + `allowed` enum('Y','N') NOT NULL DEFAULT 'N', + PRIMARY KEY (`usergroup`,`tab`,`allowed`) ) COMMENT='User groups with configured menu items' COLLATE utf8_bin; diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php index 4c4ee18ebf..3894b557ab 100644 --- a/libraries/Menu.class.php +++ b/libraries/Menu.class.php @@ -140,19 +140,16 @@ class PMA_Menu $userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']); - $sql_query = "SELECT * FROM " . $groupTable - . " WHERE `usergroup` = (SELECT usergroup FROM " + $sql_query = "SELECT `tab` FROM " . $groupTable + . " WHERE `allowed` = 'N' AND `usergroup` = (SELECT usergroup FROM " . $userTable . " WHERE `username` = '" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "')"; $result = PMA_queryAsControlUser($sql_query, false); if ($result) { - $row = $GLOBALS['dbi']->fetchAssoc($result); - foreach ($allowedTabs as $key => $tab) { - $colName = $level . '_' . $key; - if (isset($row[$colName]) && $row[$colName] == 'N') { - unset($allowedTabs[$key]); - } + while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { + $tabName = substr($row['tab'], strpos($row['tab'], '_') + 1); + unset($allowedTabs[$tabName]); } } } diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index fc9199a4e9..4e1d82538a 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -500,7 +500,7 @@ function PMA_getHtmlToChooseUserGroup($username) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']); $userGroups = array(); - $sql_query = "SELECT `usergroup` FROM " . $groupTable; + $sql_query = "SELECT DISTINCT `usergroup` FROM " . $groupTable; $result = PMA_queryAsControlUser($sql_query, false); if ($result) { while ($row = $GLOBALS['dbi']->fetchRow($result)) { @@ -3871,18 +3871,26 @@ function PMA_getHtmlForUserGroupsTable() $html_output .= ''; $odd = true; + $userGroups = array(); while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { + $groupName = $row['usergroup']; + if (! isset($userGroups[$groupName])) { + $userGroups[$groupName] = array(); + } + $userGroups[$groupName][$row['tab']] = $row['allowed']; + } + foreach ($userGroups as $groupName => $tabs) { $html_output .= ''; - $html_output .= '' . htmlspecialchars($row['usergroup']) . ''; - $html_output .= '' . _getAllowedTabNames($row, 'server') . ''; - $html_output .= '' . _getAllowedTabNames($row, 'db') . ''; - $html_output .= '' . _getAllowedTabNames($row, 'table') . ''; + $html_output .= '' . htmlspecialchars($groupName) . ''; + $html_output .= '' . _getAllowedTabNames($tabs, 'server') . ''; + $html_output .= '' . _getAllowedTabNames($tabs, 'db') . ''; + $html_output .= '' . _getAllowedTabNames($tabs, 'table') . ''; $html_output .= ''; $html_output .= '' @@ -3891,7 +3899,7 @@ function PMA_getHtmlForUserGroupsTable() $html_output .= '' @@ -3901,7 +3909,7 @@ function PMA_getHtmlForUserGroupsTable() . ' href="server_user_groups.php' . PMA_URL_getCommon( array( - 'deleteUserGroup' => 1, 'userGroup' => $row['usergroup'] + 'deleteUserGroup' => 1, 'userGroup' => $groupName ) ) . '">' @@ -4028,8 +4036,9 @@ function PMA_getHtmlToEditUserGroup($userGroup = null) . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; $result = PMA_queryAsControlUser($sql_query, false); if ($result) { - $row = $GLOBALS['dbi']->fetchAssoc($result); - foreach ($row as $key => $value) { + while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { + $key = $row['tab']; + $value = $row['allowed']; if (substr($key, 0, 7) == 'server_' && $value == 'Y') { $allowedTabs['server'][] = substr($key, 7); } elseif (substr($key, 0, 3) == 'db_' && $value == 'Y') { @@ -4105,31 +4114,29 @@ function PMA_editUserGroup($userGroup, $new = false) $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); - $cols = ""; - $vals = ""; - $colsNvals = ""; + if (! $new) { + $sql_query = "DELETE FROM " . $groupTable + . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "';"; + PMA_queryAsControlUser($sql_query, true); + } + + $sql_query = "INSERT INTO " . $groupTable + . "(`usergroup`, `tab`, `allowed`)" + . " VALUES "; + $first = true; foreach ($tabs as $tabGroupName => $tabGroup) { foreach ($tabs[$tabGroupName] as $tab => $tabName) { - $colName = $tabGroupName . '_' . $tab; - $cols .= "," . PMA_Util::backquote($colName); - if (isset($_REQUEST[$colName])&& $_REQUEST[$colName] == 'Y') { - $vals .= ",'Y'"; - $colsNvals .= "," . PMA_Util::backquote($colName) . "='Y'"; - } else { - $vals .= ",'N'"; - $colsNvals .= "," . PMA_Util::backquote($colName) . "='N'"; + if (! $first) { + $sql_query .= ", "; } + $tabName = $tabGroupName . '_' . $tab; + $allowed = isset($_REQUEST[$tabName]) && $_REQUEST[$tabName] == 'Y'; + $sql_query .= "('" . $userGroup . "', '" . $tabName . "', '" + . ($allowed ? "Y" : "N") . "')"; + $first = false; } } - if ($new) { - $sql_query = "INSERT INTO " . $groupTable - . "(`usergroup`" . $cols . ")" - . " VALUES" - . " ('" . PMA_Util::sqlAddSlashes($userGroup) . "'" . $vals . ")"; - } else { - $sql_query = "UPDATE " . $groupTable . " SET " . substr($colsNvals, 1) - . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; - } + $sql_query .= ";"; PMA_queryAsControlUser($sql_query, true); } From 99257dea7cc54b366e3d21d036d7f1469b6e958c Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Sun, 8 Sep 2013 23:34:22 +0530 Subject: [PATCH 67/88] Fix failing tests --- .../libraries/PMA_server_user_groups_test.php | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/test/libraries/PMA_server_user_groups_test.php b/test/libraries/PMA_server_user_groups_test.php index c15bf08034..88653c6cc0 100644 --- a/test/libraries/PMA_server_user_groups_test.php +++ b/test/libraries/PMA_server_user_groups_test.php @@ -99,12 +99,8 @@ class PMA_ServerUserGroupsTest extends PHPUnit_Framework_TestCase $this->returnValue( array( 'usergroup' => 'usergroup', - 'server_sql' => 'Y', - 'server_databases' => 'N', - 'db_sql' => 'Y', - 'db_structure' => 'N', - 'table_sql' => 'Y', - 'table_browse' => 'N' + 'tab' => 'server_sql', + 'allowed' => 'Y' ) ) ); @@ -122,33 +118,33 @@ class PMA_ServerUserGroupsTest extends PHPUnit_Framework_TestCase $html ); $url_tag = ''; $output .= PMA_getHtmlForColumnElement( - '', $val_ordered_current_equals_data, + '', $val_ordered_current_equals_data, $key_ordered_current_key, $val_ordered_current_val, $val_ordered_current_val_title, $field ); $output .= PMA_getHtmlForColumnElement( 'class="nowrap"', $val_ordered_current_equals_data, - $val_ordered_current_key, $val_ordered_current_val_title, $field + $key_ordered_current_key, $val_ordered_current_key, + $val_ordered_current_val_title, $field ); $output .= ''; } // end while @@ -195,7 +197,7 @@ function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignDat * @return string */ function PMA_getHtmlForColumnElement($cssClass, $currentEqualsData, $currentKey, - $currentTitle, $field + $currentVal, $currentTitle, $field ){ $output = '' . ($currentEqualsData ? '' : '') @@ -206,13 +208,13 @@ function PMA_getHtmlForColumnElement($cssClass, $currentEqualsData, $currentKey, . '" onclick="formupdate(\'' . md5($field) . '\', \'' . PMA_jsFormat($currentKey, false) . '\'); return false;">'; - if ($cssClass == '') { - $currentKey = htmlspecialchars($currentKey); + if ($cssClass !== '') { + $output .= htmlspecialchars($currentKey); + } else { + $output .= $currentVal; } - $output .= $currentKey . '' - . ($currentEqualsData ? '' : '') - . ''; + $output .= '' . ($currentEqualsData ? '' : '') . ''; return $output; } From a9983882b9c30c5a003bfd0ad8b2645b152eed4b Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Mon, 9 Sep 2013 07:10:06 +0530 Subject: [PATCH 69/88] Move user group related functions to a lib file of its own --- libraries/server_privileges.lib.php | 388 +----------------- libraries/server_user_groups.lib.php | 355 ++++++++++++++++ libraries/server_users.lib.php | 55 +++ server_privileges.php | 1 + server_user_groups.php | 3 +- .../libraries/PMA_server_user_groups_test.php | 2 +- 6 files changed, 415 insertions(+), 389 deletions(-) create mode 100644 libraries/server_user_groups.lib.php create mode 100644 libraries/server_users.lib.php diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 62a9e7d6b8..66e3595285 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1929,7 +1929,7 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table) list($list_of_privileges, $list_of_compared_privileges) = PMA_getListOfPrivilegesAndComparedPrivileges(); - $sql_query + $sql_query = "(" . " SELECT " . $list_of_privileges . ", '*' AS `Db`, 'g' AS `Type`" . " FROM `mysql`.`user`" @@ -3801,349 +3801,6 @@ function PMA_getHtmlForDisplayUserOverviewPage($pmaThemeImage, $text_dir) return $html_output; } -/** - * Return HTML to list the users belonging to a given user group - * - * @param string $userGroup user group name - * - * @return HTML to list the users belonging to a given user group - */ -function PMA_getHtmlForListingUsersofAGroup($userGroup) -{ - $html_output = '

    ' - . sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup)) - . '

    '; - - $usersTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) - . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']); - $sql_query = "SELECT `username` FROM " . $usersTable - . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; - $result = PMA_queryAsControlUser($sql_query, false); - if ($result) { - if ($GLOBALS['dbi']->numRows($result) == 0) { - $html_output .= '

    ' - . __('No users were found belonging to this user group.') - . '

    '; - } else { - $html_output .= '' - . '' - . ''; - $i = 0; - while ($row = $GLOBALS['dbi']->fetchRow($result)) { - $i++; - $html_output .= '' - . '' - . '' - . ''; - } - $html_output .= '' - . '
    #' . __('User') . '
    ' . $i . ' ' . htmlspecialchars($row[0]) . '
    '; - } - } - $GLOBALS['dbi']->freeResult($result); - return $html_output; -} - -/** - * Returns HTML for the 'user groups' table - * - * @return string HTML for the 'user groups' table - */ -function PMA_getHtmlForUserGroupsTable() -{ - $tabs = PMA_Util::getMenuTabList(); - - $html_output = '

    ' . __('User groups') . '

    '; - $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) - . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); - $sql_query = "SELECT * FROM " . $groupTable . " ORDER BY `usergroup` ASC"; - $result = PMA_queryAsControlUser($sql_query, false); - - if ($result && $GLOBALS['dbi']->numRows($result)) { - $html_output .= '
    '; - $html_output .= PMA_URL_getHiddenInputs(); - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - - $odd = true; - $userGroups = array(); - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - $groupName = $row['usergroup']; - if (! isset($userGroups[$groupName])) { - $userGroups[$groupName] = array(); - } - $userGroups[$groupName][$row['tab']] = $row['allowed']; - } - foreach ($userGroups as $groupName => $tabs) { - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - $html_output .= ''; - - $html_output .= ''; - - $html_output .= ''; - - $odd = ! $odd; - } - - $html_output .= ''; - $html_output .= '
    ' - . __('User group') . '' . __('Server level tabs') . '' . __('Database level tabs') . '' . __('Table level tabs') . '' . __('Action') . '
    ' . htmlspecialchars($groupName) . '' . _getAllowedTabNames($tabs, 'server') . '' . _getAllowedTabNames($tabs, 'db') . '' . _getAllowedTabNames($tabs, 'table') . ''; - $html_output .= '' - . PMA_Util::getIcon('b_usrlist.png', __('View users')) . ''; - $html_output .= '  '; - $html_output .= '' - . PMA_Util::getIcon('b_edit.png', __('Edit')) . ''; - $html_output .= '  '; - $html_output .= '' - . PMA_Util::getIcon('b_drop.png', __('Delete')) . ''; - $html_output .= '
    '; - $html_output .= '
    '; - } - $GLOBALS['dbi']->freeResult($result); - - $html_output .= '
    '; - $html_output .= '' - . PMA_Util::getIcon('b_usradd.png') - . __('Add user group') . ''; - $html_output .= '
    '; - - return $html_output; -} - -/** - * Returns the list of allowed menu tab names - * based on a data row from usergroup table. - * - * @param array $row row of usergroup table - * @param string $level 'server', 'db' or 'table' - * - * @return string comma seperated list of allowed menu tab names - */ -function _getAllowedTabNames($row, $level) -{ - $tabNames = array(); - $tabs = PMA_Util::getMenuTabList($level); - foreach ($tabs as $tab => $tabName) { - if (! isset($row[$level . '_' . $tab]) - || $row[$level . '_' . $tab] == 'Y' - ) { - $tabNames[] = $tabName; - } - } - return implode(', ', $tabNames); -} - -/** - * Deletes a user group - * - * @param string $userGroup user group name - * - * @return void - */ -function PMA_deleteUserGroup($userGroup) -{ - $userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) - . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']); - $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) - . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); - $sql_query = "DELETE FROM " . $userTable - . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; - PMA_queryAsControlUser($sql_query, true); - $sql_query = "DELETE FROM " . $groupTable - . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; - PMA_queryAsControlUser($sql_query, true); -} - -/** - * Returns HTML for add/edit user group dialog - * - * @param string $userGroup name of the user group in case of editing - * - * @return string HTML for add/edit user group dialog - */ -function PMA_getHtmlToEditUserGroup($userGroup = null) -{ - $html_output = ''; - if ($userGroup == null) { - $html_output .= '

    ' . __('Add user group') . '

    '; - } else { - $html_output .= '

    ' - . sprintf(__('Edit user group: \'%s\''), htmlspecialchars($userGroup)) - . '

    '; - } - - $html_output .= '
    '; - $urlParams = array(); - if ($userGroup != null) { - $urlParams['userGroup'] = $userGroup; - $urlParams['editUserGroupSubmit'] = '1'; - } else { - $urlParams['addUserGroupSubmit'] = '1'; - } - $html_output .= PMA_URL_getHiddenInputs($urlParams); - - $html_output .= '
    '; - $html_output .= '' . __('User group menu assignments') - . '   ' - . '' - . '' - . ''; - - if ($userGroup == null) { - $html_output .= ''; - $html_output .= ''; - $html_output .= '
    '; - } - - $allowedTabs = array( - 'server' => array(), - 'db' => array(), - 'table' => array() - ); - if ($userGroup != null) { - $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) - . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); - $sql_query = "SELECT * FROM " . $groupTable - . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; - $result = PMA_queryAsControlUser($sql_query, false); - if ($result) { - while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { - $key = $row['tab']; - $value = $row['allowed']; - if (substr($key, 0, 7) == 'server_' && $value == 'Y') { - $allowedTabs['server'][] = substr($key, 7); - } elseif (substr($key, 0, 3) == 'db_' && $value == 'Y') { - $allowedTabs['db'][] = substr($key, 3); - } elseif (substr($key, 0, 6) == 'table_' && $value == 'Y') { - $allowedTabs['table'][] = substr($key, 6); - } - } - } - $GLOBALS['dbi']->freeResult($result); - } - - $html_output .= _getTabList( - __('Server-level tabs'), 'server', $allowedTabs['server'] - ); - $html_output .= _getTabList( - __('Database-level tabs'), 'db', $allowedTabs['db'] - ); - $html_output .= _getTabList( - __('Table-level tabs'), 'table', $allowedTabs['table'] - ); - - $html_output .= '
    '; - - $html_output .= ''; - - return $html_output; -} - -/** - * Returns HTML for checkbox groups to choose - * tabs of 'server', 'db' or 'table' levels. - * - * @param string $title title of the checkbox group - * @param string $level 'server', 'db' or 'table' - * @param array $selected array of selected allowed tabs - * - * @return string HTML for checkbox groups - */ -function _getTabList($title, $level, $selected) -{ - $tabs = PMA_Util::getMenuTabList($level); - $html_output = '
    '; - $html_output .= '' . $title . ''; - foreach ($tabs as $tab => $tabName) { - $html_output .= '
    '; - $html_output .= ''; - $html_output .= ''; - $html_output .= '
    '; - } - $html_output .= '
    '; - return $html_output; -} - -/** - * Add/update a user group with allowed menu tabs. - * - * @param string $userGroup user group name - * @param boolean $new whether this is a new user group - * - * @return void - */ -function PMA_editUserGroup($userGroup, $new = false) -{ - $tabs = PMA_Util::getMenuTabList(); - $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) - . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); - - if (! $new) { - $sql_query = "DELETE FROM " . $groupTable - . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "';"; - PMA_queryAsControlUser($sql_query, true); - } - - $sql_query = "INSERT INTO " . $groupTable - . "(`usergroup`, `tab`, `allowed`)" - . " VALUES "; - $first = true; - foreach ($tabs as $tabGroupName => $tabGroup) { - foreach ($tabs[$tabGroupName] as $tab => $tabName) { - if (! $first) { - $sql_query .= ", "; - } - $tabName = $tabGroupName . '_' . $tab; - $allowed = isset($_REQUEST[$tabName]) && $_REQUEST[$tabName] == 'Y'; - $sql_query .= "('" . $userGroup . "', '" . $tabName . "', '" - . ($allowed ? "Y" : "N") . "')"; - $first = false; - } - } - $sql_query .= ";"; - PMA_queryAsControlUser($sql_query, true); -} - /** * Get HTML snippet for display user properties * @@ -4520,47 +4177,4 @@ function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password) $sql_query ); } - -/** - * Get HTML for secondary level menu tabs on 'Users' page - * - * @param string $selfUrl Url of the file - * - * @return string HTML for secondary level menu tabs on 'Users' page - */ -function PMA_getHtmlForSubMenusOnUsersPage($selfUrl) -{ - $url_params = PMA_URL_getCommon(); - $items = array( - array( - 'name' => __('Users overview'), - 'url' => 'server_privileges.php', - 'specific_params' => '&viewing_mode=server' - ), - array( - 'name' => __('User groups'), - 'url' => 'server_user_groups.php', - 'specific_params' => '' - ) - ); - - $retval = '
      '; - foreach ($items as $item) { - $class = ''; - if ($item['url'] === $selfUrl) { - $class = ' class="tabactive"'; - } - $retval .= '
    • '; - $retval .= ''; - $retval .= $item['name']; - $retval .= ''; - $retval .= '
    • '; - } - $retval .= '
    '; - $retval .= '
    '; - - return $retval; -} ?> diff --git a/libraries/server_user_groups.lib.php b/libraries/server_user_groups.lib.php new file mode 100644 index 0000000000..7085b60b4a --- /dev/null +++ b/libraries/server_user_groups.lib.php @@ -0,0 +1,355 @@ +' + . sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup)) + . ''; + + $usersTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) + . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']); + $sql_query = "SELECT `username` FROM " . $usersTable + . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; + $result = PMA_queryAsControlUser($sql_query, false); + if ($result) { + if ($GLOBALS['dbi']->numRows($result) == 0) { + $html_output .= '

    ' + . __('No users were found belonging to this user group.') + . '

    '; + } else { + $html_output .= '' + . '' + . ''; + $i = 0; + while ($row = $GLOBALS['dbi']->fetchRow($result)) { + $i++; + $html_output .= '' + . '' + . '' + . ''; + } + $html_output .= '' + . '
    #' . __('User') . '
    ' . $i . ' ' . htmlspecialchars($row[0]) . '
    '; + } + } + $GLOBALS['dbi']->freeResult($result); + return $html_output; +} + +/** + * Returns HTML for the 'user groups' table + * + * @return string HTML for the 'user groups' table + */ +function PMA_getHtmlForUserGroupsTable() +{ + $tabs = PMA_Util::getMenuTabList(); + + $html_output = '

    ' . __('User groups') . '

    '; + $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) + . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); + $sql_query = "SELECT * FROM " . $groupTable . " ORDER BY `usergroup` ASC"; + $result = PMA_queryAsControlUser($sql_query, false); + + if ($result && $GLOBALS['dbi']->numRows($result)) { + $html_output .= ''; + $html_output .= PMA_URL_getHiddenInputs(); + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + + $odd = true; + $userGroups = array(); + while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { + $groupName = $row['usergroup']; + if (! isset($userGroups[$groupName])) { + $userGroups[$groupName] = array(); + } + $userGroups[$groupName][$row['tab']] = $row['allowed']; + } + foreach ($userGroups as $groupName => $tabs) { + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + $html_output .= ''; + + $html_output .= ''; + + $html_output .= ''; + + $odd = ! $odd; + } + + $html_output .= ''; + $html_output .= '
    ' + . __('User group') . '' . __('Server level tabs') . '' . __('Database level tabs') . '' . __('Table level tabs') . '' . __('Action') . '
    ' . htmlspecialchars($groupName) . '' . _getAllowedTabNames($tabs, 'server') . '' . _getAllowedTabNames($tabs, 'db') . '' . _getAllowedTabNames($tabs, 'table') . ''; + $html_output .= '' + . PMA_Util::getIcon('b_usrlist.png', __('View users')) . ''; + $html_output .= '  '; + $html_output .= '' + . PMA_Util::getIcon('b_edit.png', __('Edit')) . ''; + $html_output .= '  '; + $html_output .= '' + . PMA_Util::getIcon('b_drop.png', __('Delete')) . ''; + $html_output .= '
    '; + $html_output .= '
    '; + } + $GLOBALS['dbi']->freeResult($result); + + $html_output .= '
    '; + $html_output .= '' + . PMA_Util::getIcon('b_usradd.png') + . __('Add user group') . ''; + $html_output .= '
    '; + + return $html_output; +} + +/** + * Returns the list of allowed menu tab names + * based on a data row from usergroup table. + * + * @param array $row row of usergroup table + * @param string $level 'server', 'db' or 'table' + * + * @return string comma seperated list of allowed menu tab names + */ +function _getAllowedTabNames($row, $level) +{ + $tabNames = array(); + $tabs = PMA_Util::getMenuTabList($level); + foreach ($tabs as $tab => $tabName) { + if (! isset($row[$level . '_' . $tab]) + || $row[$level . '_' . $tab] == 'Y' + ) { + $tabNames[] = $tabName; + } + } + return implode(', ', $tabNames); +} + +/** + * Deletes a user group + * + * @param string $userGroup user group name + * + * @return void + */ +function PMA_deleteUserGroup($userGroup) +{ + $userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) + . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']); + $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) + . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); + $sql_query = "DELETE FROM " . $userTable + . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; + PMA_queryAsControlUser($sql_query, true); + $sql_query = "DELETE FROM " . $groupTable + . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; + PMA_queryAsControlUser($sql_query, true); +} + +/** + * Returns HTML for add/edit user group dialog + * + * @param string $userGroup name of the user group in case of editing + * + * @return string HTML for add/edit user group dialog + */ +function PMA_getHtmlToEditUserGroup($userGroup = null) +{ + $html_output = ''; + if ($userGroup == null) { + $html_output .= '

    ' . __('Add user group') . '

    '; + } else { + $html_output .= '

    ' + . sprintf(__('Edit user group: \'%s\''), htmlspecialchars($userGroup)) + . '

    '; + } + + $html_output .= '
    '; + $urlParams = array(); + if ($userGroup != null) { + $urlParams['userGroup'] = $userGroup; + $urlParams['editUserGroupSubmit'] = '1'; + } else { + $urlParams['addUserGroupSubmit'] = '1'; + } + $html_output .= PMA_URL_getHiddenInputs($urlParams); + + $html_output .= '
    '; + $html_output .= '' . __('User group menu assignments') + . '   ' + . '' + . '' + . ''; + + if ($userGroup == null) { + $html_output .= ''; + $html_output .= ''; + $html_output .= '
    '; + } + + $allowedTabs = array( + 'server' => array(), + 'db' => array(), + 'table' => array() + ); + if ($userGroup != null) { + $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) + . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); + $sql_query = "SELECT * FROM " . $groupTable + . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "'"; + $result = PMA_queryAsControlUser($sql_query, false); + if ($result) { + while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { + $key = $row['tab']; + $value = $row['allowed']; + if (substr($key, 0, 7) == 'server_' && $value == 'Y') { + $allowedTabs['server'][] = substr($key, 7); + } elseif (substr($key, 0, 3) == 'db_' && $value == 'Y') { + $allowedTabs['db'][] = substr($key, 3); + } elseif (substr($key, 0, 6) == 'table_' && $value == 'Y') { + $allowedTabs['table'][] = substr($key, 6); + } + } + } + $GLOBALS['dbi']->freeResult($result); + } + + $html_output .= _getTabList( + __('Server-level tabs'), 'server', $allowedTabs['server'] + ); + $html_output .= _getTabList( + __('Database-level tabs'), 'db', $allowedTabs['db'] + ); + $html_output .= _getTabList( + __('Table-level tabs'), 'table', $allowedTabs['table'] + ); + + $html_output .= '
    '; + + $html_output .= ''; + + return $html_output; +} + +/** + * Returns HTML for checkbox groups to choose + * tabs of 'server', 'db' or 'table' levels. + * + * @param string $title title of the checkbox group + * @param string $level 'server', 'db' or 'table' + * @param array $selected array of selected allowed tabs + * + * @return string HTML for checkbox groups + */ +function _getTabList($title, $level, $selected) +{ + $tabs = PMA_Util::getMenuTabList($level); + $html_output = '
    '; + $html_output .= '' . $title . ''; + foreach ($tabs as $tab => $tabName) { + $html_output .= '
    '; + $html_output .= ''; + $html_output .= ''; + $html_output .= '
    '; + } + $html_output .= '
    '; + return $html_output; +} + +/** + * Add/update a user group with allowed menu tabs. + * + * @param string $userGroup user group name + * @param boolean $new whether this is a new user group + * + * @return void + */ +function PMA_editUserGroup($userGroup, $new = false) +{ + $tabs = PMA_Util::getMenuTabList(); + $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) + . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']); + + if (! $new) { + $sql_query = "DELETE FROM " . $groupTable + . " WHERE `usergroup`='" . PMA_Util::sqlAddSlashes($userGroup) . "';"; + PMA_queryAsControlUser($sql_query, true); + } + + $sql_query = "INSERT INTO " . $groupTable + . "(`usergroup`, `tab`, `allowed`)" + . " VALUES "; + $first = true; + foreach ($tabs as $tabGroupName => $tabGroup) { + foreach ($tabs[$tabGroupName] as $tab => $tabName) { + if (! $first) { + $sql_query .= ", "; + } + $tabName = $tabGroupName . '_' . $tab; + $allowed = isset($_REQUEST[$tabName]) && $_REQUEST[$tabName] == 'Y'; + $sql_query .= "('" . $userGroup . "', '" . $tabName . "', '" + . ($allowed ? "Y" : "N") . "')"; + $first = false; + } + } + $sql_query .= ";"; + PMA_queryAsControlUser($sql_query, true); +} +?> \ No newline at end of file diff --git a/libraries/server_users.lib.php b/libraries/server_users.lib.php new file mode 100644 index 0000000000..57d59b7657 --- /dev/null +++ b/libraries/server_users.lib.php @@ -0,0 +1,55 @@ + __('Users overview'), + 'url' => 'server_privileges.php', + 'specific_params' => '&viewing_mode=server' + ), + array( + 'name' => __('User groups'), + 'url' => 'server_user_groups.php', + 'specific_params' => '' + ) + ); + + $retval = '
      '; + foreach ($items as $item) { + $class = ''; + if ($item['url'] === $selfUrl) { + $class = ' class="tabactive"'; + } + $retval .= '
    • '; + $retval .= ''; + $retval .= $item['name']; + $retval .= ''; + $retval .= '
    • '; + } + $retval .= '
    '; + $retval .= '
    '; + + return $retval; +} +?> \ No newline at end of file diff --git a/server_privileges.php b/server_privileges.php index 410f82b03e..4500f439b2 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -30,6 +30,7 @@ $scripts->addFile('server_privileges.js'); if ((isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'server') && $GLOBALS['cfgRelation']['menuswork'] ) { + include_once 'libraries/server_users.lib.php'; $response->addHTML('
    '); $response->addHTML(PMA_getHtmlForSubMenusOnUsersPage('server_privileges.php')); } diff --git a/server_user_groups.php b/server_user_groups.php index 65900a87ef..7236a91615 100644 --- a/server_user_groups.php +++ b/server_user_groups.php @@ -7,7 +7,8 @@ */ require_once 'libraries/common.inc.php'; -require_once 'libraries/server_privileges.lib.php'; +require_once 'libraries/server_users.lib.php'; +require_once 'libraries/server_user_groups.lib.php'; PMA_getRelationsParam(); if (! $GLOBALS['cfgRelation']['menuswork']) { diff --git a/test/libraries/PMA_server_user_groups_test.php b/test/libraries/PMA_server_user_groups_test.php index 88653c6cc0..aac165c3e4 100644 --- a/test/libraries/PMA_server_user_groups_test.php +++ b/test/libraries/PMA_server_user_groups_test.php @@ -12,7 +12,7 @@ require_once 'libraries/relation.lib.php'; /* * Include to test. */ -require_once 'libraries/server_privileges.lib.php'; +require_once 'libraries/server_user_groups.lib.php'; /** * Tests for server_user_groups.lib.php From 99e4afadcf54d0b35215abc61861862f6ef1a3a6 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Mon, 9 Sep 2013 07:33:59 +0530 Subject: [PATCH 70/88] Fix tests --- test/libraries/PMA_server_privileges_test.php | 36 ----------- test/libraries/PMA_server_users_test.php | 62 +++++++++++++++++++ 2 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 test/libraries/PMA_server_users_test.php diff --git a/test/libraries/PMA_server_privileges_test.php b/test/libraries/PMA_server_privileges_test.php index ffc6a5ee78..dd41e1bac9 100644 --- a/test/libraries/PMA_server_privileges_test.php +++ b/test/libraries/PMA_server_privileges_test.php @@ -739,42 +739,6 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase ); } - /** - * Test for PMA_getHtmlForSubMenusOnUsersPage - * - * @return void - */ - public function testPMAGetHtmlForSubMenusOnUsersPage() - { - $html = PMA_getHtmlForSubMenusOnUsersPage('server_privileges.php'); - - //validate 1: topmenu2 - $this->assertContains( - '