/** * Fills out {@link userprefs_keys} and {@link userprefs_disallow} * * @uses PMA_read_userprefs_fieldnames() */ private function _loadUserprefsInfo() { if ($this->userprefs_keys === null) { $this->userprefs_keys = array_flip(PMA_read_userprefs_fieldnames()); // read real config for user preferences display $userprefs_disallow = defined('PMA_SETUP') ? ConfigFile::getInstance()->get('UserprefsDisallow', array()) : $GLOBALS['cfg']['UserprefsDisallow']; $this->userprefs_disallow = array_flip($userprefs_disallow); } }
/** * Returns a user preferences array filtered by $cfg['UserprefsDisallow'] * (blacklist) and keys from user preferences form (whitelist) * * @uses PMA_array_write() * @uses PMA_read_userprefs_fieldnames() * @param array $config_data path => value pairs * @return array */ function PMA_apply_userprefs(array $config_data) { $cfg = array(); $blacklist = array_flip($GLOBALS['cfg']['UserprefsDisallow']); if (!$GLOBALS['cfg']['UserprefsDeveloperTab']) { // disallow everything in the Developers tab $blacklist['Error_Handler/display'] = true; $blacklist['Error_Handler/gather'] = true; $blacklist['DBG/sql'] = true; } $whitelist = array_flip(PMA_read_userprefs_fieldnames()); // whitelist some additional fields which are custom handled $whitelist['ThemeDefault'] = true; $whitelist['fontsize'] = true; $whitelist['lang'] = true; $whitelist['collation_connection'] = true; $whitelist['Server/hide_db'] = true; $whitelist['Server/only_db'] = true; foreach ($config_data as $path => $value) { if (!isset($whitelist[$path]) || isset($blacklist[$path])) { continue; } PMA_array_write($path, $cfg, $value); } return $cfg; }