コード例 #1
0
/**
 * Returns a user preferences array filtered by $cfg['UserprefsDisallow']
 * (blacklist) and keys from user preferences form (whitelist)
 *
 * @param array $config_data path => value pairs
 *
 * @return array
 */
function PMA_applyUserprefs(array $config_data)
{
    $cfg = array();
    $blacklist = array_flip($GLOBALS['cfg']['UserprefsDisallow']);
    if (!$GLOBALS['cfg']['UserprefsDeveloperTab']) {
        // disallow everything in the Developers tab
        $blacklist['DBG/sql'] = true;
    }
    $whitelist = array_flip(PMA_readUserprefsFieldNames());
    // 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_arrayWrite($path, $cfg, $value);
    }
    return $cfg;
}
コード例 #2
0
ファイル: FormDisplay.php プロジェクト: rclakmal/phpmyadmin
 /**
  * Fills out {@link userprefs_keys} and {@link userprefs_disallow}
  *
  * @return void
  */
 private function _loadUserprefsInfo()
 {
     if ($this->_userprefsKeys !== null) {
         return;
     }
     $this->_userprefsKeys = array_flip(PMA_readUserprefsFieldNames());
     // read real config for user preferences display
     $userprefs_disallow = defined('PMA_SETUP') ? $this->_configFile->get('UserprefsDisallow', array()) : $GLOBALS['cfg']['UserprefsDisallow'];
     $this->_userprefsDisallow = array_flip($userprefs_disallow);
 }
コード例 #3
0
 /**
  * Test for PMA_readUserprefsFieldNames
  *
  * @return void
  */
 public function testReadUserprefsFieldNames()
 {
     $this->assertGreaterThan(0, count(PMA_readUserprefsFieldNames()));
     $forms = array('form1' => array(array('Servers/1/hide_db', 'bar'), array('test' => 'val')));
     $this->assertEquals(array('Servers/1/hide_db', 'bar', 'test'), PMA_readUserprefsFieldNames($forms));
 }