MDL-87017 blocks: Provide page context to page_type_list functions
- The current context may be necessary when deleting a frontpage block displayed on every page with javascript disabled - The current context may be necessary when a frontpage block is displayed on every page and the question bank is viewed - Also handle a NULL currentcontext for question_page_type_list() correctly
This commit is contained in:
@@ -1469,7 +1469,7 @@ class block_manager {
|
||||
if ($parentcontext->id != $systemcontext->id && is_inside_frontpage($parentcontext)) {
|
||||
$messagestring->pagetype = get_string('showonfrontpageandsubs', 'block');
|
||||
} else {
|
||||
$pagetypes = generate_page_type_patterns($this->page->pagetype, $parentcontext);
|
||||
$pagetypes = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context);
|
||||
$messagestring->pagetype = $block->instance->pagetypepattern;
|
||||
if (isset($pagetypes[$block->instance->pagetypepattern])) {
|
||||
$messagestring->pagetype = $pagetypes[$block->instance->pagetypepattern];
|
||||
@@ -1686,7 +1686,7 @@ class block_manager {
|
||||
if ($parentcontext->id != $systemcontext->id && is_inside_frontpage($parentcontext)) {
|
||||
$messagestring->pagetype = get_string('showonfrontpageandsubs', 'block');
|
||||
} else {
|
||||
$pagetypes = generate_page_type_patterns($this->page->pagetype, $parentcontext);
|
||||
$pagetypes = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context);
|
||||
$messagestring->pagetype = $block->instance->pagetypepattern;
|
||||
if (isset($pagetypes[$block->instance->pagetypepattern])) {
|
||||
$messagestring->pagetype = $pagetypes[$block->instance->pagetypepattern];
|
||||
|
||||
@@ -1825,7 +1825,7 @@ function question_page_type_list($pagetype, $parentcontext, $currentcontext): ar
|
||||
'question-export' => get_string('page-question-export', 'question'),
|
||||
'question-import' => get_string('page-question-import', 'question')
|
||||
];
|
||||
if ($currentcontext->contextlevel == CONTEXT_COURSE) {
|
||||
if ($currentcontext && $currentcontext->contextlevel == CONTEXT_COURSE) {
|
||||
require_once($CFG->dirroot . '/course/lib.php');
|
||||
return array_merge(course_page_type_list($pagetype, $parentcontext, $currentcontext), $types);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user