// 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)) {
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."
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
* @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
}
$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);
bi.id,
bp.id AS blockpositionid,
bi.blockname,
- bi.contextid,
+ bi.parentcontextid,
bi.showinsubcontexts,
bi.pagetypepattern,
bi.subpagepattern,
$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;
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));
}
$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-*';
<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"/>
<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">
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
}
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);
}
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);
}
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);
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
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');
}
}
+ 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;
}
// 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