From 9b5b648e65535c01ed78b77194cc119deb7a5196 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 8 Dec 2008 17:39:30 +0000 Subject: [PATCH] patch #1821619 [privileges] Extra back reference when editing table-specific privileges --- ChangeLog | 12 +++--- libraries/common.lib.php | 23 +---------- libraries/config.default.php | 22 +++++++++++ server_privileges.php | 76 ++++++++++++++++++++++++------------ 4 files changed, 82 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 487063d10..62046b4fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,11 +7,13 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA 3.2.0.0 (not yet released) - [core] better support for vendor customisation (based on what Debian needs) -- rfe #2127987 warn when session.gc_maxlifetime is less than cookie validity -- rfe #2100910 configurable default charset for import -- rfe #1913541 link to InnoDB status when error 1005 occurs -- rfe #1927189 strip ` from column names on import -- rfe #1821619 LeftFrameDBSeparator can be an array ++ rfe #2127987 warn when session.gc_maxlifetime is less than cookie validity ++ rfe #2100910 configurable default charset for import ++ rfe #1913541 link to InnoDB status when error 1005 occurs ++ rfe #1927189 strip ` from column names on import ++ rfe #1821619 LeftFrameDBSeparator can be an array ++ patch #1821619 [privileges] Extra back reference when editing table-specific + privileges, thanks to Herman van Rink - helmo 3.1.2.0 (not yet released) - bug #1253252 [display] Can't NULL a column with relation defined diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 74d0a1d48..8f4f76264 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2667,31 +2667,12 @@ function PMA_duplicateFirstNewline($string){ * get the action word corresponding to a script name * in order to display it as a title in navigation panel * - * @uses switch() * @uses $GLOBALS * @param string a valid value for $cfg['LeftDefaultTabTable'] * or $cfg['DefaultTabTable'] + * or $cfg['DefaultTabDatabase'] */ function PMA_getTitleForTarget($target) { - switch ($target) { - case 'tbl_structure.php': - $message = 'strStructure'; - break; - case 'tbl_sql.php': - $message = 'strSQL'; - break; - case 'tbl_select.php': - $message = 'strSearch'; - break; - case 'tbl_change.php': - $message = 'strInsert'; - break; - case 'sql.php': - $message = 'strBrowse'; - break; - default: - $message = ''; - } - return $GLOBALS[$message]; + return $GLOBALS[$GLOBALS['cfg']['DefaultTabTranslationMapping'][$target]]; } ?> diff --git a/libraries/config.default.php b/libraries/config.default.php index c35257bd0..13d3e4a6f 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -962,6 +962,28 @@ $cfg['DefaultTabDatabase'] = 'db_structure.php'; */ $cfg['DefaultTabTable'] = 'sql.php'; +/** + * Mapping between script filenames and translation keys + * + * Lookup can be performed by PMA_getTitleForTarget() + * + * @global string $cfg['DefaultTabTranslationMapping'] + */ +$cfg['DefaultTabTranslationMapping'] = array( + + // Values for $cfg['DefaultTabTable'] + 'tbl_structure.php' => 'strStructure', + 'tbl_sql.php' => 'strSQL', + 'tbl_select.php' => 'strSearch', + 'tbl_change.php' => 'strInsert', + 'sql.php' => 'strBrowse', + + // Values for $cfg['DefaultTabDatabase'] + 'db_structure.php' => 'strStructure', + 'db_sql.php' => 'strSQL', + 'db_search.php' => 'strSearch', + 'db_operations.php' => 'strOperations', +); /******************************************************************************* * Export defaults diff --git a/server_privileges.php b/server_privileges.php index 5d937a065..3cf9b267c 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -1543,32 +1543,39 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo '

' . "\n" . PMA_getIcon('b_usredit.png') - . $GLOBALS['strUser'] . ' \'' - . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) - . '\'' . "\n"; - if (isset($dbname)) { - if ($dbname_is_wildcard) { - echo ' - ' . $GLOBALS['strDatabases']; - } else { - echo ' - ' . $GLOBALS['strDatabase']; - } - $url_dbname = urlencode(str_replace('\_', '_', $dbname)); - echo ' ' - . htmlspecialchars($dbname) . '' . "\n"; - if (isset($tablename)) { - echo ' - ' . $GLOBALS['strTable'] . ' ' . htmlspecialchars($tablename) . '' - . "\n"; - } - unset($url_dbname); - } - echo ' : ' . $GLOBALS['strEditPrivileges'] . '

' . "\n"; + . $GLOBALS['strEditPrivileges'] . ': ' + . $GLOBALS['strUser'] ; + if (isset($dbname)) { + echo ' \'' + . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) + . '\'' . "\n"; + $url_dbname = urlencode(str_replace('\_', '_', $dbname)); + + if (isset($dbname)) { + if (isset($tablename)) { + echo ' - ' . ($dbname_is_wildcard ? $GLOBALS['strDatabases'] : $GLOBALS['strDatabase'] ) + . ' ' . htmlspecialchars($dbname) . ''; + echo ' - ' . $GLOBALS['strTable'] . ' ' . htmlspecialchars($tablename) . ''; + } else { + echo ' - ' . $GLOBALS['strDatabase'] . ' ' . htmlspecialchars($dbname) . ''; + } + } + + } else { + echo ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) + . '\'' . "\n"; + + } + if (isset($dbname)) { + echo '' . "\n"; + } + + $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . PMA_sqlAddslashes($username) . "'" . " AND `Host` = '" . PMA_sqlAddslashes($hostname) . "';"; @@ -1865,6 +1872,25 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . ' ' . '' . "\n" . '' . "\n"; + + } + + // Provide a line with links to the relevant database and table + if (isset($dbname)) { + echo '[ ' . $GLOBALS['strDatabase'] + . ' ' + . htmlspecialchars($dbname) . ': ' . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . " ]\n"; + + if (isset($tablename)) { + echo ' [ ' . $GLOBALS['strTable'] . ' ' . htmlspecialchars($tablename) . ': ' + . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) + . " ]\n"; + } + unset($url_dbname); } if (! isset($dbname) && ! $user_does_not_exists) {