' : '')
+ . $GLOBALS['strPrivileges'] . "\n"
+ . '' . "\n"
+ . $GLOBALS['strNoPrivileges'] . "\n";
+ require_once './libraries/footer.inc.php';
+}
+
+/**
+ * Generates a condition on the user name
+ *
+ * @param string the user's initial
+ * @return string the generated condition
+ */
+function PMA_RangeOfUsers($initial = '') {
+// strtolower() is used because the User field
+// might be BINARY, so LIKE would be case sensitive
+ if (!empty($initial)) {
+ $ret = " WHERE " . PMA_convert_using('User')
+ . " LIKE " . PMA_convert_using($initial . '%', 'quoted')
+ . " OR ". PMA_convert_using('User')
+ . " LIKE " . PMA_convert_using(strtolower($initial) . '%', 'quoted');
+ } else {
+ $ret = '';
+ }
+ return $ret;
+} // end function
+
+/**
+ * Extracts the privilege information of a priv table row
+ *
+ * @param array $row the row
+ * @param boolean $enableHTML add tag with tooltips
+ *
+ * @global ressource $user_link the database connection
+ *
+ * @return array
+ */
+function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
+{
+ $grants = array(
+ array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']),
+ array('Insert_priv', 'INSERT', $GLOBALS['strPrivDescInsert']),
+ array('Update_priv', 'UPDATE', $GLOBALS['strPrivDescUpdate']),
+ array('Delete_priv', 'DELETE', $GLOBALS['strPrivDescDelete']),
+ array('Create_priv', 'CREATE', $GLOBALS['strPrivDescCreateDb']),
+ array('Drop_priv', 'DROP', $GLOBALS['strPrivDescDropDb']),
+ array('Reload_priv', 'RELOAD', $GLOBALS['strPrivDescReload']),
+ array('Shutdown_priv', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']),
+ array('Process_priv', 'PROCESS', $GLOBALS['strPrivDescProcess' . ((!empty($row) && isset($row['Super_priv'])) || (empty($row) && isset($GLOBALS['Super_priv'])) ? '4' : '3')]),
+ array('File_priv', 'FILE', $GLOBALS['strPrivDescFile']),
+ array('References_priv', 'REFERENCES', $GLOBALS['strPrivDescReferences']),
+ array('Index_priv', 'INDEX', $GLOBALS['strPrivDescIndex']),
+ array('Alter_priv', 'ALTER', $GLOBALS['strPrivDescAlter']),
+ array('Show_db_priv', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']),
+ array('Super_priv', 'SUPER', $GLOBALS['strPrivDescSuper']),
+ array('Create_tmp_table_priv', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']),
+ array('Lock_tables_priv', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']),
+ array('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']),
+ array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']),
+ array('Create_view_priv', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']),
+ // for table privs:
+ array('Create View_priv', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']),
+ array('Show_view_priv', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']),
+ // for table privs:
+ array('Show view_priv', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']),
+ array('Create_routine_priv', 'CREATE ROUTINE', $GLOBALS['strPrivDescCreateRoutine']),
+ array('Alter_routine_priv', 'ALTER ROUTINE', $GLOBALS['strPrivDescAlterRoutine']),
+ array('Create_user_priv', 'CREATE USER', $GLOBALS['strPrivDescCreateUser'])
+ );
+ if (PMA_MYSQL_INT_VERSION >= 40002 && PMA_MYSQL_INT_VERSION <50003) {
+ $grants[] = array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']);
+ } else {
+ $grants[] = array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute5']);
+ }
+
+ if (!empty($row) && isset($row['Table_priv'])) {
+ $res = PMA_DBI_query(
+ 'SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';',
+ $GLOBALS['userlink']);
+ $row1 = PMA_DBI_fetch_assoc($res);
+ PMA_DBI_free_result($res);
+ $av_grants = explode ('\',\'', substr($row1['Type'], 5, strlen($row1['Type']) - 7));
+ unset($row1);
+ $users_grants = explode(',', $row['Table_priv']);
+ foreach ($av_grants as $current_grant) {
+ $row[$current_grant . '_priv'] = in_array($current_grant, $users_grants) ? 'Y' : 'N';
+ }
+ unset($current_grant);
+ unset($av_grants);
+ unset($users_grants);
+ }
+ $privs = array();
+ $allPrivileges = TRUE;
+ foreach ($grants as $current_grant) {
+ if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) {
+ if ((!empty($row) && $row[$current_grant[0]] == 'Y') || (empty($row) && ($GLOBALS[$current_grant[0]] == 'Y' || (is_array($GLOBALS[$current_grant[0]]) && count($GLOBALS[$current_grant[0]]) == $GLOBALS['column_count'] && empty($GLOBALS[$current_grant[0] . '_none']))))) {
+ if ($enableHTML) {
+ $privs[] = '' . $current_grant[1] . '';
+ } else {
+ $privs[] = $current_grant[1];
+ }
+ } elseif (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
+ if ($enableHTML) {
+ $priv_string = '' . $current_grant[1] . '';
+ } else {
+ $priv_string = $current_grant[1];
+ }
+ $privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
+ } else {
+ $allPrivileges = FALSE;
+ }
+ }
+ }
+ if (empty($privs)) {
+ if ($enableHTML) {
+ $privs[] = 'USAGE';
+ } else {
+ $privs[] = 'USAGE';
+ }
+ } elseif ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
+ if ($enableHTML) {
+ $privs = array('ALL PRIVILEGES');
+ } else {
+ $privs = array('ALL PRIVILEGES');
+ }
+ }
+ return $privs;
+} // end of the 'PMA_extractPrivInfo()' function
+
+
+/**
+ * Displays on which column(s) a table-specific privilege is granted
+ */
+function PMA_display_column_privs($spaces, $columns, $row, $name_for_select, $priv_for_header, $name, $name_for_dfn, $name_for_current) {
+
+ echo $spaces . '