if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string ("from")." ".get_string("modulenameplural",$name);
}
- $status = $function_name($restore);
+ $status = $function_name($restore) && $status;
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
// Process all html text also in blocks too
if (!defined('RESTORE_SILENTLY')) {
- echo '<li>' . get_string ('from') . ' ' . get_string('blocks');
+ echo '<li>'.get_string ('from').' '.get_string('blocks');
}
- if (!empty($restore->blockinstanceids)) {
- $blocks = blocks_get_record();
- $instances = get_records_list('block_instance', 'id', implode(',', $restore->blockinstanceids), '', 'id,blockid,configdata');
- foreach ($instances as $instance) {
- if (!isset($blocks[$instance->blockid]->blockobject)) {
- $blocks[$instance->blockid]->blockobject = block_instance($blocks[$instance->blockid]->name);
- }
- $config = unserialize(base64_decode($instance->configdata));
- if ($blocks[$instance->blockid]->blockobject->restore_decode_absolute_links_in_config($config)) {
- $instance->configdata = base64_encode(serialize($config));
- $status = $status && update_record('block_instance', $instance);
- }
+
+ if ($blocks = get_records('block', 'visible', 1)) {
+ foreach ($blocks as $block) {
+ $blockobject = block_instance($block->name);
+ $blockobject->decode_content_links_caller($restore);
}
}
+
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
if (!defined('RESTORE_SILENTLY')) {
echo '<li>' . get_string('from') . ' ' . get_string('questions', 'quiz');
}
- $status = question_decode_content_links_caller($restore);
+ $status = question_decode_content_links_caller($restore) && $status;
if (!defined('RESTORE_SILENTLY')) {
echo '</li>';
}
$content = $function_name($content,$restore);
}
}
+
+ // For each block, call its encode_content_links method
+ static $blockobjects = null;
+ if (!isset($blockobjects)) {
+ $blockobjects = array();
+ if ($blocks = get_records('block', 'visible', 1)) {
+ foreach ($blocks as $block) {
+ if ($blockobject = block_instance($block->name)) {
+ $blockobjects[] = $blockobject;
+ }
+ }
+ }
+ }
+
+ foreach ($blockobjects as $blockobject) {
+ $content = $blockobject->decode_content_links($content,$restore);
+ }
+
return $content;
}
// Looks like it's from Moodle < 1.3. Let's give the course default blocks...
$newpage = page_create_object(PAGE_COURSE_VIEW, $restore->course_id);
blocks_repopulate_page($newpage);
- } else {
+ } else if (!empty($CFG->showblocksonmodpages)) {
// 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();
function restore_create_block_instances($restore,$xml_file) {
global $CFG;
$status = true;
- $CFG->restore_blockinstanceids = array();
-
- // Tracks which blocks we create during the restore.
- // This is used in restore_decode_content_links.
- $restore->blockinstanceids = array();
//Check it exists
if (!file_exists($xml_file)) {
if($instance->pagetype == PAGE_COURSE_VIEW) {
// This one's easy...
$instance->pageid = $restore->course_id;
- }
- else {
+
+ } else if (!empty($CFG->showblocksonmodpages)) {
$parts = explode('-', $instance->pagetype);
if($parts[0] == 'mod') {
if(!$restore->mods[$parts[1]]->restore) {
// Not invented here ;-)
continue;
}
+
+ } else {
+ // do not restore activity blocks if disabled
+ continue;
}
if(!isset($pageinstances[$instance->pagetype])) {
$pageinstances[$instance->pagetype][$instance->pageid][] = $instance;
}
- $blocks = get_records_select('block', '', '', 'name, id, multiple');
+ $blocks = get_records_select('block', 'visible = 1', '', 'name, id, multiple');
// For each type of page we have restored
foreach($pageinstances as $thistypeinstances) {
}
if ($instance->id = insert_record('block_instance', $instance)) {
- // Save the new ID for later+
- $CFG->restore_blockinstanceids[] = $instance->id;
// Create block instance
if (!$blockobj = block_instance($instance->name, $instance)) {
$status = false;
break;
}
// Run the block restore if needed
- if ($blockobj->backuprestore_enabled()) {
+ if ($blockobj->backuprestore_instancedata_used()) {
// Get restore information
$data = backup_getid($restore->backup_unique_code,'block_instance',$oldid);
$data->new_id = $instance->id; // For completeness
if ($oldid) {
backup_putid ($restore->backup_unique_code,"block_instance",$oldid,$instance->id);
}
- $restore->blockinstanceids[] = $instance->id;
+
} else {
$status = false;
break;
//Check if we are into BLOCKS zone
//if ($this->tree[3] == "BLOCKS") //Debug
// echo $this->level.str_repeat(" ",$this->level*2)."<".$tagName."><br />\n"; //Debug
-
-
+
//If we are under a BLOCK tag under a BLOCKS zone, accumule it
if (isset($this->tree[4]) and isset($this->tree[3])) { //
if ($this->tree[4] == "BLOCK" and $this->tree[3] == "BLOCKS") {
//if (trim($this->content)) //Debug
// echo "C".str_repeat(" ",($this->level+2)*2).$this->getContents()."<br />\n"; //Debug
//echo $this->level.str_repeat(" ",$this->level*2)."</".$tagName."><br />\n"; //Debug
-
+
// Collect everything into $this->temp
if (!isset($this->temp)) {
$this->temp = "";
}
$this->temp .= htmlspecialchars(trim($this->content))."</".$tagName.">";
-
+
//Dependig of different combinations, do different things
if ($this->level == 4) {
switch ($tagName) {
//We've finalized a block, get it
$this->info->instances[] = $this->info->tempinstance;
unset($this->info->tempinstance);
-
+
//Also, xmlize INSTANCEDATA and save to db
//Prepend XML standard header to info gathered
$xml_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".$this->temp;
}
//Reset temp
unset($this->temp);
-
+
break;
default:
die($tagName);