blocks: MDL-19010 Fix further blocks-related breakage, including removing all references to blocks_insance_old outside blocklib.php

This commit is contained in:
tjhunt
2009-05-07 08:55:10 +00:00
parent 572befbcf2
commit f474a4e583
16 changed files with 154 additions and 190 deletions
+3 -3
View File
@@ -82,7 +82,7 @@
}
// First delete instances and then block
$instances = $DB->get_records('block_instance_old', array('blockid'=>$block->id));
$instances = $DB->get_records('block_instances', array('blockname' => $block->name));
if(!empty($instances)) {
foreach($instances as $instance) {
blocks_delete_instance($instance);
@@ -168,8 +168,8 @@
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
// and it should not show up on course search page
$totalcount = $DB->count_records('block_instance_old', array('blockid'=>$blockid));
$count = $DB->count_records('block_instance_old', array('blockid'=>$blockid, 'pagetype'=>'course-view'));
$totalcount = $DB->count_records('block_instances', array('blockname'=>$blockname));
$count = $DB->count_records('block_instances', array('blockname'=>$blockname, 'pagetypepattern'=>'course-view-*'));
if ($count>0) {
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&amp;sesskey=".sesskey()."\" ";
+6 -10
View File
@@ -42,17 +42,13 @@ print_simple_box_end();
/// Try to replace some well-known serialised contents (html blocks)
notify('Replacing in html blocks...');
$sql = "SELECT bi.*
FROM {block_instance_old} bi
JOIN {block} b ON b.id = bi.blockid
WHERE b.name = 'html'";
if ($instances = $DB->get_records_sql($sql)) {
foreach ($instances as $instance) {
$blockobject = block_instance('html', $instance);
$blockobject->config->text = str_replace($search, $replace, $blockobject->config->text);
$blockobject->instance_config_commit($blockobject->pinned);
}
$instances = $DB->get_recordset('block_instances', array('blockname' => 'html'));
foreach ($instances as $instance) {
$blockobject = block_instance('html', $instance);
$blockobject->config->text = str_replace($search, $replace, $blockobject->config->text);
$blockobject->instance_config_commit($blockobject->pinned);
}
$instances->close();
/// Rebuild course cache which might be incorrect now
notify('Rebuilding course cache...', 'notifysuccess');
+2 -4
View File
@@ -2825,10 +2825,8 @@
}
// add all roles assigned at block context
if ($courseblocks = $DB->get_records_sql("SELECT *
FROM {block_instance_old}
WHERE pagetype = '".PAGE_COURSE_VIEW."'
AND pageid = ?", array($preferences->backup_course))) {
if ($courseblocks = $DB->get_records_sql("SELECT * FROM {block_instances} WHERE contextid = ?",
array($coursecontext->id))) {
foreach ($courseblocks as $courseblock) {
+14 -30
View File
@@ -3,8 +3,6 @@
/**
* This file contains the parent class for moodle blocks, block_base.
*
* @author Jon Papaioannou
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package blocks
*/
@@ -303,8 +301,9 @@ class block_base {
*/
function is_empty() {
// TODO
if (empty($this->instance->pinned)) {
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
@@ -408,8 +407,9 @@ class block_base {
function _add_edit_controls($options) {
global $CFG, $USER;
// TODO
if (empty($this->instance->pinned)) {
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
@@ -709,21 +709,11 @@ class block_base {
/**
* Serialize and store config data
* @return boolean
* @todo finish documenting this function
*/
function instance_config_save($data,$pinned=false) {
function instance_config_save($data, $nolongerused = false) {
global $DB;
$data = $data;
$this->config = $data;
$table = 'block_instance_old';
$field = 'oldid';
if (!empty($pinned)) {
$table = 'block_pinned_old';
$field = 'id';
}
return $DB->set_field($table, 'configdata', base64_encode(serialize($data)), array($field => $this->instance->id));
$DB->set_field('block_instances', 'configdata', base64_encode(serialize($data)),
array($field => $this->instance->id));
}
/**
@@ -731,16 +721,9 @@ class block_base {
* @return boolean
* @todo finish documenting this function
*/
function instance_config_commit($pinned=false) {
function instance_config_commit($nolongerused = false) {
global $DB;
$table = 'block_instance_old';
$field = 'oldid';
if (!empty($pinned)) {
$table = 'block_pinned_old';
$field = 'id';
}
return $DB->set_field($table, 'configdata', base64_encode(serialize($this->config)), array($field => $this->instance->id));
$this->instance_config_save($this->config);
}
/**
@@ -801,8 +784,9 @@ class block_list extends block_base {
function is_empty() {
// TODO
if (empty($this->instance->pinned)) {
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
+5 -4
View File
@@ -37,11 +37,12 @@ class block_online_users extends block_base {
// Get context so we can check capabilities.
$context = $this->page->context;
// TODO
if (empty($this->instance->pinned)) {
$blockcontext = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$blockcontext = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
}
//Calculate if we are in separate groups
+3 -2
View File
@@ -96,8 +96,9 @@
}
}
// TODO
if (empty($this->instance->pinned)) {
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
+6 -4
View File
@@ -93,8 +93,9 @@ print_box_start();
print $checkbox . $feedtitle .'<br />'."\n";
}
} else {
// TODO
if (empty($this->instance->pinned)) {
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
@@ -174,8 +175,9 @@ print_box_start();
} else {
global $act, $url, $rssid, $preferredtitle, $shared;
print '</div></form></div>'; // Closes off page form
// TODO
if (empty($this->instance->pinned)) {
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
+7 -6
View File
@@ -5,12 +5,13 @@
global $USER;
$tabs = $row = array();
// TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
}
// TODO - temporary hack to get the block context only if it already exists.
global $DB;
if ($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $this->instance->id))) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
}
if (has_capability('moodle/site:manageblocks', $context)) {
$script = $page->url->out(array('instanceid' => $this->instance->id, 'sesskey' => sesskey(), 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id, 'section' => 'rss'));
+15 -14
View File
@@ -29,20 +29,21 @@
$tagsblock = $DB->get_record('block', array('name'=>'blog_tags'));
// add those 2 into block_instance page
// add blog_menu block
$newblock = new object();
$newblock->blockid = $menublock->id;
$newblock->pageid = $USER->id;
$newblock->pagetype = 'blog-view';
$newblock->position = 'r';
$newblock->weight = 0;
$newblock->visible = 1;
$DB->insert_record('block_instance_old', $newblock);
// add blog_tags menu
$newblock -> blockid = $tagsblock->id;
$newblock -> weight = 1;
$DB->insert_record('block_instance_old', $newblock);
// Commmented out since the block changes broke it. Hopefully nico will fix it ;-)
// // add blog_menu block
// $newblock = new object();
// $newblock->blockid = $menublock->id;
// $newblock->pageid = $USER->id;
// $newblock->pagetype = 'blog-view';
// $newblock->position = 'r';
// $newblock->weight = 0;
// $newblock->visible = 1;
// $DB->insert_record('block_instances', $newblock);
//
// // add blog_tags menu
// $newblock -> blockid = $tagsblock->id;
// $newblock -> weight = 1;
// $DB->insert_record('block_instances', $newblock);
// finally we set the page size pref
set_user_preference('blogpagesize', 10);
+2 -1
View File
@@ -1,7 +1,8 @@
<?php // $Id$
// Admin-only code to delete a course utterly
require_once("../config.php");
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot . '/course/lib.php');
$id = required_param('id', PARAM_INT); // course id
$delete = optional_param('delete', '', PARAM_ALPHANUM); // delete confirmation hash
+3
View File
@@ -24,6 +24,9 @@
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$PAGE->set_url('course/index.php');
$PAGE->set_context($systemcontext);
if (update_category_button()) {
if ($categoryedit !== -1) {
$USER->editing = $categoryedit;
+11 -18
View File
@@ -116,26 +116,19 @@
// get list of courses containing blocks if required
if (!empty($blocklist) and confirm_sesskey()) {
$blockid = $blocklist;
if (!$blocks = $DB->get_records('block_instance_old', array('blockid'=>$blockid))) {
print_error('blockcannotread', '', '', $blockid);
}
// run through blocks and get (unique) courses
$blockname = $DB->get_field('block', 'name', array('id' => $blocklist));
$courses = $DB->get_recordset_sql("
SELECT * FROM {course} WHERE id IN (
SELECT DISTINCT ctx.instanceid
FROM {context} ctx
JOIN {block_instances} bi ON bi.contextid = ctx.id
WHERE ctx.contextlevel = " . CONTEXT_COURSE . " AND bi.blockname = ?)",
array($blockname));
$courses = array();
foreach ($blocks as $block) {
$courseid = $block->pageid;
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
// and it should not show up on course search page
if ($courseid==0 || $block->pagetype != 'course-view') {
continue;
}
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
print_error('invalidcourseid', '', '', $courseid);
}
$courses[$courseid] = $course;
foreach ($courses as $course) {
$courses[$course->id] = $course;
}
$totalcount = count( $courses );
$totalcount = count($courses);
}
// get list of courses containing modules if required
elseif (!empty($modulelist) and confirm_sesskey()) {
+34 -49
View File
@@ -2091,28 +2091,16 @@ function create_context($contextlevel, $instanceid) {
case CONTEXT_BLOCK:
// Only non-pinned & course-page based
$sql = "SELECT ctx.path, ctx.depth
FROM {context} ctx
JOIN {block_instance_old} bi
ON (bi.pageid=ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.")
WHERE bi.oldid=? AND bi.pagetype='course-view'";
$params = array($instanceid);
FROM {context} ctx
JOIN {block_instances} bi ON (bi.contextid=ctx.id)
WHERE bi.id=? AND ctx.contextlevel=?";
$params = array($instanceid, CONTEXT_COURSE);
if ($p = $DB->get_record_sql($sql, $params)) {
$basepath = $p->path;
$basedepth = $p->depth;
} else if ($bi = $DB->get_record('block_instance_old', array('oldid'=>$instanceid))) {
if ($bi->pagetype != 'course-view') {
// ok - not a course block
} else if ($parent = get_context_instance(CONTEXT_COURSE, $bi->pageid)) {
$basepath = $parent->path;
$basedepth = $parent->depth;
} else {
// parent course does not exist - course blocks can not exist without a course
$error_message = 'parent course does not exist - course blocks can not exist without a course';
$result = false;
}
} else {
// block does not exist
$error_message = 'block does not exist';
$error_message = 'block or parent context does not exist';
$result = false;
}
break;
@@ -2294,8 +2282,8 @@ function create_contexts($contextlevel=null, $buildpaths=true) {
if (empty($contextlevel) or $contextlevel == CONTEXT_BLOCK) {
$sql = "INSERT INTO {context} (contextlevel, instanceid)
SELECT ".CONTEXT_BLOCK.", bi.oldid
FROM {block_instance_old} bi
SELECT ".CONTEXT_BLOCK.", bi.id
FROM {block_instances} bi
WHERE NOT EXISTS (SELECT 'x'
FROM {context} cx
WHERE bi.id = cx.instanceid AND cx.contextlevel=".CONTEXT_BLOCK.")";
@@ -2358,8 +2346,8 @@ function cleanup_contexts() {
SELECT c.contextlevel,
c.instanceid
FROM {context} c
LEFT OUTER JOIN {block_instance_old} t
ON c.instanceid = t.oldid
LEFT OUTER JOIN {block_instances} t
ON c.instanceid = t.id
WHERE t.id IS NULL AND c.contextlevel = ".CONTEXT_BLOCK."
";
if ($rs = $DB->get_recordset_sql($sql)) {
@@ -2407,9 +2395,10 @@ function preload_course_contexts($courseid) {
UNION ALL
SELECT x.instanceid, x.id, x.contextlevel, x.path, x.depth
FROM {block_instance_old} bi
JOIN {context} x ON x.instanceid=bi.oldid
WHERE bi.pageid=? AND bi.pagetype='course-view'
FROM {context} px
JOIN {block_instances} bi ON bi.contextid = px.id
JOIN {context} x ON x.instanceid=bi.id
WHERE px.instanceid = ? AND px.contextlevel = ".CONTEXT_COURSE."
AND x.contextlevel=".CONTEXT_BLOCK."
UNION ALL
@@ -3426,18 +3415,16 @@ function print_context_name($context, $withprefix = true, $short = false) {
break;
case CONTEXT_BLOCK: // not necessarily 1 to 1 to course
if ($blockinstance = $DB->get_record('block_instance_old', array('oldid'=>$context->instanceid))) {
if ($block = $DB->get_record('block', array('id'=>$blockinstance->blockid))) {
global $CFG;
require_once("$CFG->dirroot/blocks/moodleblock.class.php");
require_once("$CFG->dirroot/blocks/$block->name/block_$block->name.php");
$blockname = "block_$block->name";
if ($blockobject = new $blockname()) {
if ($withprefix){
$name = get_string('block').': ';
}
$name .= $blockobject->title;
if ($blockinstance = $DB->get_record('block_instances', array('id'=>$context->instanceid))) {
global $CFG;
require_once("$CFG->dirroot/blocks/moodleblock.class.php");
require_once("$CFG->dirroot/blocks/$blockinstance->blockname/block_$blockinstance->blockname.php");
$blockname = "block_$blockinstance->blockname";
if ($blockobject = new $blockname()) {
if ($withprefix){
$name = get_string('block').': ';
}
$name .= $blockobject->title;
}
}
break;
@@ -3607,15 +3594,13 @@ function fetch_context_capabilities($context) {
break;
case CONTEXT_BLOCK: // block caps
$cb = $DB->get_record('block_instance_old', array('oldid'=>$context->instanceid));
$block = $DB->get_record('block', array('id'=>$cb->blockid));
$cb = $DB->get_record('block_instances', array('id'=>$context->instanceid));
$extra = "";
if ($blockinstance = block_instance($block->name)) {
if ($extracaps = $blockinstance->get_extra_capabilities()) {
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
$extra = "OR name $extra";
}
$extra = '';
$extracaps = block_method_result($cb->blockname, 'get_extra_capabilities');
if ($extracaps) {
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
$extra = "OR name $extra";
}
$SQL = "SELECT *
@@ -3750,13 +3735,13 @@ function get_sorted_contexts($select, $params = array()) {
return $DB->get_records_sql("
SELECT ctx.*
FROM {context} ctx
LEFT JOIN {user} u ON ctx.contextlevel = 30 AND u.id = ctx.instanceid
LEFT JOIN {course_categories} cat ON ctx.contextlevel = 40 AND cat.id = ctx.instanceid
LEFT JOIN {course} c ON ctx.contextlevel = 50 AND c.id = ctx.instanceid
LEFT JOIN {course_modules} cm ON ctx.contextlevel = 70 AND cm.id = ctx.instanceid
LEFT JOIN {block_instance_old} bi ON ctx.contextlevel = 80 AND bi.oldid = ctx.instanceid
LEFT JOIN {user} u ON ctx.contextlevel = " . CONTEXT_USER . " AND u.id = ctx.instanceid
LEFT JOIN {course_categories} cat ON ctx.contextlevel = " . CONTEXT_COURSECAT . " AND cat.id = ctx.instanceid
LEFT JOIN {course} c ON ctx.contextlevel = " . CONTEXT_COURSE . " AND c.id = ctx.instanceid
LEFT JOIN {course_modules} cm ON ctx.contextlevel = " . CONTEXT_MODULE . " AND cm.id = ctx.instanceid
LEFT JOIN {block_instances} bi ON ctx.contextlevel = " . CONTEXT_BLOCK . " AND bi.id = ctx.instanceid
$select
ORDER BY ctx.contextlevel, bi.position, COALESCE(cat.sortorder, c.sortorder, cm.section, bi.weight), u.lastname, u.firstname, cm.id
ORDER BY ctx.contextlevel, bi.region, COALESCE(cat.sortorder, c.sortorder, cm.section, bi.weight), u.lastname, u.firstname, cm.id
", $params);
}
+39 -9
View File
@@ -1335,6 +1335,23 @@ function blocks_delete_all_on_page($pagetype, $pageid) {
return false;
}
/**
* Delete a block, and associated data.
* @param object $instance a row from the block_instances table
* @param $skipblockstables for internal use only. Makes @see blocks_delete_all_for_context() more efficient.
*/
function blocks_delete_block($instance, $skipblockstables = false) {
if ($block = block_instance($block->blockname, $instance)) {
$block->instance_delete();
}
delete_context(CONTEXT_BLOCK, $instance->id);
if (!$skipblockstables) {
$DB->delete_records('block_positions', array('blockinstanceid' => $instance->id));
$DB->delete_records('block_instances', array('id' => $instance->id));
}
}
/**
* Delete all the blocks that belong to a particular context.
* @param $contextid the context id.
@@ -1343,7 +1360,7 @@ function blocks_delete_all_for_context($contextid) {
global $DB;
$instances = $DB->get_recordset('block_instances', array('contextid' => $contextid));
foreach ($instances as $instance) {
delete_context(CONTEXT_BLOCK, $instance->id);
blocks_delete_block($instance, true);
}
$instances->close();
$DB->delete_records('block_instances', array('contextid' => $contextid));
@@ -1356,11 +1373,15 @@ function blocks_delete_all_for_context($contextid) {
* @return array
*/
function blocks_parse_default_blocks_list($blocksstr) {
list($left, $right) = explode(':', $blocksstr);
return array(
BLOCK_POS_LEFT => explode(',', $left),
BLOCK_POS_RIGHT => explode(',', $right),
);
$blocks = array();
$bits = explode(':', $blocksstr);
if (!empty($bits)) {
$blocks[BLOCK_POS_LEFT] = explode(',', array_shift($bits));
}
if (!empty($bits)) {
$blocks[BLOCK_POS_RIGHT] = explode(',', array_shift($bits));
}
return $blocks;
}
/**
@@ -1370,9 +1391,9 @@ function blocks_get_default_site_course_blocks() {
global $CFG;
if (!empty($CFG->defaultblocks_site)) {
blocks_parse_default_blocks_list($CFG->defaultblocks_site);
return blocks_parse_default_blocks_list($CFG->defaultblocks_site);
} else {
$blocknames = array(
return array(
BLOCK_POS_LEFT => array('site_main_menu', 'admin_tree'),
BLOCK_POS_RIGHT => array('course_summary', 'calendar_month')
);
@@ -1417,9 +1438,18 @@ function blocks_add_default_course_blocks($course) {
}
}
if ($course->id == SITEID) {
$pagetypepattern = 'site-index';
} else {
$pagetypepattern = 'course-view-*';
}
$page = new moodle_page();
$page->set_course($course);
$page->blocks->add_blocks(array($blocknames), 'course-view-*');
print_object($page); // DONOTCOMMIT
print_object($pagetypepattern); // DONOTCOMMIT
print_object($blocknames); // DONOTCOMMIT
$page->blocks->add_blocks($blocknames, $pagetypepattern);
}
/**
+2 -35
View File
@@ -3528,6 +3528,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
if (! $course = $DB->get_record('course', array('id'=>$courseid))) {
print_error('invalidcourseid');
}
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$strdeleted = get_string('deleted');
@@ -3601,40 +3602,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
notify_local_delete_course($courseid, $showfeedback);
/// Delete course blocks
if ($blocks = $DB->get_records_sql("SELECT *
FROM {block_instance_old}
WHERE pagetype = '".PAGE_COURSE_VIEW."'
AND pageid = ?", array($course->id))) {
if ($DB->delete_records('block_instance_old', array('pagetype'=>PAGE_COURSE_VIEW, 'pageid'=>$course->id))) {
if ($showfeedback) {
notify($strdeleted .' block_instance_old');
}
foreach ($blocks as $block) { /// Delete any associated contexts for this block
delete_context(CONTEXT_BLOCK, $block->id);
// fix for MDL-7164
// Get the block object and call instance_delete()
if (!$record = blocks_get_record($block->blockid)) {
$result = false;
continue;
}
if (!$obj = block_instance($record->name, $block)) {
$result = false;
continue;
}
// Return value ignored, in core mods this does not do anything, but just in case
// third party blocks might have stuff to clean up
// we execute this anyway
$obj->instance_delete();
}
} else {
$result = false;
}
}
blocks_delete_all_for_context($context->id);
/// Delete any groups, removing members and grouping/course links first.
require_once($CFG->dirroot.'/group/lib.php');
@@ -3688,7 +3656,6 @@ function remove_course_contents($courseid, $showfeedback=true) {
question_delete_course($course, $showfeedback);
/// Remove all data from gradebook
$context = get_context_instance(CONTEXT_COURSE, $courseid);
remove_course_grades($courseid, $showfeedback);
remove_grade_letters($context, $showfeedback);
+2 -1
View File
@@ -330,7 +330,7 @@ class moodle_page {
if ($this->_legacypageobject) {
return $this->_legacypageobject->user_allowed_editing();
}
return has_any_capability($this->all_editing_caps(), $this->_context);
return has_any_capability($this->all_editing_caps(), $this->context);
}
/// Setter methods =============================================================
@@ -974,6 +974,7 @@ function page_create_object($type, $id = NULL) {
$legacypage->set_course($SITE);
}
}
$legacypage->set_pagetype($type);
$legacypage->set_url($ME);