mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
blocks: MDL-19946 More bug fixes.
This commit is contained in:
parent
715889769d
commit
a23bbaa30b
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user