MDL-30669 - blocks: Added a warning when deleting blocks that have multiple displays set.
Also added a fix to the function course_page_type_list(). It was making a call to get_context_info_array() which will generate an error if $currentcontext is not set.
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
a515bc1b58
commit
f3f1f5d3d0
+11
-9
@@ -4458,16 +4458,18 @@ class course_request {
|
||||
* @param stdClass $currentcontext Current context of block
|
||||
*/
|
||||
function course_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
// if above course context ,display all course fomats
|
||||
list($currentcontext, $course, $cm) = get_context_info_array($currentcontext->id);
|
||||
if ($course->id == SITEID) {
|
||||
return array('*'=>get_string('page-x', 'pagetype'));
|
||||
} else {
|
||||
return array('*'=>get_string('page-x', 'pagetype'),
|
||||
'course-*'=>get_string('page-course-x', 'pagetype'),
|
||||
'course-view-*'=>get_string('page-course-view-x', 'pagetype')
|
||||
);
|
||||
// $currentcontext could be null, get_context_info_array() will throw an error if this is the case.
|
||||
if (isset($currentcontext)) {
|
||||
// if above course context ,display all course fomats
|
||||
list($currentcontext, $course, $cm) = get_context_info_array($currentcontext->id);
|
||||
if ($course->id == SITEID) {
|
||||
return array('*'=>get_string('page-x', 'pagetype'));
|
||||
}
|
||||
}
|
||||
return array('*'=>get_string('page-x', 'pagetype'),
|
||||
'course-*'=>get_string('page-course-x', 'pagetype'),
|
||||
'course-view-*'=>get_string('page-course-view-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,7 @@ $string['defaultweight_help'] = 'The default weight allows you to choose roughly
|
||||
$string['deletecheck'] = 'Delete {$a} block?';
|
||||
$string['deleteblock'] = 'Delete {$a} block';
|
||||
$string['deleteblockcheck'] = 'Are you sure that you want to delete this block titled {$a}?';
|
||||
$string['deleteblockwarning'] = '<p>You are about to delete a block that appears elsewhere.</p><p>Original block location: {$a->location}<br />Display on page types: {$a->pagetype}</p><p>Are you sure you want to continue?</p>';
|
||||
$string['hideblock'] = 'Hide {$a} block';
|
||||
$string['hidedockpanel'] = 'Hide the dock panel';
|
||||
$string['hidepanel'] = 'Hide panel';
|
||||
|
||||
@@ -1162,6 +1162,27 @@ class block_manager {
|
||||
$strdeletecheck = get_string('deletecheck', 'block', $blocktitle);
|
||||
$message = get_string('deleteblockcheck', 'block', $blocktitle);
|
||||
|
||||
// If the block is being shown in sub contexts display a warning.
|
||||
if ($block->instance->showinsubcontexts == 1) {
|
||||
$parentcontext = context::instance_by_id($block->instance->parentcontextid);
|
||||
$systemcontext = context_system::instance();
|
||||
$messagestring = new stdClass();
|
||||
$messagestring->location = $parentcontext->get_context_name();
|
||||
|
||||
// Checking for blocks that may have visibility on the front page and pages added on that.
|
||||
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);
|
||||
$messagestring->pagetype = $block->instance->pagetypepattern;
|
||||
if (isset($pagetypes[$block->instance->pagetypepattern])) {
|
||||
$messagestring->pagetype = $pagetypes[$block->instance->pagetypepattern];
|
||||
}
|
||||
}
|
||||
|
||||
$message = get_string('deleteblockwarning', 'block', $messagestring);
|
||||
}
|
||||
|
||||
$PAGE->navbar->add($strdeletecheck);
|
||||
$PAGE->set_title($blocktitle . ': ' . $strdeletecheck);
|
||||
$PAGE->set_heading($site->fullname);
|
||||
|
||||
Reference in New Issue
Block a user