mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 19:36:41 +02:00
Now scheduled backup supports new blocks.
Moved blocks code to library. Fixed a missing global preventing restore to work.
This commit is contained in:
parent
00363c7033
commit
94df8a48c3
4 changed files with 72 additions and 53 deletions
|
@ -120,60 +120,12 @@
|
|||
|
||||
//Bring back the course blocks
|
||||
if($status) {
|
||||
echo '<li>'.get_string('creatingblocks');
|
||||
//If we are deleting and bringing into a course or making a new course, same situation
|
||||
if($restore->restoreto == 0 || $restore->restoreto == 2) {
|
||||
delete_records('block_instance', 'pageid', $course_header->course_id, 'pagetype', MOODLE_PAGE_COURSE);
|
||||
if (empty($info->backup_block_format)) { // This is a backup from Moodle < 1.5
|
||||
if (empty($course_header->blockinfo)) {
|
||||
// Looks like it's from Moodle < 1.3. Let's give the course default blocks...
|
||||
$newpage = page_create_object(MOODLE_PAGE_COURSE, $course_header->course_id);
|
||||
blocks_repopulate_page($newpage);
|
||||
|
||||
} else {
|
||||
// We just have a blockinfo field, this is a legacy 1.4 or 1.3 backup
|
||||
$blockrecords = get_records_select('block', '', '', 'name, id');
|
||||
$temp_blocks_l = array();
|
||||
$temp_blocks_r = array();
|
||||
@list($temp_blocks_l, $temp_blocks_r) = explode(':', $course_header->blockinfo);
|
||||
$temp_blocks = array(BLOCK_POS_LEFT => explode(',', $temp_blocks_l), BLOCK_POS_RIGHT => explode(',', $temp_blocks_r));
|
||||
foreach($temp_blocks as $blockposition => $blocks) {
|
||||
$blockweight = 0;
|
||||
foreach($blocks as $blockname) {
|
||||
if(!isset($blockrecords[$blockname])) {
|
||||
// We don't know anything about this block!
|
||||
continue;
|
||||
}
|
||||
$blockinstance = new stdClass;
|
||||
// Remove any - prefix before doing the name-to-id mapping
|
||||
if(substr($blockname, 0, 1) == '-') {
|
||||
$blockname = substr($blockname, 1);
|
||||
$blockinstance->visible = 0;
|
||||
}
|
||||
else {
|
||||
$blockinstance->visible = 1;
|
||||
}
|
||||
$blockinstance->blockid = $blockrecords[$blockname]->id;
|
||||
$blockinstance->pageid = $course_header->course_id;
|
||||
$blockinstance->pagetype = MOODLE_PAGE_COURSE;
|
||||
$blockinstance->position = $blockposition;
|
||||
$blockinstance->weight = $blockweight;
|
||||
if(!$status = insert_record('block_instance', $blockinstance)) {
|
||||
notify('Error while creating the course blocks');
|
||||
}
|
||||
++$blockweight;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '<li>'.get_string('creatingblocks');
|
||||
if (!$status = restore_create_blocks($restore, $xml_file)) {
|
||||
notify("Error while creating the course blocks");
|
||||
}
|
||||
else if($info->backup_block_format == 'instances') {
|
||||
if(!$status = restore_create_block_instances($restore,$xml_file)) {
|
||||
notify('Error while creating the course blocks');
|
||||
}
|
||||
}
|
||||
}
|
||||
//Otherwise we are adding the backup into an existing course; do nothing
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue