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


PHP set_config函数代码示例

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


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

示例1: announces_prune

function announces_prune($force_prune = false)
{
    global $db, $board_config;
    // do we prune the announces ?
    $today_time = time();
    $today = mktime(0, 0, 0, date('m', $today_time), date('d', $today_time) + 1, date('Y', $today_time)) - 1;
    $do_prune = false;
    // last prune date
    if (intval($board_config['announcement_last_prune']) < $today || $force_prune) {
        $do_prune = true;
        if ($sql = set_config('announcement_last_prune', $today, TRUE)) {
            message_die(GENERAL_ERROR, 'Could not update key announcement_last_prune in the config table', '', __LINE__, __FILE__, $sql);
        }
    }
    // is the prune function activated ?
    $default_duration = isset($board_config['announcement_duration']) ? intval($board_config['announcement_duration']) : 7;
    if ($default_duration <= 0) {
        $do_prune = false;
    }
    // process fix and prune
    if ($do_prune) {
        // fix announces duration
        $default_duration = isset($board_config['announcement_duration']) ? intval($board_config['announcement_duration']) : 7;
        $sql = "UPDATE " . TOPICS_TABLE . "\n\t\t\t\tSET topic_announce_duration = {$default_duration}\n\t\t\t\tWHERE topic_announce_duration = 0\n\t\t\t\t\tAND (topic_type=" . POST_ANNOUNCE . " OR topic_type=" . POST_GLOBAL_ANNOUNCE . ")";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not update topic duration list', '', __LINE__, __FILE__, $sql);
        }
        // prune announces
        $prune_strategy = isset($board_config['announcement_prune_strategy']) ? intval($board_config['announcement_prune_strategy']) : POST_NORMAL;
        $sql = "UPDATE " . TOPICS_TABLE . "\n\t\t\t\tSET topic_type = {$prune_strategy}\n\t\t\t\tWHERE (topic_announce_duration > -1)\n\t\t\t\t\tAND ( (topic_time + topic_announce_duration * 86400) <= {$today} )\n\t\t\t\t\tAND (topic_type=" . POST_ANNOUNCE . " OR topic_type=" . POST_GLOBAL_ANNOUNCE . ")";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not update topic type to prune announcements', '', __LINE__, __FILE__, $sql);
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:phpbbsfp,代码行数:35,代码来源:functions_announces.php

示例2: xmldb_filter_mediaplugin_upgrade

/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_filter_mediaplugin_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2011121200) {
        // Move all the media enable setttings that are now handled by core media renderer.
        foreach (array('html5video', 'html5audio', 'mp3', 'flv', 'wmp', 'qt', 'rm', 'youtube', 'vimeo', 'swf') as $type) {
            $existingkey = 'filter_mediaplugin_enable_' . $type;
            if (array_key_exists($existingkey, $CFG)) {
                set_config('core_media_enable_' . $type, $CFG->{$existingkey});
                unset_config($existingkey);
            }
        }
        // Override setting for html5 to turn it on (previous default was off; because
        // of changes in the way fallbacks are handled, this is now unlikely to cause
        // a problem, and is required for mobile a/v support on non-Flash devices, so
        // this change is basically needed in order to maintain existing behaviour).
        set_config('core_media_enable_html5video', 1);
        set_config('core_media_enable_html5audio', 1);
        upgrade_plugin_savepoint(true, 2011121200, 'filter', 'mediaplugin');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    return true;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:upgrade.php

示例3: xmldb_theme_formal_white_upgrade

function xmldb_theme_formal_white_upgrade($oldversion)
{
    // Moodle v2.2.0 release upgrade line
    // Put any upgrade step following this
    if ($oldversion < 2012051503) {
        $currentsetting = get_config('theme_formal_white');
        if (isset($currentsetting->displaylogo)) {
            // useless but safer
            // Create a new config setting called headercontent and give it the current displaylogo value.
            set_config('headercontent', $currentsetting->displaylogo, 'theme_formal_white');
            unset_config('displaylogo', 'theme_formal_white');
        }
        if (isset($currentsetting->logo)) {
            // useless but safer
            // Create a new config setting called headercontent and give it the current displaylogo value.
            set_config('customlogourl', $currentsetting->logo, 'theme_formal_white');
            unset_config('logo', 'theme_formal_white');
        }
        if (isset($currentsetting->frontpagelogo)) {
            // useless but safer
            // Create a new config setting called headercontent and give it the current displaylogo value.
            set_config('frontpagelogourl', $currentsetting->frontpagelogo, 'theme_formal_white');
            unset_config('frontpagelogo', 'theme_formal_white');
        }
        upgrade_plugin_savepoint(true, 2012051503, 'theme', 'formal_white');
    }
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:34,代码来源:upgrade.php

示例4: as_cron

/**
 * Runs the cron functions
 */
function as_cron()
{
    global $db, $config;
    set_config('last_as_run', time(), true);
    if (!function_exists('add_log')) {
        include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
    }
    if ($config['as_max_posts'] > 0) {
        $sql = 'SELECT COUNT(shout_id) as total FROM ' . SHOUTBOX_TABLE;
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchfield('total', $result);
        $db->sql_freeresult($result);
        if ($row > $config['as_max_posts']) {
            $sql = 'SELECT shout_id FROM ' . SHOUTBOX_TABLE . ' ORDER BY shout_time DESC';
            $result = $db->sql_query_limit($sql, $config['as_max_posts']);
            $delete = array();
            while ($row = $db->sql_fetchrow($result)) {
                $delete[] = $row['shout_id'];
            }
            $sql = 'DELETE FROM ' . SHOUTBOX_TABLE . ' WHERE ' . $db->sql_in_set('shout_id', $delete, true);
            $db->sql_query($sql);
            add_log('admin', 'LOG_AS_REMOVED', $db->sql_affectedrows($result));
        }
    } else {
        if ($config['as_prune'] > 0) {
            $time = time() - $config['as_prune'] * 3600;
            $sql = 'DELETE FROM  ' . SHOUTBOX_TABLE . " WHERE shout_time < {$time}";
            $db->sql_query($sql);
            $deleted = $db->sql_affectedrows($result);
            if ($deleted > 0) {
                add_log('admin', 'LOG_AS_PURGED', $deleted);
            }
        }
    }
}
开发者ID:paul999,项目名称:ajax-shoutbox,代码行数:38,代码来源:functions_shoutbox.php

示例5: disable_plugin

 protected function disable_plugin()
 {
     $enabled = enrol_get_plugins(true);
     unset($enabled['cohort']);
     $enabled = array_keys($enabled);
     set_config('enrol_plugins_enabled', implode(',', $enabled));
 }
开发者ID:stronk7,项目名称:moodle,代码行数:7,代码来源:sync_test.php

示例6: xmldb_filter_texwjax_upgrade

/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_filter_texwjax_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Moodle v2.3.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.4.0 release upgrade line
    // Put any upgrade step following this
    // Moodle v2.5.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    if ($oldversion < 2013120300) {
        $settings = array('density', 'latexbackground', 'convertformat', 'pathlatex', 'convertformat', 'pathconvert', 'pathdvips', 'latexpreamble');
        // Move tex settings to config_pluins and delete entries from the config table.
        foreach ($settings as $setting) {
            $existingkey = 'filter_texwjax_' . $setting;
            if (array_key_exists($existingkey, $CFG)) {
                set_config($setting, $CFG->{$existingkey}, 'filter_texwjax');
                unset_config($existingkey);
            }
        }
        upgrade_plugin_savepoint(true, 2013120300, 'filter', 'texwjax');
    }
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:papillon326,项目名称:moodle-filter_texwjax,代码行数:34,代码来源:upgrade.php

示例7: setUp

 function setUp()
 {
     global $DB, $CFG;
     $this->realDB = $DB;
     $dbclass = get_class($this->realDB);
     $DB = new $dbclass();
     $DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->unittestprefix);
     if ($DB->get_manager()->table_exists('onlinejudge_tasks')) {
         $DB->get_manager()->delete_tables_from_xmldb_file($CFG->dirroot . '/local/onlinejudge/db/install.xml');
     }
     $DB->get_manager()->install_from_xmldb_file($CFG->dirroot . '/local/onlinejudge/db/install.xml');
     if ($DB->get_manager()->table_exists('files')) {
         $table = new xmldb_table('files');
         $DB->get_manager()->drop_table($table);
         $table = new xmldb_table('config_plugins');
         $DB->get_manager()->drop_table($table);
         $table = new xmldb_table('events_handlers');
         $DB->get_manager()->drop_table($table);
     }
     $DB->get_manager()->install_one_table_from_xmldb_file($CFG->dirroot . '/lib/db/install.xml', 'files');
     $DB->get_manager()->install_one_table_from_xmldb_file($CFG->dirroot . '/lib/db/install.xml', 'config_plugins');
     $DB->get_manager()->install_one_table_from_xmldb_file($CFG->dirroot . '/lib/db/install.xml', 'events_handlers');
     set_config('maxmemlimit', 64, 'local_onlinejudge');
     set_config('maxcpulimit', 10, 'local_onlinejudge');
     set_config('ideonedelay', 10, 'local_onlinejudge');
 }
