本文整理汇总了PHP中unset_config函数的典型用法代码示例。如果您正苦于以下问题:PHP unset_config函数的具体用法?PHP unset_config怎么用?PHP unset_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unset_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp() {
global $DB, $CFG;
$this->resetAfterTest(true);
unset_config('noemailever');
$CFG->enablecompletion = true;
$user = $this->getDataGenerator()->create_user();
$fordb = new stdClass();
$fordb->id = null;
$fordb->name = "Test badge";
$fordb->description = "Testing badges";
$fordb->timecreated = time();
$fordb->timemodified = time();
$fordb->usercreated = $user->id;
$fordb->usermodified = $user->id;
$fordb->issuername = "Test issuer";
$fordb->issuerurl = "http://issuer-url.domain.co.nz";
$fordb->issuercontact = "issuer@example.com";
$fordb->expiredate = null;
$fordb->expireperiod = null;
$fordb->type = BADGE_TYPE_SITE;
$fordb->courseid = null;
$fordb->messagesubject = "Test message subject";
$fordb->message = "Test message body";
$fordb->attachment = 1;
$fordb->notification = 0;
$fordb->status = BADGE_STATUS_INACTIVE;
$this->badgeid = $DB->insert_record('badge', $fordb, true);
// Create a course with activity and auto completion tracking.
$this->course = $this->getDataGenerator()->create_course(array('enablecompletion' => true));
$this->user = $this->getDataGenerator()->create_user();
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->assertNotEmpty($studentrole);
// Get manual enrolment plugin and enrol user.
require_once($CFG->dirroot.'/enrol/manual/locallib.php');
$manplugin = enrol_get_plugin('manual');
$maninstance = $DB->get_record('enrol', array('courseid' => $this->course->id, 'enrol' => 'manual'), '*', MUST_EXIST);
$manplugin->enrol_user($maninstance, $this->user->id, $studentrole->id);
$this->assertEquals(1, $DB->count_records('user_enrolments'));
$completionauto = array('completion' => COMPLETION_TRACKING_AUTOMATIC);
$this->module = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id), $completionauto);
// Build badge and criteria.
$fordb->type = BADGE_TYPE_COURSE;
$fordb->courseid = $this->course->id;
$fordb->status = BADGE_STATUS_ACTIVE;
$this->coursebadge = $DB->insert_record('badge', $fordb, true);
$this->assertion = new stdClass();
$this->assertion->badge = '{"uid":"%s","recipient":{"identity":"%s","type":"email","hashed":true,"salt":"%s"},"badge":"%s","verify":{"type":"hosted","url":"%s"},"issuedOn":"%d","evidence":"%s"}';
$this->assertion->class = '{"name":"%s","description":"%s","image":"%s","criteria":"%s","issuer":"%s"}';
$this->assertion->issuer = '{"name":"%s","url":"%s","email":"%s"}';
}
示例2: xmldb_theme_formal_white_install
function xmldb_theme_formal_white_install()
{
// We need here to check whether or not the theme has been installed.
// If it has been installed then we need to change the name of the settings to the new names.
// If it is not installed it won't have any settings yet and we won't need to worry about this.
$currentsetting = get_config('theme_formal_white');
if (!empty($currentsetting)) {
// Remove the settings that are no longer used by this theme
// Remove regionwidth
unset_config('regionwidth', 'theme_formal_white');
// Remove alwayslangmenu
unset_config('alwayslangmenu', 'theme_formal_white');
// previous releases of formal_white them were not equipped with version number
// so I can not know if a theme specific variable exists or not.
// This is the reason why I try to use them both.
if (!empty($currentsetting->backgroundcolor)) {
// Create a new config setting called lblockcolumnbgc and give it backgroundcolor's value.
set_config('lblockcolumnbgc', $currentsetting->backgroundcolor, 'theme_formal_white');
// Remove backgroundcolor
unset_config('backgroundcolor', 'theme_formal_white');
} elseif (!empty($currentsetting->blockcolumnbgc)) {
// Create a new config setting called lblockcolumnbgc and give it blockcolumnbgc's value.
set_config('lblockcolumnbgc', $currentsetting->blockcolumnbgc, 'theme_formal_white');
// Remove blockcolumnbgc
unset_config('blockcolumnbgc', 'theme_formal_white');
}
}
return true;
}
示例3: xmldb_tool_bloglevelupgrade_install
function xmldb_tool_bloglevelupgrade_install()
{
global $CFG, $OUTPUT;
// this is a hack - admins were long ago instructed to upgrade blog levels,
// the problem is that blog is not supposed to be course level activity!!
if (!empty($CFG->bloglevel_upgrade_complete)) {
// somebody already upgrades, we do not need this any more
unset_config('bloglevel_upgrade_complete');
return;
}
if (!isset($CFG->bloglevel)) {
// fresh install?
return;
}
if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
// inform admins that some settings require attention after upgrade
$site = get_site();
$a = new StdClass();
$a->sitename = $site->fullname;
$a->fixurl = "{$CFG->wwwroot}/{$CFG->admin}/tool/bloglevelupgrade/index.php";
$subject = get_string('bloglevelupgrade', 'tool_bloglevelupgrade');
$description = get_string('bloglevelupgradedescription', 'tool_bloglevelupgrade', $a);
// can not use messaging here because it is not configured yet!
upgrade_log(UPGRADE_LOG_NOTICE, null, $subject, $description);
set_config('tool_bloglevelupgrade_pending', 1);
echo $OUTPUT->notification($description);
}
}
示例4: xmldb_enrol_license_install
function xmldb_enrol_license_install()
{
global $CFG, $DB;
// Migrate welcome message.
if (isset($CFG->sendcoursewelcomemessage)) {
// New course default.
set_config('sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, 'enrol_license');
// Each instance has different setting now.
$DB->set_field('enrol', 'customint4', $CFG->sendcoursewelcomemessage, array('enrol' => 'license'));
unset_config('sendcoursewelcomemessage');
}
// Migrate long-time-no-see feature settings.
if (isset($CFG->longtimenosee)) {
$nosee = $CFG->longtimenosee * 3600 * 24;
set_config('longtimenosee', $nosee, 'enrol_license');
$DB->set_field('enrol', 'customint2', $nosee, array('enrol' => 'license'));
unset_config('longtimenosee');
}
// Enable by default on the site.
$enabledenrols = explode(',', $CFG->enrol_plugins_enabled);
if (!in_array('license', $enabledenrols)) {
$enabledenrols[] = 'license';
set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
}
}
示例5: 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;
}
示例6: xmldb_block_section_links_upgrade
/**
* Upgrade code for the section links block.
*
* @global moodle_database $DB
* @param int $oldversion
* @param object $block
*/
function xmldb_block_section_links_upgrade($oldversion, $block)
{
global $DB;
// 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
if ($oldversion < 2013012200.0) {
// The section links block used to use its own crazy plugin name.
// Here we are converting it to the proper component name.
$oldplugin = 'blocks/section_links';
$newplugin = 'block_section_links';
// Use the proper API here... thats what we should be doing as it ensures any caches etc are cleared
// along the way!
// It may be quicker to just write an SQL statement but that would be reckless.
$config = get_config($oldplugin);
if (!empty($config)) {
foreach ($config as $name => $value) {
set_config($name, $value, $newplugin);
unset_config($name, $oldplugin);
}
}
// Main savepoint reached.
upgrade_block_savepoint(true, 2013012200.0, 'section_links');
}
// 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.
// 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;
}
示例7: 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;
}
示例8: 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, $OUTPUT;
if ($oldversion < 2011030900) {
unset_config('filter_mediaplugin_enable_img');
// migrated to filter_urltolink
unset_config('filter_mediaplugin_enable_ram');
// --> rm
unset_config('filter_mediaplugin_enable_rpm');
// --> rm
unset_config('filter_mediaplugin_enable_ogg');
// --> html5audio
unset_config('filter_mediaplugin_enable_ogv');
// --> html5video
unset_config('filter_mediaplugin_enable_avi');
// --> wmp
unset_config('filter_mediaplugin_enable_wmv');
// --> wmp
unset_config('filter_mediaplugin_enable_mov');
// --> qt
unset_config('filter_mediaplugin_enable_mpg');
// --> qt
upgrade_plugin_savepoint(true, 2011030900, 'filter', 'mediaplugin');
}
return true;
}
示例9: 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;
}
示例10: xmldb_enrol_leap_upgrade
function xmldb_enrol_leap_upgrade($oldversion)
{
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012100702) {
// Set default expiry threshold to 1 day.
$DB->execute("UPDATE {enrol} SET expirythreshold = 86400 WHERE enrol = 'leap' AND expirythreshold = 0");
upgrade_plugin_savepoint(true, 2012100702, 'enrol', 'leap');
}
if ($oldversion < 2012101400) {
// Delete obsoleted settings, now using expiry* prefix to make them more consistent.
unset_config('notifylast', 'enrol_leap');
unset_config('notifyhour', 'enrol_leap');
upgrade_plugin_savepoint(true, 2012101400, 'enrol', 'leap');
}
// 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.
// 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;
}
示例11: 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;
}
示例12: xmldb_qtype_calculated_upgrade
function xmldb_qtype_calculated_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
// MDL-16505.
if ($result && $oldversion < 2008091700) {
//New version in version.php
if (get_config('qtype_datasetdependent', 'version')) {
$result = $result && unset_config('version', 'qtype_datasetdependent');
}
upgrade_plugin_savepoint($result, 2008091700, 'qtype', 'calculated');
}
// let if ($dbman->table_exists()) replace the normal $oldversion test
// as in any case the question question_calculated_options should be created
/// Define table question_calculated_options to be created
$table = new xmldb_table('question_calculated_options');
/// Adding fields to table question_calculated_options
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('synchronize', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
/// Adding keys to table question_calculated_options
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id'));
/// Conditionally launch create table for question_calculated_options
if (!$dbman->table_exists($table)) {
$result = $dbman->create_table($table);
}
/// calculated savepoint reached
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of database_manager methods
/// upgrade_plugin_savepoint($result, YYYYMMDD00, 'qtype', 'calculated');
/// }
return $result;
}
示例13: xmldb_scorm_upgrade
/**
* @global moodle_database $DB
* @param int $oldversion
* @return bool
*/
function xmldb_scorm_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012032100) {
unset_config('updatetime', 'scorm');
upgrade_mod_savepoint(true, 2012032100, 'scorm');
}
// Adding completion fields to scorm table
if ($oldversion < 2012032101) {
$table = new xmldb_table('scorm');
$field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2012032101, 'scorm');
}
return true;
}
示例14: uninstall_cleanup
/**
* Pre-uninstall hook.
*
* This is intended for disabling of plugin, some DB table purging, etc.
*
* NOTE: to be called from uninstall_plugin() only.
* @private
*/
public function uninstall_cleanup()
{
global $DB;
$DB->set_field('course', 'theme', '', array('theme' => $this->name));
$DB->set_field('course_categories', 'theme', '', array('theme' => $this->name));
$DB->set_field('user', 'theme', '', array('theme' => $this->name));
$DB->set_field('mnet_host', 'theme', '', array('theme' => $this->name));
if (get_config('core', 'thememobile') === $this->name) {
unset_config('thememobile');
}
if (get_config('core', 'themetablet') === $this->name) {
unset_config('themetablet');
}
if (get_config('core', 'themelegacy') === $this->name) {
unset_config('themelegacy');
}
$themelist = get_config('core', 'themelist');
if (!empty($themelist)) {
$themes = explode(',', $themelist);
$key = array_search($this->name, $themes);
if ($key !== false) {
unset($themes[$key]);
set_config('themelist', implode(',', $themes));
}
}
parent::uninstall_cleanup();
}
示例15: xmldb_scorm_upgrade
/**
* @global moodle_database $DB
* @param int $oldversion
* @return bool
*/
function xmldb_scorm_upgrade($oldversion)
{
global $CFG, $DB;
$dbman = $DB->get_manager();
// Moodle v2.2.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012032100) {
unset_config('updatetime', 'scorm');
upgrade_mod_savepoint(true, 2012032100, 'scorm');
}
// Adding completion fields to scorm table
if ($oldversion < 2012032101) {
$table = new xmldb_table('scorm');
$field = new xmldb_field('completionstatusrequired', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'timemodified');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('completionscorerequired', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, null, 'completionstatusrequired');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2012032101, 'scorm');
}
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
//rename config var from maxattempts to maxattempt
if ($oldversion < 2012061701) {
$maxattempts = get_config('scorm', 'maxattempts');
$maxattempts_adv = get_config('scorm', 'maxattempts_adv');
set_config('maxattempt', $maxattempts, 'scorm');
set_config('maxattempt_adv', $maxattempts_adv, 'scorm');
unset_config('maxattempts', 'scorm');
//remove old setting.
unset_config('maxattempts_adv', 'scorm');
//remove old setting.
upgrade_mod_savepoint(true, 2012061701, 'scorm');
}
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2015101301) {
// Define table scorm_scoes_item to be created.
$table = new xmldb_table('scorm_scoes_item');
// Adding fields to table scorm_scoes_item.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('scorm_scoes_track_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('field_id', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('field_text', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('field_value', XMLDB_TYPE_CHAR, '255', null, null, null, null);
// Adding keys to table scorm_scoes_item.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally launch create table for scorm_scoes_item.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Scorm savepoint reached.
upgrade_mod_savepoint(true, 2015101301, 'scorm');
}
return true;
}