PMA\libraries\Util::getMenuTabList PHP Method

getMenuTabList() public static method

Return the list of tabs for the menu with corresponding names
public static getMenuTabList ( string $level = null ) : array
$level string 'server', 'db' or 'table' level
return array list of tabs for the menu
    public static function getMenuTabList($level = null)
    {
        $tabList = array('server' => array('databases' => __('Databases'), 'sql' => __('SQL'), 'status' => __('Status'), 'rights' => __('Users'), 'export' => __('Export'), 'import' => __('Import'), 'settings' => __('Settings'), 'binlog' => __('Binary log'), 'replication' => __('Replication'), 'vars' => __('Variables'), 'charset' => __('Charsets'), 'plugins' => __('Plugins'), 'engine' => __('Engines')), 'db' => array('structure' => __('Structure'), 'sql' => __('SQL'), 'search' => __('Search'), 'qbe' => __('Query'), 'export' => __('Export'), 'import' => __('Import'), 'operation' => __('Operations'), 'privileges' => __('Privileges'), 'routines' => __('Routines'), 'events' => __('Events'), 'triggers' => __('Triggers'), 'tracking' => __('Tracking'), 'designer' => __('Designer'), 'central_columns' => __('Central columns')), 'table' => array('browse' => __('Browse'), 'structure' => __('Structure'), 'sql' => __('SQL'), 'search' => __('Search'), 'insert' => __('Insert'), 'export' => __('Export'), 'import' => __('Import'), 'privileges' => __('Privileges'), 'operation' => __('Operations'), 'tracking' => __('Tracking'), 'triggers' => __('Triggers')));
        if ($level == null) {
            return $tabList;
        } else {
            if (array_key_exists($level, $tabList)) {
                return $tabList[$level];
            } else {
                return null;
            }
        }
    }

Usage Example

示例#1
0
 /**
  * Returns a list of allowed tabs for the current user for the given level
  *
  * @param string $level 'server', 'db' or 'table' level
  *
  * @return array list of allowed tabs
  */
 private function _getAllowedTabs($level)
 {
     $cache_key = 'menu-levels-' . $level;
     if (Util::cacheExists($cache_key)) {
         return Util::cacheGet($cache_key);
     }
     $allowedTabs = Util::getMenuTabList($level);
     $cfgRelation = PMA_getRelationsParam();
     if ($cfgRelation['menuswork']) {
         $groupTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['usergroups']);
         $userTable = Util::backquote($cfgRelation['db']) . "." . Util::backquote($cfgRelation['users']);
         $sql_query = "SELECT `tab` FROM " . $groupTable . " WHERE `allowed` = 'N'" . " AND `tab` LIKE '" . $level . "%'" . " AND `usergroup` = (SELECT usergroup FROM " . $userTable . " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "')";
         $result = PMA_queryAsControlUser($sql_query, false);
         if ($result) {
             while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
                 $tabName = mb_substr($row['tab'], mb_strpos($row['tab'], '_') + 1);
                 unset($allowedTabs[$tabName]);
             }
         }
     }
     Util::cacheSet($cache_key, $allowedTabs);
     return $allowedTabs;
 }
Util