if ($newid = $DB->insert_record('course', $newsite)) {
// Site created, add blocks for it
- $page = page_create_object(PAGE_COURSE_VIEW, $newid);
- blocks_repopulate_page($page); // Return value not checked because you can always edit later
+ blocks_add_default_course_blocks($DB->get_record('course', array('id' => $newid)));
// create default course category
$cat = get_course_category();
if (empty($backup_block_format)) { // This is a backup from Moodle < 1.5
if (empty($blockinfo)) {
// Looks like it's from Moodle < 1.3. Let's give the course default blocks...
- $newpage = page_create_object(PAGE_COURSE_VIEW, $restore->course_id);
- blocks_repopulate_page($newpage);
+ blocks_add_default_course_blocks($DB->get_record('course', array('id' => $restore->course_id)));
} else {
// We just have a blockinfo field, this is a legacy 1.4 or 1.3 backup
$blockrecords = $DB->get_records('block', null, '', 'name, id');
}
/// Insert the record.
- if ($courseid = $DB->insert_record("course",$course)) {
- $page = page_create_object(PAGE_COURSE_VIEW, $courseid);
- blocks_repopulate_page($page); // Return value not checked because you can always edit later
+ if ($courseid = $DB->insert_record('course', $course)) {
+ $course = $DB->get_record('course', array('id' => $courseid));
+ blocks_add_default_course_blocks($course);
$context = get_context_instance(CONTEXT_COURSE, $courseid);
role_assign($CFG->creatornewroleid, $teacherid, 0, $context->id); // assing teacher role
- $course->id = $courseid;
- if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) { // if we're all or requested we're ok.
+ if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) {
+ // if we're all or requested we're ok.
$allowedmods = explode(',',$CFG->defaultallowedmodules);
update_restricted_mods($course,$allowedmods);
}
$section->course = $newcourseid; // Create a default section.
$section->section = 0;
$section->id = $DB->insert_record("course_sections", $section);
- $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
- blocks_repopulate_page($page); // Return value no
+ $course = $DB->get_record('course', array('id' => $newcourseid));
+ blocks_add_default_course_blocks($course);
if (!$skip_fix_course_sortorder){
fix_course_sortorder();
// Choose a sort order that puts us at the start of the list!
$course->sortorder = 0;
- if($course->id = $DB->insert_record('course', $course)){
+ if ($courseid = $DB->insert_record('course', $course)) {
// 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
+ $course = $DB->get_record('course', array('id' => $courseid));
+ blocks_add_default_course_blocks($course);
$section = new object();
$section->course = $course->id; // Create a default section.
$section->course = $newcourseid; // Create a default section.
$section->section = 0;
$section->id = $DB->insert_record("course_sections", $section);
- $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
- blocks_repopulate_page($page); // Return value no
+ $course = $DB->get_record('course', array('id' => $newcourseid));
+ blocks_add_default_course_blocks($course);
if (!$skip_fix_course_sortorder){
fix_course_sortorder();
function blocks_delete_all_on_page($pagetype, $pageid) {
global $DB;
- debugging('Call to deprecated function blocks_repopulate_page. ' .
+ debugging('Call to deprecated function blocks_delete_all_on_page. ' .
'This function cannot work any more. Doing nothing. ' .
'Please update your code to use another method.', DEBUG_DEVELOPER);
return false;