diff --git a/ChangeLog b/ChangeLog index 1f712d524..54cf33c45 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-10-23 Marc Delisle + * server_privileges.php: top index for user initials + 2004-10-22 Alexander M. Turek * lang/english-*.inc.php: Grammar fix. diff --git a/server_privileges.php b/server_privileges.php index 5c2e6c621..4a56b03f5 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -913,7 +913,15 @@ if (empty($adduser) && empty($checkprivs)) { . '' . "\n"; $oldPrivTables = FALSE; if (PMA_MYSQL_INT_VERSION >= 40002) { - $res = PMA_DBI_try_query('SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '\'\', \'N\', \'Y\') AS \'Password\', `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv` FROM `user` ORDER BY `User` ASC, `Host` ASC;'); + $sql_query = 'SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '\'\', \'N\', \'Y\') AS \'Password\', `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv` FROM `user` '; + + if (isset($initial)) { + $sql_query .= " WHERE `User` LIKE '" . $initial . "%'"; + } + + $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;'; + $res = PMA_DBI_try_query($sql_query); + if (!$res) { // the query failed! This may have two reasons: // - the user has not enough privileges @@ -922,7 +930,15 @@ if (empty($adduser) && empty($checkprivs)) { } } if (empty($res) || PMA_MYSQL_INT_VERSION < 40002) { - $res = PMA_DBI_try_query('SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '\'\', \'N\', \'Y\') AS \'Password\', `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Index_priv`, `Alter_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv` FROM `user` ORDER BY `User` ASC, `Host` ASC;'); + $sql_query = 'SELECT `User`, `Host`, IF(`Password` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . '\'\', \'N\', \'Y\') AS \'Password\', `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Index_priv`, `Alter_priv`, `Create_priv`, `Drop_priv`, `Grant_priv`, `References_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv` FROM `user`'; + + if (isset($initial)) { + $sql_query .= " WHERE `User` LIKE '" . $initial . "%'"; + } + + $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;'; + $res = PMA_DBI_try_query($sql_query); + if (!$res) { // the query failed! This may have two reasons: // - the user has not enough privileges @@ -943,95 +959,141 @@ if (empty($adduser) && empty($checkprivs)) { . ' Please run the script mysql_fix_privilege_tables that should be included in your MySQL server distribution to solve this problem!' . "\n" . '
' . "\n"; } - echo '
' . "\n" - . PMA_generate_common_hidden_inputs('', '', 1) - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . ($cfg['PropertiesIconic'] ? '' : '') . "\n"; - echo ' ' . "\n"; - $useBgcolorOne = TRUE; - for ($i = 0; $row = PMA_DBI_fetch_assoc($res); $i++) { - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; - $privs = PMA_extractPrivInfo($row, TRUE); - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; - $useBgcolorOne = !$useBgcolorOne; + + /** + * Displays the initials + */ + + // for all initials, even non A-Z + $array_initials = array(); + + // initialize to FALSE the letters A-Z + for ($letter_counter = 1; $letter_counter < 27; $letter_counter++) { + $array_initials[chr($letter_counter + 64)] = FALSE; } - @PMA_DBI_free_result($res); - unset($res); - unset ($row); - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . '
 ' . $strUser . '  ' . $strHost . '  ' . $strPassword . '  ' . $strGlobalPrivileges . '  ' . $strGrantOption . '  ' . $strAction . '
' . htmlspecialchars($row['Host']) . '' . ($row['Password'] == 'Y' ? $strYes : '' . $strNo . '') . '' . "\n" - . ' ' . join(',' . "\n" . ' ', $privs) . "\n" - . ' ' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . ''; - if ($GLOBALS['cfg']['PropertiesIconic']) { - echo '' . $strEditPrivileges . ''; - } else { - echo $strEditPrivileges; - } - echo '
' . "\n" - . '  ' . $strEnglishPrivileges . ' ' . "\n" - . '
' . "\n" - . ' ' . $strWithChecked . '' . "\n" - . ' ' . $strCheckAll . '' . "\n" - . '  / ' . "\n" - . ' ' . $strUncheckAll . '' . "\n" - . '
' . "\n" - . '
' . "\n" - . ' ' . "\n" . ' ' - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" . ' ' . "\n" - . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" - . ' ' . $strAddUser . '' . "\n" - . ' ' . "\n" - . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" - . ' ' . $strRemoveSelectedUsers . '' . "\n" - . '
 
 
 
 ' . "\n" - . '
' - . ' ' . "\n" - . '
' . "\n" - . '
' . "\n" - . '
' . "\n" - . ' ' . sprintf($strFlushPrivilegesNote, '', '') . "\n" - . '
' . "\n"; + + $initials = PMA_DBI_try_query('SELECT DISTINCT UPPER(LEFT(`User`,1)) FROM `user` ORDER BY `User` ASC'); + while (list($tmp_initial) = PMA_DBI_fetch_row($initials)) { + $array_initials[$tmp_initial] = TRUE; + } + + // Display the initials, which can be any characters, not + // just letters. For letters A-Z, we add the non-used letters + // as greyed out. + + uksort($array_initials, "strnatcasecmp"); + reset($array_initials); + + echo ''; + foreach ($array_initials as $tmp_initial => $initial_was_found) { + + if ($initial_was_found) { + echo '' . "\n"; + } else { + echo ''; + } + } + echo '' . "\n"; + echo '
' . $tmp_initial . '' . $tmp_initial . '[' . $strShowAll . ']
'; + + /** + * Displays the user overview + */ + + if (isset($initial) || isset($showall) || PMA_DBI_num_rows($res) < 50) { + + echo '
' . "\n" + . PMA_generate_common_hidden_inputs('', '', 1) + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . ($cfg['PropertiesIconic'] ? '' : '') . "\n"; + echo ' ' . "\n"; + $useBgcolorOne = TRUE; + for ($i = 0; $row = PMA_DBI_fetch_assoc($res); $i++) { + echo ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n"; + $privs = PMA_extractPrivInfo($row, TRUE); + echo ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n"; + $useBgcolorOne = !$useBgcolorOne; + } + @PMA_DBI_free_result($res); + unset($res); + unset ($row); + echo ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . '
 ' . $strUser . '  ' . $strHost . '  ' . $strPassword . '  ' . $strGlobalPrivileges . '  ' . $strGrantOption . '  ' . $strAction . '
' . htmlspecialchars($row['Host']) . '' . ($row['Password'] == 'Y' ? $strYes : '' . $strNo . '') . '' . "\n" + . ' ' . join(',' . "\n" . ' ', $privs) . "\n" + . ' ' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . ''; + if ($GLOBALS['cfg']['PropertiesIconic']) { + echo '' . $strEditPrivileges . ''; + } else { + echo $strEditPrivileges; + } + echo '
' . "\n" + . '  ' . $strEnglishPrivileges . ' ' . "\n" + . '
' . "\n" + . ' ' . $strWithChecked . '' . "\n" + . ' ' . $strCheckAll . '' . "\n" + . '  / ' . "\n" + . ' ' . $strUncheckAll . '' . "\n" + . '
' . "\n" + . '
' . "\n" + . ' ' . "\n" . ' ' + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n" . ' ' . "\n" + . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" + . ' ' . $strAddUser . '' . "\n" + . ' ' . "\n" + . '
' : 'width="20" nowrap="nowrap" align="center" valign="top">' ). "\n" + . ' ' . $strRemoveSelectedUsers . '' . "\n" + . '
 
 
 
 ' . "\n" + . '
' + . ' ' . "\n" + . '
' . "\n" + . '
' . "\n" + . '
' . "\n" + . ' ' . sprintf($strFlushPrivilegesNote, '', '') . "\n" + . '
' . "\n"; + } // end if (display overview) } } else { + // A user was selected -> display the user's properties + echo '

' . "\n" . ($cfg['PropertiesIconic'] ? '' : '' ) . ' ' . $strUser . ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'' . "\n";