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


PHP PMA_loadUserprefs函数代码示例

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


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

示例1: testLoadUserprefs

 /**
  * Test for PMA_loadUserprefs
  *
  * @return void
  */
 public function testLoadUserprefs()
 {
     $_SESSION['relation'][$GLOBALS['server']]['userconfigwork'] = null;
     unset($_SESSION['userconfig']);
     $result = PMA_loadUserprefs();
     $this->assertCount(3, $result);
     $this->assertEquals(array(), $result['config_data']);
     $this->assertEquals(time(), $result['mtime'], '', 2);
     $this->assertEquals('session', $result['type']);
     // case 2
     $_SESSION['relation'][$GLOBALS['server']]['userconfigwork'] = 1;
     $_SESSION['relation'][$GLOBALS['server']]['db'] = "pma'db";
     $_SESSION['relation'][$GLOBALS['server']]['userconfig'] = "testconf";
     $_SESSION['relation'][$GLOBALS['server']]['user'] = "user";
     $GLOBALS['controllink'] = null;
     $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
     $query = 'SELECT `config_data`, UNIX_TIMESTAMP(`timevalue`) ts ' . 'FROM `pma\'db`.`testconf` WHERE `username` = \'user\'';
     $dbi->expects($this->once())->method('fetchSingleRow')->with($query, 'ASSOC', null)->will($this->returnValue(array('ts' => '123', 'config_data' => json_encode(array(1, 2)))));
     $GLOBALS['dbi'] = $dbi;
     $result = PMA_loadUserprefs();
     $this->assertEquals(array('config_data' => array(1, 2), 'mtime' => 123, 'type' => 'db'), $result);
 }
开发者ID:hewenhao2008,项目名称:phpmyadmin,代码行数:27,代码来源:PMA_user_preferences_test.php

示例2: ConfigFile

