/**
  * Test for PMA_getUsersOverview
  *
  * @return void
  */
 public function testPMAGetUsersOverview()
 {
     $result = array();
     $db_rights = array();
     $pmaThemeImage = "pmaThemeImage";
     $text_dir = "text_dir";
     $GLOBALS['cfgRelation']['menuswork'] = true;
     $html = PMA_getUsersOverview($result, $db_rights, $pmaThemeImage, $text_dir);
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs('', ''), $html);
     //items
     $this->assertContains(__('User'), $html);
     $this->assertContains(__('Host'), $html);
     $this->assertContains(__('Password'), $html);
     $this->assertContains(__('Global privileges'), $html);
     //PMA\libraries\Util::showHint
     $this->assertContains(PMA\libraries\Util::showHint(__('Note: MySQL privilege names are expressed in English.')), $html);
     //__('User group')
     $this->assertContains(__('User group'), $html);
     $this->assertContains(__('Grant'), $html);
     $this->assertContains(__('Action'), $html);
     //$pmaThemeImage
     $this->assertContains($pmaThemeImage, $html);
     //$text_dir
     $this->assertContains($text_dir, $html);
     //PMA_getFieldsetForAddDeleteUser
     $this->assertContains(PMA_getFieldsetForAddDeleteUser(), $html);
 }
/**
 * Get HTML for display the users overview
 * (if less than 50 users, display them immediately)
 *
 * @param array  $result        ran sql query
 * @param array  $db_rights     user's database rights array
 * @param string $pmaThemeImage a image source link
 * @param string $text_dir      text directory
 *
 * @return string HTML snippet
 */
function PMA_getUsersOverview($result, $db_rights, $pmaThemeImage, $text_dir)
{
    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
        $row['privs'] = PMA_extractPrivInfo($row, true);
        $db_rights[$row['User']][$row['Host']] = $row;
    }
    @$GLOBALS['dbi']->freeResult($result);
    $user_group_count = 0;
    if ($GLOBALS['cfgRelation']['menuswork']) {
        $user_group_count = PMA_getUserGroupCount();
    }
    $html_output = '<form name="usersForm" id="usersForm" action="server_privileges.php" ' . 'method="post">' . "\n" . PMA_URL_getHiddenInputs('', '') . '<table id="tableuserrights" class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '<th>' . __('User') . '</th>' . "\n" . '<th>' . __('Host') . '</th>' . "\n" . '<th>' . __('Password') . '</th>' . "\n" . '<th>' . __('Global privileges') . ' ' . PMA_Util::showHint(__('Note: MySQL privilege names are expressed in English.')) . '</th>' . "\n";
    if ($GLOBALS['cfgRelation']['menuswork']) {
        $html_output .= '<th>' . __('User group') . '</th>' . "\n";
    }
    $html_output .= '<th>' . __('Grant') . '</th>' . "\n" . '<th colspan="' . ($user_group_count > 0 ? '3' : '2') . '">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $html_output .= '<tbody>' . "\n";
    $html_output .= PMA_getHtmlTableBodyForUserRights($db_rights);
    $html_output .= '</tbody>' . '</table>' . "\n";
    $html_output .= '<div style="float:left;">' . PMA_Util::getWithSelected($pmaThemeImage, $text_dir, "usersForm") . "\n";
    $html_output .= PMA_Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export');
    $html_output .= '<input type="hidden" name="initial" ' . 'value="' . (isset($_GET['initial']) ? $_GET['initial'] : '') . '" />';
    $html_output .= '</div>' . '<div class="clear_both" style="clear:both"></div>';
    // add/delete user fieldset
    $html_output .= PMA_getFieldsetForAddDeleteUser();
    $html_output .= '</form>' . "\n";
    return $html_output;
}
/**
 * Get HTML for display the users overview
 * (if less than 50 users, display them immediately)
 *
 * @param array  $result            ran sql query
 * @param array  $db_rights         user's database rights array
 * @param string $link_edit         standard link to edit privileges
 * @param string $pmaThemeImage     a image source link
 * @param string $text_dir          text directory
 * @param string $conditional_class if ajaxable 'Ajax' otherwise ''
 * @param string $link_export       standard link to export privileges
 *
 * @return string HTML snippet
 */
function PMA_getUsersOverview($result, $db_rights, $link_edit, $pmaThemeImage, $text_dir, $conditional_class, $link_export)
{
    while ($row = PMA_DBI_fetch_assoc($result)) {
        $row['privs'] = PMA_extractPrivInfo($row, true);
        $db_rights[$row['User']][$row['Host']] = $row;
    }
    @PMA_DBI_free_result($result);
    $html_output = '<form name="usersForm" id="usersForm" action="server_privileges.php" ' . 'method="post">' . "\n" . PMA_generate_common_hidden_inputs('', '') . '<table id="tableuserrights" class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '<th>' . __('User') . '</th>' . "\n" . '<th>' . __('Host') . '</th>' . "\n" . '<th>' . __('Password') . '</th>' . "\n" . '<th>' . __('Global privileges') . ' ' . PMA_Util::showHint(__('Note: MySQL privilege names are expressed in English')) . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th colspan="2">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $html_output .= '<tbody>' . "\n";
    $html_output .= PMA_getTableBodyForUserRightsTable($db_rights, $link_edit, $link_export);
    $html_output .= '</tbody>' . '</table>' . "\n";
    $html_output .= '<div style="float:left;">' . '<img class="selectallarrow"' . ' src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png"' . ' width="38" height="22"' . ' alt="' . __('With selected:') . '" />' . "\n" . '<input type="checkbox" id="checkall" title="' . __('Check All') . '" /> ' . '<label for="checkall">' . __('Check All') . '</label> ' . '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
    $html_output .= PMA_Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export');
    $html_output .= '<input type="hidden" name="initial" ' . 'value="' . (isset($_GET['initial']) ? $_GET['initial'] : '') . '" />';
    $html_output .= '</div>' . '<div class="clear_both" style="clear:both"></div>';
    // add/delete user fieldset
    $html_output .= PMA_getFieldsetForAddDeleteUser($conditional_class);
    $html_output .= '</form>' . "\n";
    return $html_output;
}