From 0f411d04ca18b28762df9fa3f9110985fbe087ef Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Tue, 22 Nov 2016 10:18:14 +0530 Subject: [PATCH] Refactor html for choosing user group to use template Signed-off-by: Deven Bansod --- libraries/server_privileges.lib.php | 48 ++++++++------------ templates/privileges/choose_user_group.phtml | 9 ++++ 2 files changed, 27 insertions(+), 30 deletions(-) create mode 100644 templates/privileges/choose_user_group.phtml diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 1b3e2cde4f..67fe80be63 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -528,29 +528,12 @@ function PMA_getSqlQueryForDisplayPrivTable($db, $table, $username, $hostname) */ function PMA_getHtmlToChooseUserGroup($username) { - $html_output = '
'; - $params = array('username' => $username); - $html_output .= URL::getHiddenInputs($params); - $html_output .= '
'; - $html_output .= '' . __('User group') . ''; - $cfgRelation = PMA_getRelationsParam(); $groupTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['usergroups']); $userTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['users']); - $userGroups = array(); - $sql_query = "SELECT DISTINCT `usergroup` FROM " . $groupTable; - $result = PMA_queryAsControlUser($sql_query, false); - if ($result) { - while ($row = $GLOBALS['dbi']->fetchRow($result)) { - $userGroups[] = $row[0]; - } - } - $GLOBALS['dbi']->freeResult($result); - $userGroup = ''; if (isset($GLOBALS['username'])) { $sql_query = "SELECT `usergroup` FROM " . $userTable @@ -560,20 +543,25 @@ function PMA_getHtmlToChooseUserGroup($username) ); } - $html_output .= __('User group') . ': '; - $html_output .= ''; - $html_output .= ''; - $html_output .= '
'; - $html_output .= '
'; + $GLOBALS['dbi']->freeResult($result); + + // render the template + $data = array( + 'allUserGroups' => $allUserGroups, + 'userGroup' => $userGroup, + 'params' => array('username' => $username) + ); + $html_output = Template::get('privileges/choose_user_group') + ->render($data); + return $html_output; } diff --git a/templates/privileges/choose_user_group.phtml b/templates/privileges/choose_user_group.phtml new file mode 100644 index 0000000000..380e6a6d56 --- /dev/null +++ b/templates/privileges/choose_user_group.phtml @@ -0,0 +1,9 @@ +
+ +
+ + : + + +
+
\ No newline at end of file