blocks MDL-19536: rename block_instances.contextid to parentcontextid to avoid gross confusion
This commit is contained in:
+3
-3
@@ -2224,7 +2224,7 @@ function create_context($contextlevel, $instanceid) {
|
||||
// Only non-pinned & course-page based
|
||||
$sql = "SELECT ctx.path, ctx.depth
|
||||
FROM {context} ctx
|
||||
JOIN {block_instances} bi ON (bi.contextid=ctx.id)
|
||||
JOIN {block_instances} bi ON (bi.parentcontextid=ctx.id)
|
||||
WHERE bi.id=? AND ctx.contextlevel=?";
|
||||
$params = array($instanceid, CONTEXT_COURSE);
|
||||
if ($p = $DB->get_record_sql($sql, $params)) {
|
||||
@@ -2539,7 +2539,7 @@ function preload_course_contexts($courseid) {
|
||||
|
||||
SELECT x.instanceid, x.id, x.contextlevel, x.path, x.depth
|
||||
FROM {context} px
|
||||
JOIN {block_instances} bi ON bi.contextid = px.id
|
||||
JOIN {block_instances} bi ON bi.parentcontextid = px.id
|
||||
JOIN {context} x ON x.instanceid=bi.id
|
||||
WHERE px.instanceid = ? AND px.contextlevel = ".CONTEXT_COURSE."
|
||||
AND x.contextlevel=".CONTEXT_BLOCK."
|
||||
@@ -6076,7 +6076,7 @@ function build_context_path($force=false) {
|
||||
SELECT ctx.id, ".$DB->sql_concat('pctx.path', "'/'", 'ctx.id').", pctx.depth+1
|
||||
FROM {context} ctx
|
||||
JOIN {block_instances} bi ON ctx.instanceid = bi.id
|
||||
JOIN {context} pctx ON bi.contextid = pctx.id
|
||||
JOIN {context} pctx ON bi.parentcontextid = pctx.id
|
||||
WHERE ctx.contextlevel=".CONTEXT_BLOCK."
|
||||
AND NOT EXISTS (SELECT 'x'
|
||||
FROM {context_temp} temp
|
||||
|
||||
+17
-8
@@ -25,21 +25,30 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block Defines
|
||||
/**#@+
|
||||
* @deprecated since Moodle 2.0. No longer used.
|
||||
*/
|
||||
define('BLOCK_MOVE_LEFT', 0x01);
|
||||
define('BLOCK_MOVE_RIGHT', 0x02);
|
||||
define('BLOCK_MOVE_UP', 0x04);
|
||||
define('BLOCK_MOVE_DOWN', 0x08);
|
||||
define('BLOCK_CONFIGURE', 0x10);
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* Default names for the block regions in the standard theme.
|
||||
*/
|
||||
define('BLOCK_POS_LEFT', 'side-pre');
|
||||
define('BLOCK_POS_RIGHT', 'side-post');
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* @deprecated since Moodle 2.0. No longer used.
|
||||
*/
|
||||
define('BLOCKS_PINNED_TRUE',0);
|
||||
define('BLOCKS_PINNED_FALSE',1);
|
||||
define('BLOCKS_PINNED_BOTH',2);
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Exception thrown when someone tried to do something with a block that does
|
||||
@@ -379,13 +388,13 @@ class block_manager {
|
||||
}
|
||||
|
||||
$context = $this->page->context;
|
||||
$contexttest = 'bi.contextid = :contextid2';
|
||||
$contexttest = 'bi.parentcontextid = :contextid2';
|
||||
$parentcontextparams = array();
|
||||
$parentcontextids = get_parent_contexts($context);
|
||||
if ($parentcontextids) {
|
||||
list($parentcontexttest, $parentcontextparams) =
|
||||
$DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext0000');
|
||||
$contexttest = "($contexttest OR (bi.showinsubcontexts = 1 AND bi.contextid $parentcontexttest))";
|
||||
$contexttest = "($contexttest OR (bi.showinsubcontexts = 1 AND bi.parentcontextid $parentcontexttest))";
|
||||
}
|
||||
|
||||
$pagetypepatterns = $this->matching_page_type_patterns($this->page->pagetype);
|
||||
@@ -403,7 +412,7 @@ class block_manager {
|
||||
bi.id,
|
||||
bp.id AS blockpositionid,
|
||||
bi.blockname,
|
||||
bi.contextid,
|
||||
bi.parentcontextid,
|
||||
bi.showinsubcontexts,
|
||||
bi.pagetypepattern,
|
||||
bi.subpagepattern,
|
||||
@@ -473,7 +482,7 @@ class block_manager {
|
||||
|
||||
$blockinstance = new stdClass;
|
||||
$blockinstance->blockname = $blockname;
|
||||
$blockinstance->contextid = $this->page->context->id;
|
||||
$blockinstance->parentcontextid = $this->page->context->id;
|
||||
$blockinstance->showinsubcontexts = !empty($showinsubcontexts);
|
||||
$blockinstance->pagetypepattern = $pagetypepattern;
|
||||
$blockinstance->subpagepattern = $subpagepattern;
|
||||
@@ -902,7 +911,7 @@ function blocks_delete_all_for_context($contextid) {
|
||||
blocks_delete_instance($instance, true);
|
||||
}
|
||||
$instances->close();
|
||||
$DB->delete_records('block_instances', array('contextid' => $contextid));
|
||||
$DB->delete_records('block_instances', array('parentcontextid' => $contextid));
|
||||
$DB->delete_records('block_positions', array('contextid' => $contextid));
|
||||
}
|
||||
|
||||
@@ -1204,7 +1213,7 @@ function blocks_execute_action($page, &$blockmanager, $blockaction, $instanceori
|
||||
|
||||
$region = $page->blocks->get_default_region();
|
||||
$weight = $DB->get_field_sql("SELECT MAX(defaultweight) FROM {block_instances}
|
||||
WHERE contextid = ? AND defaultregion = ?", array($page->context->id, $region));
|
||||
WHERE parentcontextid = ? AND defaultregion = ?", array($page->context->id, $region));
|
||||
$pagetypepattern = $page->pagetype;
|
||||
if (strpos($pagetypepattern, 'course-view') === 0) {
|
||||
$pagetypepattern = 'course-view-*';
|
||||
|
||||
+7
-7
@@ -2177,12 +2177,12 @@
|
||||
<INDEX NAME="name" UNIQUE="true" FIELDS="name"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="block_instances" COMMENT="This table stores block instances. The type of block this is is given by the block name column. The places this block instance appears is controlled by the contextid, showinsubcontexts, pagetypepattern and subpagepattern fields. Where the block appears on the page (by default) is controlled by the defaultposition and defaultweight columns. The block's own configuration is stored serialized in configdata." PREVIOUS="block" NEXT="block_positions">
|
||||
<TABLE NAME="block_instances" COMMENT="This table stores block instances. The type of block this is is given by the blockname column. The places this block instance appears is controlled by the parentcontexid, showinsubcontexts, pagetypepattern and subpagepattern fields. Where the block appears on the page (by default) is controlled by the defaultposition and defaultweight columns. The block's own configuration is stored serialized in configdata." PREVIOUS="block" NEXT="block_positions">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="blockname"/>
|
||||
<FIELD NAME="blockname" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" COMMENT="The type of block this is. Foreign key, references block.name." PREVIOUS="id" NEXT="contextid"/>
|
||||
<FIELD NAME="contextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The context within which this block appears. Foreign key, references context.id." PREVIOUS="blockname" NEXT="showinsubcontexts"/>
|
||||
<FIELD NAME="showinsubcontexts" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="If 1, this block appears on all matching pages in subcontexts of this contextid, as well in contextid." PREVIOUS="contextid" NEXT="pagetypepattern"/>
|
||||
<FIELD NAME="blockname" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" COMMENT="The type of block this is. Foreign key, references block.name." PREVIOUS="id" NEXT="parentcontextid"/>
|
||||
<FIELD NAME="parentcontextid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The context within which this block appears. Foreign key, references context.id." PREVIOUS="blockname" NEXT="showinsubcontexts"/>
|
||||
<FIELD NAME="showinsubcontexts" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="If 1, this block appears on all matching pages in subcontexts of parentcontextid, as well in pages belonging to parentcontextid." PREVIOUS="parentcontextid" NEXT="pagetypepattern"/>
|
||||
<FIELD NAME="pagetypepattern" TYPE="char" LENGTH="64" NOTNULL="true" SEQUENCE="false" COMMENT="The types of page this block appears on. Either an exact page type like mod-quiz-view, or a pattern like mod-quiz-* or course-view-*. Note that course-view-* will match course-view." PREVIOUS="showinsubcontexts" NEXT="subpagepattern"/>
|
||||
<FIELD NAME="subpagepattern" TYPE="char" LENGTH="16" NOTNULL="false" SEQUENCE="false" COMMENT="Further restrictions on where this block appears. In some places, e.g. during a quiz or lesson attempt, different pages have different subpage ids. If this field is not null, the block only appears on that particular subpage." PREVIOUS="pagetypepattern" NEXT="defaultregion"/>
|
||||
<FIELD NAME="defaultregion" TYPE="char" LENGTH="16" NOTNULL="true" SEQUENCE="false" COMMENT="Which block region this block should appear in on each page, in the absence of a specific position in the block_positions table." PREVIOUS="subpagepattern" NEXT="defaultweight"/>
|
||||
@@ -2190,11 +2190,11 @@
|
||||
<FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="A serialized blob of configuration data for this block instance." PREVIOUS="defaultweight"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="contextid"/>
|
||||
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="parentcontextid"/>
|
||||
<KEY NAME="parentcontextid" TYPE="foreign" FIELDS="parentcontextid" REFTABLE="context" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="contextid-showinsubcontexts-pagetypepattern-subpagepattern" UNIQUE="false" FIELDS="contextid, showinsubcontexts, pagetypepattern, subpagepattern"/>
|
||||
<INDEX NAME="parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern" UNIQUE="false" FIELDS="parentcontextid, showinsubcontexts, pagetypepattern, subpagepattern"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="block_positions" COMMENT="Stores the position of a sticky block_instance on a another page than the one where it was added." PREVIOUS="block_instances">
|
||||
|
||||
+20
-7
@@ -23,7 +23,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
global $CFG, $THEME, $USER, $DB;
|
||||
|
||||
require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
|
||||
|
||||
|
||||
$result = true;
|
||||
|
||||
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
|
||||
@@ -2229,7 +2229,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2009061704) {
|
||||
// change component string in capability records to new "_" format
|
||||
// change component string in capability records to new "_" format
|
||||
if ($caps = $DB->get_records('capabilities')) {
|
||||
foreach ($caps as $cap) {
|
||||
$cap->component = str_replace('/', '_', $cap->component);
|
||||
@@ -2241,7 +2241,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2009061705) {
|
||||
// change component string in events_handlers records to new "_" format
|
||||
// change component string in events_handlers records to new "_" format
|
||||
if ($handlers = $DB->get_records('events_handlers')) {
|
||||
foreach ($handlers as $handler) {
|
||||
$handler->handlermodule = str_replace('/', '_', $handler->handlermodule);
|
||||
@@ -2253,7 +2253,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2009061706) {
|
||||
// change component string in message_providers records to new "_" format
|
||||
// change component string in message_providers records to new "_" format
|
||||
if ($mps = $DB->get_records('message_providers')) {
|
||||
foreach ($mps as $mp) {
|
||||
$mp->component = str_replace('/', '_', $mp->component);
|
||||
@@ -2263,7 +2263,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
unset($caps);
|
||||
upgrade_main_savepoint($result, 2009061706);
|
||||
}
|
||||
|
||||
|
||||
if ($result && $oldversion < 2009063000) {
|
||||
// upgrade format of _with_advanced settings - quiz only
|
||||
// note: this can be removed later, not needed for upgrades from 1.9.x
|
||||
@@ -2276,10 +2276,10 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
set_config($newname, $value, 'quiz');
|
||||
unset_config($name, 'quiz');
|
||||
}
|
||||
}
|
||||
}
|
||||
upgrade_main_savepoint($result, 2009063000);
|
||||
}
|
||||
|
||||
|
||||
if ($result && $oldversion < 2009070100) {
|
||||
// MDL-19677 Change $CFG->bloglevel to BLOG_SITE_LEVEL if BLOG_COURSE_LEVEL or BLOG_GROUP_LEVEL
|
||||
$current_bloglevel = get_config(null, 'bloglevel');
|
||||
@@ -2289,6 +2289,19 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2009071000) {
|
||||
|
||||
/// Rename field contextid on table block_instances to parentcontextid
|
||||
$table = new xmldb_table('block_instances');
|
||||
$field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'blockname');
|
||||
|
||||
/// Launch rename field parentcontextid
|
||||
$dbman->rename_field($table, $field, 'parentcontextid');
|
||||
|
||||
/// Main savepoint reached
|
||||
upgrade_main_savepoint($result, 2009071000);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2009070100; // YYYYMMDD = date of the last version bump
|
||||
$version = 2009071000; // YYYYMMDD = date of the last version bump
|
||||
// XX = daily increments
|
||||
|
||||
$release = '2.0 dev (Build: 20090710)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user