开发者ID:boychunli,项目名称:moodle-local_onlinejudge,代码行数:26,代码来源:testjudgelib.php

示例8: test_mymoodleredirectreturnsfalseforadmin

 /**
  * Validate that redirection from My Moodle does not happen for admins
  */
 public function test_mymoodleredirectreturnsfalseforadmin()
 {
     global $CFG, $USER, $DB;
     require_once $CFG->dirroot . '/user/lib.php';
     // Make sure we're not a guest.
     set_config('siteguest', '');
     // Obtain the system context.
     $syscontext = context_system::instance();
     // Set up the current user global.
     $user = new stdClass();
     $user->username = "testuser";
     $userid = user_create_user($user);
     $USER = $DB->get_record('user', array('id' => $userid));
     // Enable functionaltiy.
     pm_set_config('mymoodle_redirect', 1);
     elis::$config = new elis_config();
     // Give the admin sufficient permissions.
     $roleid = create_role('adminrole', 'adminrole', 'adminrole');
     assign_capability('moodle/site:config', CAP_ALLOW, $roleid, $syscontext->id);
     role_assign($roleid, $USER->id, $syscontext->id);
     // Validate that redirection does not happen for admins.
     $result = pm_mymoodle_redirect();
     // Clear out cached permissions data so we don't affect other tests.
     accesslib_clear_all_caches(true);
     $this->assertFalse($result);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:29,代码来源:programsettings_test.php

示例9: xmldb_editor_tinymce_upgrade

function xmldb_editor_tinymce_upgrade($oldversion)
{
    global $CFG, $DB;
    if ($oldversion < 2014062900) {
        // We only want to delete DragMath from the customtoolbar setting if the directory no longer exists. If
        // the directory is present then it means it has been restored, so do not remove any settings.
        if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) {
            // Remove the DragMath plugin from the 'customtoolbar' setting (if it exists) as it has been removed.
            $currentorder = get_config('editor_tinymce', 'customtoolbar');
            $newtoolbarrows = array();
            $currenttoolbarrows = explode("\n", $currentorder);
            foreach ($currenttoolbarrows as $currenttoolbarrow) {
                $currenttoolbarrow = implode(',', array_diff(str_getcsv($currenttoolbarrow), array('dragmath')));
                $newtoolbarrows[] = $currenttoolbarrow;
            }
            $neworder = implode("\n", $newtoolbarrows);
            unset_config('customtoolbar', 'editor_tinymce');
            set_config('customtoolbar', $neworder, 'editor_tinymce');
        }
        upgrade_plugin_savepoint(true, 2014062900, 'editor', 'tinymce');
    }
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:upgrade.php

示例10: cron

 /**
  * Automatically update the registration on all hubs
  */
 public function cron()
 {
     global $CFG;
     if (extension_loaded('xmlrpc')) {
         //check if the last registration cron update was less than a week ago
         $lastcron = get_config('registration', 'crontime');
         if ($lastcron === false or $lastcron < strtotime("-7 day")) {
             //set to a week, see MDL-23704
             $function = 'hub_update_site_info';
             require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
             //update all hub where the site is registered on
             $hubs = $this->get_registered_on_hubs();
             foreach ($hubs as $hub) {
                 //update the registration
                 $siteinfo = $this->get_site_info($hub->huburl);
                 $params = array('siteinfo' => $siteinfo);
                 $serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
                 $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
                 try {
                     $result = $xmlrpcclient->call($function, $params);
                     mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
                 } catch (Exception $e) {
                     $errorparam = new stdClass();
                     $errorparam->errormessage = $e->getMessage();
                     $errorparam->hubname = $hub->hubname;
                     mtrace(get_string('errorcron', 'hub', $errorparam));
                 }
             }
             set_config('crontime', time(), 'registration');
         }
     } else {
         mtrace(get_string('errorcronnoxmlrpc', 'hub'));
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:37,代码来源:lib.php

示例11: test_get_site_info

    public function test_get_site_info() {
        global $DB, $USER, $CFG;

        $this->resetAfterTest(true);

        // This is the info we are going to check
        set_config('release', '2.4dev (Build: 20120823)');
        set_config('version', '2012083100.00');

        // Set current user
        $user = array();
        $user['username'] = 'johnd';
        $user['firstname'] = 'John';
        $user['lastname'] = 'Doe';
        self::setUser(self::getDataGenerator()->create_user($user));

        // Add a web service and token.
        $webservice = new stdClass();
        $webservice->name = 'Test web service';
        $webservice->enabled = true;
        $webservice->restrictedusers = false;
        $webservice->component = 'moodle';
        $webservice->timecreated = time();
        $webservice->downloadfiles = true;
        $externalserviceid = $DB->insert_record('external_services', $webservice);

        // Add a function to the service
        $DB->insert_record('external_services_functions', array('externalserviceid' => $externalserviceid,
            'functionname' => 'core_course_get_contents'));

        $_POST['wstoken'] = 'testtoken';
        $externaltoken = new stdClass();
        $externaltoken->token = 'testtoken';
        $externaltoken->tokentype = 0;
        $externaltoken->userid = $USER->id;
        $externaltoken->externalserviceid = $externalserviceid;
        $externaltoken->contextid = 1;
        $externaltoken->creatorid = $USER->id;
        $externaltoken->timecreated = time();
        $DB->insert_record('external_tokens', $externaltoken);

        $siteinfo = core_webservice_external::get_site_info();

        // We need to execute the return values cleaning process to simulate the web service server.
        $siteinfo = external_api::clean_returnvalue(core_webservice_external::get_site_info_returns(), $siteinfo);

        $this->assertEquals('johnd', $siteinfo['username']);
        $this->assertEquals('John', $siteinfo['firstname']);
        $this->assertEquals('Doe', $siteinfo['lastname']);
        $this->assertEquals(current_language(), $siteinfo['lang']);
        $this->assertEquals($USER->id, $siteinfo['userid']);
        $this->assertEquals(true, $siteinfo['downloadfiles']);
        $this->assertEquals($CFG->release, $siteinfo['release']);
        $this->assertEquals($CFG->version, $siteinfo['version']);
        $this->assertEquals($CFG->mobilecssurl, $siteinfo['mobilecssurl']);
        $this->assertEquals(count($siteinfo['functions']), 1);
        $function = array_pop($siteinfo['functions']);
        $this->assertEquals($function['name'], 'core_course_get_contents');
        $this->assertEquals($function['version'], $siteinfo['version']);
    }
开发者ID:verbazend,项目名称:AWFA,代码行数:60,代码来源:externallib_test.php

示例12: __construct

 public function __construct()
 {
     // Use this context for filtering.
     $this->context = context_system::instance();
     // Define FORMAT_HTML as only one filtering in DB.
     set_config('formats', implode(',', array(FORMAT_HTML)), get_class($this));
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:7,代码来源:filter_test.php

示例13: networkingform_submit

function networkingform_submit(Pieform $form, $values)
{
    $reply = '';
    if ($form->get_submitvalue() === 'deletekey') {
        global $SESSION;
        $openssl = OpenSslRepo::singleton();
        $openssl->get_keypair(true);
        $SESSION->add_info_msg(get_string('keydeleted', 'admin'));
        // Using cancel here as a hack to get it to redirect so it shows the new keys
        $form->reply(PIEFORM_CANCEL, array('location' => get_config('wwwroot') . 'admin/site/networking.php'));
    }
    if (get_config('enablenetworking') != $values['enablenetworking']) {
        if (!set_config('enablenetworking', $values['enablenetworking'])) {
            networkingform_fail($form);
        } else {
            if (empty($values['enablenetworking'])) {
                $reply .= get_string('networkingdisabled', 'admin');
            } else {
                $reply .= get_string('networkingenabled', 'admin');
            }
        }
    }
    if (get_config('promiscuousmode') != $values['promiscuousmode']) {
        if (!set_config('promiscuousmode', $values['promiscuousmode'])) {
            networkingform_fail($form);
        } else {
            if (empty($values['promiscuousmode'])) {
                $reply .= get_string('promiscuousmodedisabled', 'admin');
            } else {
                $reply .= get_string('promiscuousmodeenabled', 'admin');
            }
        }
    }
    $form->reply(PIEFORM_OK, array('message' => $reply == '' ? get_string('networkingunchanged', 'admin') : $reply, 'goto' => '/admin/site/networking.php'));
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:35,代码来源:networking.php

示例14: setUp

 public function setUp()
 {
     $this->resetAfterTest();
     set_config('enableglobalsearch', true);
     // Set \core_search::instance to the mock_search_engine as we don't require the search engine to be working to test this.
     $search = testable_core_search::instance();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:7,代码来源:engine_test.php

示例15: process_config

 /**
  * Processes and stores configuration data for this authentication plugin.
  * $this->config->somefield
  */
 function process_config($config)
 {
     // set to defaults if undefined
     if (!isset($config->mainrule_fld)) {
         $config->mainrule_fld = '';
     }
     if (!isset($config->secondrule_fld)) {
         $config->secondrule_fld = 'n/a';
     }
     if (!isset($config->replace_arr)) {
         $config->replace_arr = '';
     }
     if (!isset($config->delim)) {
         $config->delim = 'CR+LF';
     }
     if (!isset($config->donttouchusers)) {
         $config->donttouchusers = '';
     }
     if (!isset($config->enableunenrol)) {
         $config->enableunenrol = 0;
     }
     // save settings
     set_config('mainrule_fld', $config->mainrule_fld, self::COMPONENT_NAME);
     set_config('secondrule_fld', $config->secondrule_fld, self::COMPONENT_NAME);
     set_config('replace_arr', $config->replace_arr, self::COMPONENT_NAME);
     set_config('delim', $config->delim, self::COMPONENT_NAME);
     set_config('donttouchusers', $config->donttouchusers, self::COMPONENT_NAME);
     set_config('enableunenrol', $config->enableunenrol, self::COMPONENT_NAME);
     return true;
 }
开发者ID:gagathos,项目名称:mcae,代码行数:34,代码来源:auth.php


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