--- ../../moodle-1.7/lib/blocklib.php 2006-10-26 14:55:24.000000000 +0100 +++ blocklib.php 2006-12-04 20:34:07.000000000 +0000 @@ -907,26 +907,29 @@ // Here we slyly count $posblocks and NOT $positions. This can actually make a difference // if the textual representation has undefined slots in the end. So we only work with as many // positions were retrieved, not with all the page says it has available. + $pageformat = $page->get_format_name(); $numpositions = count($posblocks); for($i = 0; $i < $numpositions; ++$i) { $position = $positions[$i]; $blocknames = explode(',', $posblocks[$i]); $weight = 0; foreach($blocknames as $blockname) { - $newinstance = new stdClass; - $newinstance->blockid = $idforname[$blockname]; - $newinstance->pageid = $page->get_id(); - $newinstance->pagetype = $page->get_type(); - $newinstance->position = $position; - $newinstance->weight = $weight; - $newinstance->visible = 1; - $newinstance->configdata = ''; - - if(!empty($newinstance->blockid)) { - // Only add block if it was recognized - insert_record('block_instance', $newinstance); - ++$weight; - } + if( blocks_name_allowed_in_format($blockname, $pageformat) ){ + $newinstance = new stdClass; + $newinstance->blockid = $idforname[$blockname]; + $newinstance->pageid = $page->get_id(); + $newinstance->pagetype = $page->get_type(); + $newinstance->position = $position; + $newinstance->weight = $weight; + $newinstance->visible = 1; + $newinstance->configdata = ''; + + if(!empty($newinstance->blockid)) { + // Only add block if it was recognized + insert_record('block_instance', $newinstance); + ++$weight; + } + } } }