require_once 'libraries/config/messages.inc.php';
require 'libraries/config/user_preferences.forms.php';
$cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
PMA_userprefsPageInit($cf);
$error = '';
if (isset($_POST['submit_export']) && isset($_POST['export_type']) && $_POST['export_type'] == 'text_file') {
    // export to JSON file
    PMA\libraries\Response::getInstance()->disable();
    $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json';
    PMA_downloadHeader($filename, 'application/json');
    $settings = PMA_loadUserprefs();
    echo json_encode($settings['config_data'], JSON_PRETTY_PRINT);
    exit;
} else {
    if (isset($_POST['submit_get_json'])) {
        $settings = PMA_loadUserprefs();
        $response = PMA\libraries\Response::getInstance();
        $response->addJSON('prefs', json_encode($settings['config_data']));
        $response->addJSON('mtime', $settings['mtime']);
        exit;
    } else {
        if (isset($_POST['submit_import'])) {
            // load from JSON file
            $json = '';
            if (isset($_POST['import_type']) && $_POST['import_type'] == 'text_file' && isset($_FILES['import_file']) && $_FILES['import_file']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['import_file']['tmp_name'])) {
                // read JSON from uploaded file
                $open_basedir = @ini_get('open_basedir');
                $file_to_unlink = '';
                $import_file = $_FILES['import_file']['tmp_name'];
                // If we are on a server with open_basedir, we must move the file
                // before opening it. The doc explains how to create the "./tmp"
开发者ID:Dhrumil1808,项目名称:phpmyadmin,代码行数:31,代码来源:prefs_manage.php

示例3: loadUserPreferences

 /**
  * Loads user preferences and merges them with current config
  * must be called after control connection has been estabilished
  *
  * @return boolean
  */
 function loadUserPreferences()
 {
     // index.php should load these settings, so that phpmyadmin.css.php
     // will have everything avaiable in session cache
     $server = isset($GLOBALS['server']) ? $GLOBALS['server'] : (!empty($GLOBALS['cfg']['ServerDefault']) ? $GLOBALS['cfg']['ServerDefault'] : 0);
     $cache_key = 'server_' . $server;
     if ($server > 0 && !defined('PMA_MINIMUM_COMMON')) {
         $config_mtime = max($this->default_source_mtime, $this->source_mtime);
         // cache user preferences, use database only when needed
         if (!isset($_SESSION['cache'][$cache_key]['userprefs']) || $_SESSION['cache'][$cache_key]['config_mtime'] < $config_mtime) {
             // load required libraries
             include_once './libraries/user_preferences.lib.php';
             $prefs = PMA_loadUserprefs();
             $_SESSION['cache'][$cache_key]['userprefs'] = PMA_applyUserprefs($prefs['config_data']);
             $_SESSION['cache'][$cache_key]['userprefs_mtime'] = $prefs['mtime'];
             $_SESSION['cache'][$cache_key]['userprefs_type'] = $prefs['type'];
             $_SESSION['cache'][$cache_key]['config_mtime'] = $config_mtime;
         }
     } elseif ($server == 0 || !isset($_SESSION['cache'][$cache_key]['userprefs'])) {
         $this->set('user_preferences', false);
         return;
     }
     $config_data = $_SESSION['cache'][$cache_key]['userprefs'];
     // type is 'db' or 'session'
     $this->set('user_preferences', $_SESSION['cache'][$cache_key]['userprefs_type']);
     $this->set('user_preferences_mtime', $_SESSION['cache'][$cache_key]['userprefs_mtime']);
     // backup some settings
     $org_fontsize = '';
     if (isset($this->settings['fontsize'])) {
         $org_fontsize = $this->settings['fontsize'];
     }
     // load config array
     $this->settings = PMA_arrayMergeRecursive($this->settings, $config_data);
     $GLOBALS['cfg'] = PMA_arrayMergeRecursive($GLOBALS['cfg'], $config_data);
     if (defined('PMA_MINIMUM_COMMON')) {
         return;
     }
     // settings below start really working on next page load, but
     // changes are made only in index.php so everything is set when
     // in frames
     // save theme
     $tmanager = $_SESSION['PMA_Theme_Manager'];
     if ($tmanager->getThemeCookie() || isset($_REQUEST['set_theme'])) {
         if (!isset($config_data['ThemeDefault']) && $tmanager->theme->getId() != 'original' || isset($config_data['ThemeDefault']) && $config_data['ThemeDefault'] != $tmanager->theme->getId()) {
             // new theme was set in common.inc.php
             $this->setUserValue(null, 'ThemeDefault', $tmanager->theme->getId(), 'original');
         }
     } else {
         // no cookie - read default from settings
         if ($this->settings['ThemeDefault'] != $tmanager->theme->getId() && $tmanager->checkTheme($this->settings['ThemeDefault'])) {
             $tmanager->setActiveTheme($this->settings['ThemeDefault']);
             $tmanager->setThemeCookie();
         }
     }
     // save font size
     if (!isset($config_data['fontsize']) && $org_fontsize != '82%' || isset($config_data['fontsize']) && $org_fontsize != $config_data['fontsize']) {
         $this->setUserValue(null, 'fontsize', $org_fontsize, '82%');
     }
     // save language
     if (isset($_COOKIE['pma_lang']) || isset($_POST['lang'])) {
         if (!isset($config_data['lang']) && $GLOBALS['lang'] != 'en' || isset($config_data['lang']) && $GLOBALS['lang'] != $config_data['lang']) {
             $this->setUserValue(null, 'lang', $GLOBALS['lang'], 'en');
         }
     } else {
         // read language from settings
         if (isset($config_data['lang']) && PMA_langSet($config_data['lang'])) {
             $this->setCookie('pma_lang', $GLOBALS['lang']);
         }
     }
     // save connection collation
     if (isset($_COOKIE['pma_collation_connection']) || isset($_POST['collation_connection'])) {
         if (!isset($config_data['collation_connection']) && $GLOBALS['collation_connection'] != 'utf8_general_ci' || isset($config_data['collation_connection']) && $GLOBALS['collation_connection'] != $config_data['collation_connection']) {
             $this->setUserValue(null, 'collation_connection', $GLOBALS['collation_connection'], 'utf8_general_ci');
         }
     } else {
         // read collation from settings
         if (isset($config_data['collation_connection'])) {
             $GLOBALS['collation_connection'] = $config_data['collation_connection'];
             $this->setCookie('pma_collation_connection', $GLOBALS['collation_connection']);
         }
     }
 }
开发者ID:nvq247,项目名称:joomla15test,代码行数:88,代码来源:Config.class.php

示例4: PMA_persistOption

/**
 * Updates one user preferences option (loads and saves to database).
 *
 * No validation is done!
 *
 * @param string $path          configuration
 * @param mixed  $value         value
 * @param mixed  $default_value default value
 *
 * @return void
 */
function PMA_persistOption($path, $value, $default_value)
{
    $prefs = PMA_loadUserprefs();
    if ($value === $default_value) {
        if (isset($prefs['config_data'][$path])) {
            unset($prefs['config_data'][$path]);
        } else {
            return;
        }
    } else {
        $prefs['config_data'][$path] = $value;
    }
    PMA_saveUserprefs($prefs['config_data']);
}
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:25,代码来源:user_preferences.lib.php


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