}
function set_data($defaults) {
+ // Prefix bui_ on all the core field names.
+ $blockfields = array('showinsubcontexts', 'pagetypepattern', 'subpagepattern',
+ 'defaultregion', 'defaultweight', 'visible', 'region', 'weight');
+ foreach ($blockfields as $field) {
+ $newname = 'bui_' . $field;
+ $defaults->$newname = $defaults->$field;
+ }
+
// Copy block config into config_ fields.
if (!empty($this->block->config)) {
foreach ($this->block->config as $field => $value) {
}
// Munge ->subpagepattern becuase HTML selects don't play nicely with NULLs.
- if (empty($defaults->subpagepattern)) {
- $defaults->subpagepattern = '%@NULL@%';
+ if (empty($defaults->bui_subpagepattern)) {
+ $defaults->bui_subpagepattern = '%@NULL@%';
}
parent::set_data($defaults);
}
$mform = new $classname($editpage->url, $block, $this->page);
+ print_object($block); // DONOTCOMMIT
$mform->set_data($block->instance);
if ($mform->is_cancelled()) {
$bi->defaultweight = $data->bui_defaultweight;
$DB->update_record('block_instances', $bi);
- $config = clone($block->config);
+ if (!empty($block->config)) {
+ $config = clone($block->config);
+ } else {
+ $config = new stdClass;
+ }
foreach ($data as $configfield => $value) {
if (strpos($configfield, 'config_') !== 0) {
continue;
} else if ($needbprecord) {
$bp->blockinstanceid = $block->instance->id;
- $bp->contextid = $this->page->contextid;
+ $bp->contextid = $this->page->context->id;
$bp->pagetype = $this->page->pagetype;
if ($this->page->subpage) {
$bp->subpage = $this->page->subpage;
} else {
- $bp->subpage = null;
+ $bp->subpage = '';
}
$DB->insert_record('block_positions', $bp);
}