diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 3ef12987bb..52a60bb5e7 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -1735,10 +1735,16 @@ function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename) * * @return array $db_rights database rights */ -function PMA_getUserSpecificRights($dbname, $tables, $user_host_condition) +function PMA_getUserSpecificRights($tables, $user_host_condition) { $common_functions = PMA_CommonFunctions::getInstance(); + if (PMA_isValid($_REQUEST['pred_dbname'])) { + $dbname = $_REQUEST['pred_dbname']; + unset($pred_dbname); + } elseif (PMA_isValid($_REQUEST['dbname'])) { + $dbname = $_REQUEST['dbname']; + } if (! isset($dbname)) { $tables_to_search_for_users = array( 'tables_priv', 'columns_priv', @@ -1917,9 +1923,14 @@ function PMA_getHtmlForDisplayUserRightsInRows($db_rights, $link_edit, * * @return array $html_output, $found_rows */ -function PMA_getTableForDisplayAllTableSpecificRights($username, $hostname, - $dbname, $link_edit, $link_revoke +function PMA_getTableForDisplayAllTableSpecificRights($username, $hostname + , $link_edit, $link_revoke ) { + if (PMA_isValid($_REQUEST['pred_dbname'])) { + $dbname = $_REQUEST['pred_dbname']; + } elseif (PMA_isValid($_REQUEST['dbname'])) { + $dbname = $_REQUEST['dbname']; + } // table header $html_output = PMA_generate_common_hidden_inputs('', '') . '' . "\n" @@ -1955,7 +1966,7 @@ function PMA_getTableForDisplayAllTableSpecificRights($username, $hostname, * no db name given, so we want all privs for the given user * db name was given, so we want all user specific rights for this db */ - $db_rights = PMA_getUserSpecificRights($dbname, $tables, $user_host_condition); + $db_rights = PMA_getUserSpecificRights($tables, $user_host_condition); ksort($db_rights); @@ -2524,4 +2535,243 @@ function PMA_getHtmlForExportUserDefinition($username, $hostname) return array($title, $export); } +function PMA_getAddUserHtmlFieldset($conditional_class) +{ + return '
' . "\n"; +} + +function PMA_getHtmlHeaderForDisplayUserProperties($dbname_is_wildcard) +{ + $html_output = 'mysql_upgrade command'
+ . '(mysql_fix_privilege_tables on older systems)'
+ . ' that should be included in your MySQL server distribution'
+ . ' to solve this problem!';
+ $html_output .= PMA_Message::rawError($raw)->getDisplay();
+ }
+ } else {
+ $db_rights = PMA_getDbRightsForUserOverview();
+ // for all initials, even non A-Z
+ $array_initials = array();
+
+ /**
+ * Displays the initials
+ * In an Ajax request, we don't need to show this.
+ * Also not necassary if there is less than 20 privileges
+ */
+ if ($GLOBALS['is_ajax_request'] != true && PMA_DBI_num_rows($res) > 20 ) {
+ $html_output .= PMA_getHtmlForDisplayTheInitials($array_initials, $conditional_class);
+ }
+
+ /**
+ * Display the user overview
+ * (if less than 50 users, display them immediately)
+ */
+ if (isset($_REQUEST['initial']) || isset($_REQUEST['showall']) || PMA_DBI_num_rows($res) < 50) {
+ $html_output .= PMA_displayUserOverview($res, $db_rights, $link_edit,$pmaThemeImage,
+ $text_dir, $conditional_class, $link_export, $link_export_all
+ );
+ } else {
+ $html_output .= PMA_getAddUserHtmlFieldset($conditional_class);
+ } // end if (display overview)
+
+ if ($GLOBALS['is_ajax_request']) {
+ exit;
+ }
+
+ $flushnote = new PMA_Message(
+ __('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.')
+ , PMA_Message::NOTICE
+ );
+ $flushnote->addParam(
+ '',
+ false);
+ $flushnote->addParam('', false);
+ $html_output .= $flushnote->getDisplay();
+
+ return $html_output;
+ }
+}
+
+function PMA_getHtmlForDisplayUserPropeties($dbname_is_wildcard,$url_dbname,
+ $random_n, $username, $hostname, $link_edit, $link_revoke
+) {
+ if (PMA_isValid($_REQUEST['pred_dbname'])) {
+ $dbname = $_REQUEST['pred_dbname'];
+ } elseif (PMA_isValid($_REQUEST['dbname'])) {
+ $dbname = $_REQUEST['dbname'];
+ }
+ if (PMA_isValid($_REQUEST['pred_tablename'])) {
+ $tablename = $_REQUEST['pred_tablename'];
+ } elseif (PMA_isValid($_REQUEST['tablename'])) {
+ $tablename = $_REQUEST['tablename'];
+ }
+ $html_output = PMA_getHtmlHeaderForDisplayUserProperties($dbname_is_wildcard);
+
+ $sql = "SELECT '1' FROM `mysql`.`user`"
+ . " WHERE `User` = '" . PMA_CommonFunctions::getInstance()->sqlAddSlashes($username) . "'"
+ . " AND `Host` = '" . PMA_CommonFunctions::getInstance()->sqlAddSlashes($hostname) . "';";
+
+ $user_does_not_exists = (bool) ! PMA_DBI_fetch_value($sql);
+
+ if ($user_does_not_exists) {
+ $html_output .= PMA_Message::error(
+ __('The selected user was not found in the privilege table.')
+ )->getDisplay();
+ $html_output .= PMA_getHtmlForDisplayLoginInformationFields();
+ //exit;
+ }
+
+ $html_output .= '' . "\n";
+
+ if (! isset($tablename) && empty($dbname_is_wildcard)) {
+
+ // no table name was given, display all table specific rights
+ // but only if $dbname contains no wildcards
+
+ $html_output .= '' . "\n";
+ }
+
+ // Provide a line with links to the relevant database and table
+ if (isset($dbname) && empty($dbname_is_wildcard)) {
+ $html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
+
+ }
+
+ if (! isset($dbname) && ! $user_does_not_exists) {
+ //change login information
+ include_once 'libraries/display_change_password.lib.php';
+ $html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname);
+ }
+
+ return $html_output;
+}
?>
diff --git a/server_privileges.php b/server_privileges.php
index 845570db21..3c2e765df0 100644
--- a/server_privileges.php
+++ b/server_privileges.php
@@ -621,203 +621,23 @@ if (isset($_REQUEST['export'])
if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs))) {
if (! isset($username)) {
// No username is given --> display the overview
- echo 'mysql_upgrade command'
- . '(mysql_fix_privilege_tables on older systems)'
- . ' that should be included in your MySQL server distribution'
- . ' to solve this problem!';
- PMA_Message::rawError($raw)->display();
- }
- } else {
- $db_rights = PMA_getDbRightsForUserOverview();
- // for all initials, even non A-Z
- $array_initials = array();
-
- /**
- * Displays the initials
- * In an Ajax request, we don't need to show this.
- * Also not necassary if there is less than 20 privileges
- */
- if ($GLOBALS['is_ajax_request'] != true && PMA_DBI_num_rows($res) > 20 ) {
- echo PMA_getHtmlForDisplayTheInitials($array_initials, $conditional_class);
- }
-
- /**
- * Display the user overview
- * (if less than 50 users, display them immediately)
- */
- if (isset($initial) || isset($showall) || PMA_DBI_num_rows($res) < 50) {
-
- echo PMA_displayUserOverview($res, $db_rights, $link_edit,
- $pmaThemeImage, $text_dir, $conditional_class, $link_export, $link_export_all
- );
- } else {
-
- unset ($row);
- echo ' ' . "\n";
- } // end if (display overview)
-
- if ($GLOBALS['is_ajax_request']) {
- exit;
- }
-
- $flushnote = new PMA_Message(
- __('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.')
- , PMA_Message::NOTICE
- );
- $flushnote->addParam(
- '',
- false);
- $flushnote->addParam('', false);
- $flushnote->display();
- }
-
-
+ $response->addHTML(
+ PMA_getHtmlForDiplayUserOverviewPage($link_edit, $pmaThemeImage,
+ $text_dir, $conditional_class, $link_export, $link_export_all
+ )
+ );
} else {
-
// A user was selected -> display the user's properties
// In an Ajax request, prevent cached values from showing
if ($GLOBALS['is_ajax_request'] == true) {
header('Cache-Control: no-cache');
}
-
- echo '