blocks: MDL-19946 More bug fixes.

This commit is contained in:
tjhunt 2009-07-29 03:51:16 +00:00
parent 715889769d
commit a23bbaa30b
2 changed files with 18 additions and 5 deletions

View File

@ -125,6 +125,14 @@ class block_edit_form extends moodleform {
}
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) {
@ -134,8 +142,8 @@ class block_edit_form extends moodleform {
}
// 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);

View File

@ -878,6 +878,7 @@ class block_manager {
}
$mform = new $classname($editpage->url, $block, $this->page);
print_object($block); // DONOTCOMMIT
$mform->set_data($block->instance);
if ($mform->is_cancelled()) {
@ -897,7 +898,11 @@ class block_manager {
$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;
@ -923,12 +928,12 @@ class block_manager {
} 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);
}