本文整理汇总了PHP中blocks_add_default_system_blocks函数的典型用法代码示例。如果您正苦于以下问题:PHP blocks_add_default_system_blocks函数的具体用法?PHP blocks_add_default_system_blocks怎么用?PHP blocks_add_default_system_blocks使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了blocks_add_default_system_blocks函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_plugins_blocks
//.........这里部分代码省略.........
\core\task\manager::reset_scheduled_tasks_for_component($component);
message_update_providers($component);
\core\message\inbound\manager::update_handlers_for_component($component);
upgrade_plugin_mnet_functions($component);
$endcallback($component, true, $verbose);
}
}
}
if (empty($installedversion)) { // block not installed yet, so install it
$conflictblock = array_search($blocktitle, $blocktitles);
if ($conflictblock !== false) {
// Duplicate block titles are not allowed, they confuse people
// AND PHP's associative arrays ;)
throw new plugin_defective_exception($component, get_string('blocknameconflict', 'error', (object)array('name'=>$block->name, 'conflict'=>$conflictblock)));
}
$startcallback($component, true, $verbose);
if (file_exists($fullblock.'/db/install.xml')) {
$DB->get_manager()->install_from_xmldb_file($fullblock.'/db/install.xml');
}
$block->id = $DB->insert_record('block', $block);
upgrade_block_savepoint(true, $plugin->version, $block->name, false);
if (file_exists($fullblock.'/db/install.php')) {
require_once($fullblock.'/db/install.php');
// Set installation running flag, we need to recover after exception or error
set_config('installrunning', 1, 'block_'.$blockname);
$post_install_function = 'xmldb_block_'.$blockname.'_install';
$post_install_function();
unset_config('installrunning', 'block_'.$blockname);
}
$blocktitles[$block->name] = $blocktitle;
// Install various components
update_capabilities($component);
log_update_descriptions($component);
external_update_descriptions($component);
events_update_definition($component);
\core\task\manager::reset_scheduled_tasks_for_component($component);
message_update_providers($component);
\core\message\inbound\manager::update_handlers_for_component($component);
upgrade_plugin_mnet_functions($component);
$endcallback($component, true, $verbose);
} else if ($installedversion < $plugin->version) {
$startcallback($component, false, $verbose);
if (is_readable($fullblock.'/db/upgrade.php')) {
require_once($fullblock.'/db/upgrade.php'); // defines new upgrading function
$newupgrade_function = 'xmldb_block_'.$blockname.'_upgrade';
$result = $newupgrade_function($installedversion, $block);
} else {
$result = true;
}
$installedversion = $DB->get_field('config_plugins', 'value', array('name'=>'version', 'plugin'=>$component)); // No caching!
$currblock = $DB->get_record('block', array('name'=>$block->name));
if ($installedversion < $plugin->version) {
// store version if not already there
upgrade_block_savepoint($result, $plugin->version, $block->name, false);
}
if ($currblock->cron != $block->cron) {
// update cron flag if needed
$DB->set_field('block', 'cron', $block->cron, array('id' => $currblock->id));
}
// Upgrade various components
update_capabilities($component);
log_update_descriptions($component);
external_update_descriptions($component);
events_update_definition($component);
\core\task\manager::reset_scheduled_tasks_for_component($component);
message_update_providers($component);
\core\message\inbound\manager::update_handlers_for_component($component);
upgrade_plugin_mnet_functions($component);
$endcallback($component, false, $verbose);
} else if ($installedversion > $plugin->version) {
throw new downgrade_exception($component, $installedversion, $plugin->version);
}
}
// Finally, if we are in the first_install of BLOCKS setup frontpage and admin page blocks
if ($first_install) {
//Iterate over each course - there should be only site course here now
if ($courses = $DB->get_records('course')) {
foreach ($courses as $course) {
blocks_add_default_course_blocks($course);
}
}
blocks_add_default_system_blocks();
}
}
示例2: upgrade_plugins_blocks
//.........这里部分代码省略.........
}
$block = new object();
// This may be used to update the db below
$block->name = $blockname;
// The name MUST match the directory
$block->version = $blockobj->get_version();
$block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
$block->multiple = $blockobj->instance_allow_multiple() ? 1 : 0;
if (empty($block->version)) {
throw new plugin_defective_exception($component, 'Missing block version.');
}
$currblock = $DB->get_record('block', array('name' => $block->name));
if (file_exists($fullblock . '/db/install.php')) {
if (get_config('block_' . $blockname, 'installrunning')) {
require_once $fullblock . '/db/install.php';
$recover_install_function = 'xmldb_block_' . $blockname . '_install_recovery';
if (function_exists($recover_install_function)) {
$startcallback($component, true, $verbose);
$recover_install_function();
unset_config('installrunning', 'block_' . $blockname);
// Install various components
update_capabilities($component);
events_update_definition($component);
message_update_providers($component);
$endcallback($component, true, $verbose);
}
}
}
if (empty($currblock->version)) {
// block not installed yet, so install it
// If it allows multiples, start with it enabled
$conflictblock = array_search($blocktitle, $blocktitles);
if ($conflictblock !== false) {
// Duplicate block titles are not allowed, they confuse people
// AND PHP's associative arrays ;)
throw new plugin_defective_exception($component, get_string('blocknameconflict', '', (object) array('name' => $block->name, 'conflict' => $conflictblock)));
}
$startcallback($component, true, $verbose);
if (file_exists($fullblock . '/db/install.xml')) {
$DB->get_manager()->install_from_xmldb_file($fullblock . '/db/install.xml');
}
$block->id = $DB->insert_record('block', $block);
if (file_exists($fullblock . '/db/install.php')) {
require_once $fullblock . '/db/install.php';
// Set installation running flag, we need to recover after exception or error
set_config('installrunning', 1, 'block_' . $blockname);
$post_install_function = 'xmldb_block_' . $blockname . '_install';
$post_install_function();
unset_config('installrunning', 'block_' . $blockname);
}
$blocktitles[$block->name] = $blocktitle;
// Install various components
update_capabilities($component);
events_update_definition($component);
message_update_providers($component);
$endcallback($component, true, $verbose);
} else {
if ($currblock->version < $block->version) {
$startcallback($component, false, $verbose);
if (is_readable($fullblock . '/db/upgrade.php')) {
require_once $fullblock . '/db/upgrade.php';
// defines new upgrading function
$newupgrade_function = 'xmldb_block_' . $blockname . '_upgrade';
$result = $newupgrade_function($currblock->version, $block);
} else {
$result = true;
}
$currblock = $DB->get_record('block', array('name' => $block->name));
if ($currblock->version < $block->version) {
// store version if not already there
upgrade_block_savepoint($result, $block->version, $block->name, false);
}
if ($currblock->cron != $block->cron) {
// update cron flag if needed
$currblock->cron = $block->cron;
$DB->update_record('block', $currblock);
}
// Upgrade various componebts
update_capabilities($component);
events_update_definition($component);
message_update_providers($component);
$endcallback($component, false, $verbose);
} else {
if ($currblock->version > $block->version) {
throw new downgrade_exception($component, $currblock->version, $block->version);
}
}
}
}
// Finally, if we are in the first_install of BLOCKS setup frontpage and admin page blocks
if ($first_install) {
//Iterate over each course - there should be only site course here now
if ($courses = $DB->get_records('course')) {
foreach ($courses as $course) {
blocks_add_default_course_blocks($course);
}
}
blocks_add_default_system_blocks();
}
}