mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
blocklib: MDL-19010 finally fix the regressions that mean that you could not create a new course.
This commit is contained in:
parent
ac9e220734
commit
1d00ec6a6a
@ -3536,8 +3536,7 @@ function create_course($data) {
|
||||
$course = $DB->get_record('course', array('id'=>$newcourseid));
|
||||
|
||||
// Setup the blocks
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $course->id);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
blocks_add_default_course_blocks($course);
|
||||
|
||||
update_restricted_mods($course, $allowedmods);
|
||||
|
||||
|
@ -3913,6 +3913,9 @@ function admin_externalpage_setup($section, $extrabutton = '',
|
||||
}
|
||||
$PAGE->set_url(str_replace($CFG->wwwroot . '/', '', $actualurl),
|
||||
array_merge($extraurlparams, array('section' => $section)));
|
||||
if (strpos($PAGE->pagetype, 'admin-') !== 0) {
|
||||
$PAGE->set_pagetype('admin-' . $PAGE->pagetype);
|
||||
}
|
||||
|
||||
if (empty($extpage) or !($extpage instanceof admin_externalpage)) {
|
||||
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
|
@ -54,8 +54,20 @@ require_once($CFG->libdir.'/pagelib.php');
|
||||
* only at the point that the load_blocks() method is called. It is the caller's
|
||||
* responsibility to ensure that those fields do not subsequently change.
|
||||
*
|
||||
* The implements ArrayAccess is a horrible backwards_compatibility thing.
|
||||
* TODO explain!
|
||||
*
|
||||
* Note about the weird 'implements ArrayAccess' part of the declaration:
|
||||
*
|
||||
* ArrayAccess is a magic PHP5 thing. If your class implements the ArrayAccess
|
||||
* interface, then other code can use the $object[$index] syntax, and it will
|
||||
* call the offsetGet method of the object.
|
||||
* See http://php.net/manual/en/class.arrayaccess.php
|
||||
*
|
||||
* So, why do we do this here? Basically, some of the deprecated blocks methods
|
||||
* like blocks_setup used to return an array of blocks on the page, with array
|
||||
* keys BLOCK_POS_LEFT, BLOCK_POS_RIGHT. We can keep legacy code that calls those
|
||||
* deprecated functions mostly working by changing blocks_setup to return the
|
||||
* block_manger object, and then use 'implements ArrayAccess' so that the right
|
||||
* thing happens when legacy code does something like $pageblocks[BLOCK_POS_LEFT].
|
||||
*/
|
||||
class block_manager implements ArrayAccess {
|
||||
|
||||
@ -1355,8 +1367,8 @@ function blocks_add_default_course_blocks($course) {
|
||||
$blocknames = blocks_parse_default_blocks_list($CFG->$defaultblocks);
|
||||
|
||||
} else {
|
||||
$formatconfig = $CFG->dirroot.'/course/format/'.$pageformat.'/config.php';
|
||||
if (file_exists_and_readable($formatconfig)) {
|
||||
$formatconfig = $CFG->dirroot.'/course/format/'.$course->format.'/config.php';
|
||||
if (is_readable($formatconfig)) {
|
||||
require($formatconfig);
|
||||
}
|
||||
if (!empty($format['defaultblocks'])) {
|
||||
@ -1382,9 +1394,6 @@ function blocks_add_default_course_blocks($course) {
|
||||
|
||||
$page = new moodle_page();
|
||||
$page->set_course($course);
|
||||
print_object($page); // DONOTCOMMIT
|
||||
print_object($pagetypepattern); // DONOTCOMMIT
|
||||
print_object($blocknames); // DONOTCOMMIT
|
||||
$page->blocks->add_blocks($blocknames, $pagetypepattern);
|
||||
}
|
||||
|
||||
|
@ -2305,46 +2305,46 @@ body#course-index .courseboxes {
|
||||
padding:20px;
|
||||
}
|
||||
|
||||
body#course-category .rolelink {
|
||||
body#admin-course-category .rolelink {
|
||||
text-align:right;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
body#course-category .addcategory {
|
||||
body#admin-course-category .addcategory {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
body#course-index .buttons .singlebutton,
|
||||
body#course-category .buttons .singlebutton {
|
||||
body#admin-course-index .buttons .singlebutton,
|
||||
body#admin-course-category .buttons .singlebutton {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
body#course-index .buttons,
|
||||
body#course-category .buttons {
|
||||
body#admin-course-index .buttons,
|
||||
body#admin-course-category .buttons {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
body#course-index #middle-column .editcourse {
|
||||
body#admin-course-index #middle-column .editcourse {
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
margin-top:20px;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
|
||||
body#course-index #middle-column .editcourse th,
|
||||
body#course-index #middle-column .editcourse td {
|
||||
body#admin-course-index #middle-column .editcourse th,
|
||||
body#admin-course-index #middle-column .editcourse td {
|
||||
padding-left:10px;
|
||||
padding-right:10px;
|
||||
}
|
||||
|
||||
body#course-index #middle-column .editcourse .count {
|
||||
body#admin-course-index #middle-column .editcourse .count {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
body#course-index .singlebutton,
|
||||
body#course-index .addcategory {
|
||||
body#admin-course-index .singlebutton,
|
||||
body#admin-course-index .addcategory {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user