本文整理汇总了PHP中cache_helper::update_site_identifier方法的典型用法代码示例。如果您正苦于以下问题:PHP cache_helper::update_site_identifier方法的具体用法?PHP cache_helper::update_site_identifier怎么用?PHP cache_helper::update_site_identifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache_helper
的用法示例。
在下文中一共展示了cache_helper::update_site_identifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_config
/**
* Set a key in global configuration
*
* Set a key/value pair in both this session's {@link $CFG} global variable
* and in the 'config' database table for future sessions.
*
* Can also be used to update keys for plugin-scoped configs in config_plugin table.
* In that case it doesn't affect $CFG.
*
* A NULL value will delete the entry.
*
* NOTE: this function is called from lib/db/upgrade.php
*
* @param string $name the key to set
* @param string $value the value to set (without magic quotes)
* @param string $plugin (optional) the plugin scope, default null
* @return bool true or exception
*/
function set_config($name, $value, $plugin = null)
{
global $CFG, $DB;
if (empty($plugin)) {
if (!array_key_exists($name, $CFG->config_php_settings)) {
// So it's defined for this invocation at least.
if (is_null($value)) {
unset($CFG->{$name});
} else {
// Settings from db are always strings.
$CFG->{$name} = (string) $value;
}
}
if ($DB->get_field('config', 'name', array('name' => $name))) {
if ($value === null) {
$DB->delete_records('config', array('name' => $name));
} else {
$DB->set_field('config', 'value', $value, array('name' => $name));
}
} else {
if ($value !== null) {
$config = new stdClass();
$config->name = $name;
$config->value = $value;
$DB->insert_record('config', $config, false);
}
}
if ($name === 'siteidentifier') {
cache_helper::update_site_identifier($value);
}
cache_helper::invalidate_by_definition('core', 'config', array(), 'core');
} else {
// Plugin scope.
if ($id = $DB->get_field('config_plugins', 'id', array('name' => $name, 'plugin' => $plugin))) {
if ($value === null) {
$DB->delete_records('config_plugins', array('name' => $name, 'plugin' => $plugin));
} else {
$DB->set_field('config_plugins', 'value', $value, array('id' => $id));
}
} else {
if ($value !== null) {
$config = new stdClass();
$config->plugin = $plugin;
$config->name = $name;
$config->value = $value;
$DB->insert_record('config_plugins', $config, false);
}
}
cache_helper::invalidate_by_definition('core', 'config', array(), $plugin);
}
return true;
}
示例2: xmldb_main_upgrade
//.........这里部分代码省略.........
} else {
if (strpos($filter, 'filter/') === 0) {
$newfilters[] = substr($filter, 7);
}
}
}
$filters = implode(',', $newfilters);
set_config($config, $filters);
}
}
unset($tables);
unset($table);
unset($configs);
unset($newfilters);
unset($filters);
unset($filter);
// Main savepoint reached.
upgrade_main_savepoint(true, 2012123000.0);
}
if ($oldversion < 2013021100.01) {
// Make sure there are no bogus nulls in old MySQL tables.
$DB->set_field_select('user', 'password', '', "password IS NULL");
// Changing precision of field password on table user to (255).
$table = new xmldb_table('user');
$field = new xmldb_field('password', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'username');
// Launch change of precision for field password.
$dbman->change_field_precision($table, $field);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013021100.01);
}
if ($oldversion < 2013021800.0) {
// Add the site identifier to the cache config's file.
$siteidentifier = $DB->get_field('config', 'value', array('name' => 'siteidentifier'));
cache_helper::update_site_identifier($siteidentifier);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013021800.0);
}
if ($oldversion < 2013021801.0) {
// Fixing possible wrong MIME types for SMART Notebook files.
$extensions = array('%.gallery', '%.galleryitem', '%.gallerycollection', '%.nbk', '%.notebook', '%.xbk');
$select = $DB->sql_like('filename', '?', false);
foreach ($extensions as $extension) {
$DB->set_field_select('files', 'mimetype', 'application/x-smarttech-notebook', $select, array($extension));
}
upgrade_main_savepoint(true, 2013021801.0);
}
if ($oldversion < 2013021801.01) {
// This upgrade step is re-written under MDL-38228 (see below).
/*
// Retrieve the list of course_sections as a recordset to save memory
$coursesections = $DB->get_recordset('course_sections', null, 'course, id', 'id, course, sequence');
foreach ($coursesections as $coursesection) {
// Retrieve all of the actual modules in this course and section combination to reduce DB calls
$actualsectionmodules = $DB->get_records('course_modules',
array('course' => $coursesection->course, 'section' => $coursesection->id), '', 'id, section');
// Break out the current sequence so that we can compare it
$currentsequence = explode(',', $coursesection->sequence);
$newsequence = array();
// Check each of the modules in the current sequence
foreach ($currentsequence as $module) {
if (isset($actualsectionmodules[$module])) {
$newsequence[] = $module;
// We unset the actualsectionmodules so that we don't get duplicates and that we can add orphaned
// modules later
示例3: xmldb_main_upgrade
//.........这里部分代码省略.........
if (strpos($filter, '/') === false) {
$newfilters[] = $filter;
} else {
if (strpos($filter, 'filter/') === 0) {
$newfilters[] = substr($filter, 7);
}
}
}
$filters = implode(',', $newfilters);
set_config($config, $filters);
}
}
unset($tables);
unset($table);
unset($configs);
unset($newfilters);
unset($filters);
unset($filter);
// Main savepoint reached.
upgrade_main_savepoint(true, 2012123000.0);
}
if ($oldversion < 2013021100.01) {
// Changing precision of field password on table user to (255).
$table = new xmldb_table('user');
$field = new xmldb_field('password', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'username');
// Launch change of precision for field password.
$dbman->change_field_precision($table, $field);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013021100.01);
}
if ($oldversion < 2013021800.0) {
// Add the site identifier to the cache config's file.
$siteidentifier = $DB->get_field('config', 'value', array('name' => 'siteidentifier'));
cache_helper::update_site_identifier($siteidentifier);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013021800.0);
}
if ($oldversion < 2013021801.0) {
// Fixing possible wrong MIME types for SMART Notebook files.
$extensions = array('%.gallery', '%.galleryitem', '%.gallerycollection', '%.nbk', '%.notebook', '%.xbk');
$select = $DB->sql_like('filename', '?', false);
foreach ($extensions as $extension) {
$DB->set_field_select('files', 'mimetype', 'application/x-smarttech-notebook', $select, array($extension));
}
upgrade_main_savepoint(true, 2013021801.0);
}
if ($oldversion < 2013021801.01) {
// Retrieve the list of course_sections as a recordset to save memory
$coursesections = $DB->get_recordset('course_sections', null, 'course, id', 'id, course, sequence');
foreach ($coursesections as $coursesection) {
// Retrieve all of the actual modules in this course and section combination to reduce DB calls
$actualsectionmodules = $DB->get_records('course_modules', array('course' => $coursesection->course, 'section' => $coursesection->id), '', 'id, section');
// Break out the current sequence so that we can compare it
$currentsequence = explode(',', $coursesection->sequence);
$newsequence = array();
// Check each of the modules in the current sequence
foreach ($currentsequence as $module) {
if (isset($actualsectionmodules[$module])) {
$newsequence[] = $module;
// We unset the actualsectionmodules so that we don't get duplicates and that we can add orphaned
// modules later
unset($actualsectionmodules[$module]);
}
}
// Append any modules which have somehow been orphaned
foreach ($actualsectionmodules as $module) {