当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_getHtmlForUserRights函数代码示例

本文整理汇总了PHP中PMA_getHtmlForUserRights函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getHtmlForUserRights函数的具体用法?PHP PMA_getHtmlForUserRights怎么用?PHP PMA_getHtmlForUserRights使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PMA_getHtmlForUserRights函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PMA_getHtmlForAllTableSpecificRights

/**
 * Get a HTML table for display user's tabel specific or database specific rights
 *
 * @param string $username username
 * @param string $hostname host name
 * @param string $dbname   database name
 *
 * @return array $html_output, $found_rows
 */
function PMA_getHtmlForAllTableSpecificRights($username, $hostname, $dbname)
{
    // table header
    $html_output = PMA_URL_getHiddenInputs('', '') . '<input type="hidden" name="username" ' . 'value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="hostname" ' . 'value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset>' . "\n" . '<legend data-submenu-label="' . (!mb_strlen($dbname) ? __('Database') : __('Table')) . '">' . (!mb_strlen($dbname) ? __('Database-specific privileges') : __('Table-specific privileges')) . '</legend>' . "\n" . '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th>' . (!mb_strlen($dbname) ? __('Database') : __('Table')) . '</th>' . "\n" . '<th>' . __('Privileges') . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th>' . (!mb_strlen($dbname) ? __('Table-specific privileges') : __('Column-specific privileges')) . '</th>' . "\n" . '<th colspan="2">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $user_host_condition = ' WHERE `User`' . ' = \'' . PMA_Util::sqlAddSlashes($username) . "'" . ' AND `Host`' . ' = \'' . PMA_Util::sqlAddSlashes($hostname) . "'";
    // table body
    // get data
    // we also want privileges for this user not in table `db` but in other table
    $tables = $GLOBALS['dbi']->fetchResult('SHOW TABLES FROM `mysql`;');
    /**
     * 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($tables, $user_host_condition, $dbname);
    ksort($db_rights);
    $html_output .= '<tbody>' . "\n";
    // display rows
    list($found_rows, $html_out) = PMA_getHtmlForUserRights($db_rights, $dbname, $hostname, $username);
    $html_output .= $html_out;
    $html_output .= '</tbody>' . "\n";
    $html_output .= '</table>' . "\n";
    return array($html_output, $found_rows);
}
开发者ID:siddhantsomani,项目名称:phpmyadmin,代码行数:32,代码来源:server_privileges.lib.php

示例2: testPMAGetHtmlForUserRights

 /**
  * Tests for PMA_getHtmlForUserRights
  *
  * @return void
  */
 function testPMAGetHtmlForUserRights()
 {
     // Test case 1
     $db_rights = array('y' => array('privs' => array('USAGE'), 'Db' => 'y', 'Grant_priv' => 'N', 'Column_priv' => true, 'can_delete' => true));
     $exp_found_rows = array('y');
     $actual = PMA_getHtmlForUserRights($db_rights, '', 'host', 'user');
     $this->assertArrayHasKey(0, $actual);
     $this->assertArrayHasKey(1, $actual);
     $this->assertEquals($exp_found_rows, $actual[0]);
     $this->assertContains('Edit Privileges', $actual[1]);
     $this->assertContains('Revoke', $actual[1]);
     $this->assertContains('<tr class="odd">', $actual[1]);
     $this->assertContains('<dfn title="No privileges.">USAGE</dfn>', $actual[1]);
     $this->assertContains('<img src="imageb_usredit.png" title="Edit Privileges" ' . 'alt="Edit Privileges" />', $actual[1]);
     $this->assertContains('<img src="imageb_usrdrop.png" title="Revoke" alt="Revoke" />', $actual[1]);
     // Test case 2
     $actual = PMA_getHtmlForUserRights(array(), '', '', '');
     $this->assertArrayHasKey(0, $actual);
     $this->assertArrayHasKey(1, $actual);
     $this->assertEquals(array(), $actual[0]);
     $this->assertEquals('<tr class="odd">' . "\n" . '<td colspan="6"><center><i>None</i></center></td>' . "\n" . '</tr>' . "\n", $actual[1]);
 }
开发者ID:nobodypb,项目名称:phpmyadmin,代码行数:27,代码来源:PMA_server_privileges_test.php


注:本文中的PMA_getHtmlForUserRights函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。