From 3084c9f1c81abb7cccac46196afcbfc9a2f1654b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Sat, 10 May 2014 15:39:22 +0200 Subject: [PATCH] Share code for formatting privilege MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/server_privileges.lib.php | 37 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 6fc3a28e12..00c26911ad 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -89,6 +89,24 @@ function PMA_rangeOfUsers($initial = '') return $ret; } // end function +/** + * Formats privilege name for a display + * + * @param array $privilege Privilege information + * @param boolean $html Whether to use HTML + * + * @return string + */ +function PMA_formatPrivilege($privilege, $html) +{ + if ($html) { + return '' + . $privilege[1] . ''; + } else { + return $privilege[1]; + } +} + /** * Parses priliveges into an array, it modifies the array * @@ -162,22 +180,12 @@ function PMA_extractPrivInfo($row = null, $enableHTML = false, $tablePrivs = fal && count($GLOBALS[$current_grant[0]]) == $_REQUEST['column_count'] && empty($GLOBALS[$current_grant[0] . '_none'])))) ) { - if ($enableHTML) { - $privs[] = '' - . $current_grant[1] . ''; - } else { - $privs[] = $current_grant[1]; - } + $privs[] = PMA_formatPrivilege($current_grant, $enableHTML); } 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[] = PMA_formatPrivilege($current_grant, $enableHTML); $privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)'; } else { @@ -1226,8 +1234,9 @@ function PMA_getHtmlForGlobalPrivTableWithCheckboxes( ) . '/>' . "\n" . '' . "\n" + . '' + . PMA_formatPrivilege($priv, true) + . '' . "\n" . '' . "\n"; } $html_output .= '' . "\n";