}
upgrade_plugins('qtype', 'question/type', ''); // Don't return anywhere
- /// Upgrade blocks system if necessary
- /// first old *.php update and then the new upgrade.php script
- require_once("$CFG->dirroot/lib/blocklib.php");
- if ( $verbose > CLI_NO ) {
- print_heading(get_string('upgradingblocksdb','install'),'',1);
- }
- upgrade_blocks_db(''); // Don't return anywhere
-
/// Check all blocks and load (or upgrade them if necessary)
/// first old *.php update and then the new upgrade.php script
+ require_once("$CFG->dirroot/lib/blocklib.php");
if ( $verbose > CLI_NO ) {
print_heading(get_string('upgradingblocksplugin','install'),'',1);
}
$ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks')));
$ADMIN->add('blocksettings', new admin_page_manageblocks());
$ADMIN->add('blocksettings', new admin_externalpage('stickyblocks', get_string('stickyblocks', 'admin'), "$CFG->wwwroot/$CFG->admin/stickyblocks.php"));
- if (!empty($CFG->blocks_version) and $blocks = $DB->get_records('block')) {
+ if ($blocks = $DB->get_records('block')) {
$blockbyname = array();
foreach ($blocks as $block) {
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/db" VERSION="20070813" COMMENT="XMLDB file for Moodle block tables"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
->
- <TABLES>
- <TABLE NAME="block" COMMENT="to store installed blocks" NEXT="block_instance">
- <FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
- <FIELD NAME="name" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="version"/>
- <FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="cron"/>
- <FIELD NAME="cron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="version" NEXT="lastcron"/>
- <FIELD NAME="lastcron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="cron" NEXT="visible"/>
- <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="lastcron" NEXT="multiple"/>
- <FIELD NAME="multiple" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
- </FIELDS>
- <KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" />
- </KEYS>
- </TABLE>
- <TABLE NAME="block_instance" COMMENT="to store block instances in pages" PREVIOUS="block" NEXT="block_pinned">
- <FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="blockid"/>
- <FIELD NAME="blockid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="pageid"/>
- <FIELD NAME="pageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="blockid" NEXT="pagetype"/>
- <FIELD NAME="pagetype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="pageid" NEXT="position"/>
- <FIELD NAME="position" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="pagetype" NEXT="weight"/>
- <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="position" NEXT="visible"/>
- <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="weight" NEXT="configdata"/>
- <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
- </FIELDS>
- <KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="blockid"/>
- <KEY NAME="blockid" TYPE="foreign" FIELDS="blockid" REFTABLE="block" REFFIELDS="id" PREVIOUS="primary"/>
- </KEYS>
- <INDEXES>
- <INDEX NAME="pageid" UNIQUE="false" FIELDS="pageid" NEXT="pagetype"/>
- <INDEX NAME="pagetype" UNIQUE="false" FIELDS="pagetype" PREVIOUS="pageid"/>
- </INDEXES>
- </TABLE>
- <TABLE NAME="block_pinned" COMMENT="to pin blocks" PREVIOUS="block_instance">
- <FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="blockid"/>
- <FIELD NAME="blockid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="pagetype"/>
- <FIELD NAME="pagetype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="blockid" NEXT="position"/>
- <FIELD NAME="position" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="pagetype" NEXT="weight"/>
- <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="position" NEXT="visible"/>
- <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="weight" NEXT="configdata"/>
- <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
- </FIELDS>
- <KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="blockid"/>
- <KEY NAME="blockid" TYPE="foreign" FIELDS="blockid" REFTABLE="block" REFFIELDS="id" PREVIOUS="primary"/>
- </KEYS>
- <INDEXES>
- <INDEX NAME="pagetype" UNIQUE="false" FIELDS="pagetype"/>
- </INDEXES>
- </TABLE>
- </TABLES>
-</XMLDB>
+++ /dev/null
-<?php //$Id$
-
-// This file keeps track of upgrades to
-// the blocks system
-//
-// Sometimes, changes between versions involve
-// alterations to database structures and other
-// major things that may break installations.
-//
-// The upgrade function in this file will attempt
-// to perform all the necessary actions to upgrade
-// your older installtion to the current version.
-//
-// If there's something it cannot do itself, it
-// will tell you what you need to do.
-//
-// The commands in here will all be database-neutral,
-// using the methods of database_manager class
-//
-// Please do not forget to use upgrade_set_timeout()
-// before any action that may take longer time to finish.
-
-function xmldb_blocks_upgrade($oldversion) {
- global $CFG, $DB;
-
- $dbman = $DB->get_manager();
- $result = true;
-
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
-/// this comment lines once this file start handling proper
-/// upgrade code.
-
-/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of database_manager methods
-/// }
-
- if ($result && $oldversion < 2007081300) {
-
- /// Changing nullability of field configdata on table block_instance to null
- $table = new xmldb_table('block_instance');
- $field = new xmldb_field('configdata');
- $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
-
- /// Launch change of nullability for field configdata
- $result = $result && $dbman->change_field_notnull($table, $field);
- }
-
-
- return $result;
-}
-
-
-
-?>
+++ /dev/null
-<?PHP //$Id$
-// This file defines the current version of the
-// blocks code that is being used. This can be
-// compared against the values stored in the
-// database (blocks_version) to determine whether upgrades should
-// be performed (see db/backup_*.php)
-
-$blocks_version = 2007081300; // The current version is a date (YYYYMMDDXX)
-?>
\ No newline at end of file
'filter_multilang_converted' => 1,
'backup_version' => 2008111700,
'backup_release' => '2.0 dev',
+ 'blocks_version' => 2007081300, // might be removed soon
));
// store main version
/// It is important that this is done AFTER the quiz module has been upgraded
upgrade_plugins('qtype', 'question/type', $return_url); // Return here afterwards
-/// Upgrade blocks system if necessary
-/// first old *.php update and then the new upgrade.php script
- require_once("$CFG->dirroot/lib/blocklib.php");
- upgrade_blocks_db($return_url); // Return here afterwards
-
/// Check all blocks and load (or upgrade them if necessary)
/// first old *.php update and then the new upgrade.php script
+ require_once("$CFG->dirroot/lib/blocklib.php");
upgrade_blocks_plugins($return_url); // Return here afterwards
/// Check all enrolment plugins and upgrade if necessary
}
}
-/// Now, block system stuff (blocks/db)
- $dbdirs[] = $CFG->dirroot.'/blocks/db';
-
/// Now, blocks (blocks/xxx/db)
if ($plugins = get_list_of_plugins('blocks', 'db')) {
foreach ($plugins as $plugin) {
}
$found = false;
- if (!empty($CFG->blocks_version) and $blocks = $DB->get_records('block')) {
+ if ($blocks = $DB->get_records('block')) {
$textlib = textlib_get_instance();
foreach ($blocks as $block) {
if (strpos($block->name, $query) !== false) {
return true;
}
-function upgrade_blocks_db($continueto) {
-/// This function upgrades the blocks tables, if necessary
-/// It's called from admin/index.php
-
- global $CFG, $interactive, $DB;
-
- require_once ($CFG->dirroot .'/blocks/version.php'); // Get code versions
-
- if (empty($CFG->blocks_version)) { // Blocks have never been installed.
- $strdatabaseupgrades = get_string('databaseupgrades');
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- print_header($strdatabaseupgrades, $strdatabaseupgrades,
- build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '',
- upgrade_get_javascript(), false, ' ', ' ');
- }
- upgrade_log_start();
- print_heading('blocks');
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- $DB->set_debug(true);
- }
- /// Both old .sql files and new install.xml are supported
- /// but we priorize install.xml (XMLDB) if present
- $DB->get_manager()->install_from_xmldb_file($CFG->dirroot . '/blocks/db/install.xml'); //New method
- $status = true;
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- $DB->set_debug(false);
- }
- if ($status) {
- if (set_config('blocks_version', $blocks_version)) {
- notify(get_string('databasesuccess'), 'notifysuccess');
- notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess');
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- print_continue($continueto);
- print_footer('none');
- exit;
- } else if (CLI_UPGRADE && ($interactive > CLI_SEMI) ) {
- console_write('askcontinue');
- if (read_boolean()){
- return ;
- }else {
- console_write_error('','',false);
- }
- }
- } else {
- print_error('cannotupgradeblock');
- }
- } else {
- print_error('cannotsetupblock');
- }
- }
-
-/// Upgrading code starts here
- $newupgrade = false;
- if (is_readable($CFG->dirroot . '/blocks/db/upgrade.php')) {
- include_once($CFG->dirroot . '/blocks/db/upgrade.php'); // defines new upgrading function
- $newupgrade = true;
- }
-
- if ($blocks_version > $CFG->blocks_version) { // Upgrade tables
- $strdatabaseupgrades = get_string('databaseupgrades');
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- print_header($strdatabaseupgrades, $strdatabaseupgrades,
- build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript());
- }
- upgrade_log_start();
-
- print_heading('blocks');
-
- /// Run de old and new upgrade functions for the module
- $newupgrade_function = 'xmldb_blocks_upgrade';
-
- /// Then, the new function if exists and the old one was ok
- $newupgrade_status = true;
- if ($newupgrade && function_exists($newupgrade_function)) {
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- $DB->set_debug(true);
- }
- $newupgrade_status = $newupgrade_function($CFG->blocks_version);
- } else if ($newupgrade) {
- notify ('Upgrade function ' . $newupgrade_function . ' was not available in ' .
- '/blocks/db/upgrade.php');
- }
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- $DB->set_debug(false);
- }
- /// Now analyze upgrade results
- if ($newupgrade_status) { // No upgrading failed
- if (set_config('blocks_version', $blocks_version)) {
- notify(get_string('databasesuccess'), 'notifysuccess');
- notify(get_string('databaseupgradeblocks', '', $blocks_version), 'notifysuccess');
- if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- print_continue($continueto);
- print_footer('none');
- exit;
- }
- } else {
- print_error('cannotupgradeblock');
- }
- } else {
- print_error('cannotupgradeblock');
- }
-
- } else if ($blocks_version < $CFG->blocks_version) {
- upgrade_log_start();
- notify('WARNING!!! The Blocks version you are using is OLDER than the version that made these databases!');
- }
- upgrade_log_finish();
-}
-
//This function finds all available blocks and install them
//into blocks table or do all the upgrade process if newer
function upgrade_blocks_plugins($continueto) {
<KEY NAME="courseid" TYPE="unique" FIELDS="courseid" PREVIOUS="primary"/>
</KEYS>
</TABLE>
- <TABLE NAME="backup_log" COMMENT="To store every course backup log info" PREVIOUS="backup_courses">
+ <TABLE NAME="backup_log" COMMENT="To store every course backup log info" PREVIOUS="backup_courses" NEXT="block">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="courseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="time"/>
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="backup_courses" REFFIELDS="courseid" PREVIOUS="primary"/>
</KEYS>
</TABLE>
+ <TABLE NAME="block" COMMENT="contains all installed blocks" PREVIOUS="backup_log" NEXT="block_pinned">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
+ <FIELD NAME="name" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="version"/>
+ <FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="cron"/>
+ <FIELD NAME="cron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="version" NEXT="lastcron"/>
+ <FIELD NAME="lastcron" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="cron" NEXT="visible"/>
+ <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="lastcron" NEXT="multiple"/>
+ <FIELD NAME="multiple" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+ </KEYS>
+ </TABLE>
+ <TABLE NAME="block_pinned" COMMENT="to pin blocks" PREVIOUS="block" NEXT="block_instance">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="blockid"/>
+ <FIELD NAME="blockid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="pagetype"/>
+ <FIELD NAME="pagetype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="blockid" NEXT="position"/>
+ <FIELD NAME="position" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="pagetype" NEXT="weight"/>
+ <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="position" NEXT="visible"/>
+ <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="weight" NEXT="configdata"/>
+ <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="blockid"/>
+ <KEY NAME="blockid" TYPE="foreign" FIELDS="blockid" REFTABLE="block" REFFIELDS="id" PREVIOUS="primary"/>
+ </KEYS>
+ <INDEXES>
+ <INDEX NAME="pagetype" UNIQUE="false" FIELDS="pagetype"/>
+ </INDEXES>
+ </TABLE>
+ <TABLE NAME="block_instance" COMMENT="to store block instances in pages" PREVIOUS="block_pinned">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="blockid"/>
+ <FIELD NAME="blockid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="pageid"/>
+ <FIELD NAME="pageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="blockid" NEXT="pagetype"/>
+ <FIELD NAME="pagetype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="pageid" NEXT="position"/>
+ <FIELD NAME="position" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="pagetype" NEXT="weight"/>
+ <FIELD NAME="weight" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="position" NEXT="visible"/>
+ <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="weight" NEXT="configdata"/>
+ <FIELD NAME="configdata" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="visible"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="blockid"/>
+ <KEY NAME="blockid" TYPE="foreign" FIELDS="blockid" REFTABLE="block" REFFIELDS="id" PREVIOUS="primary"/>
+ </KEYS>
+ <INDEXES>
+ <INDEX NAME="pageid" UNIQUE="false" FIELDS="pageid" NEXT="pagetype"/>
+ <INDEX NAME="pagetype" UNIQUE="false" FIELDS="pagetype" PREVIOUS="pageid"/>
+ </INDEXES>
+ </TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">
upgrade_main_savepoint($result, 2009010801);
}
+ if ($result && $oldversion < 2009011000) {
+
+ /// Changing nullability of field configdata on table block_instance to null
+ $table = new xmldb_table('block_instance');
+ $field = new xmldb_field('configdata');
+ $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
+
+ /// Launch change of nullability for field configdata
+ $dbman->change_field_notnull($table, $field);
+
+ /// Main savepoint reached
+ upgrade_main_savepoint($result, 2009011000);
+ }
+
return $result;
}
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2009010801; // YYYYMMDD = date of the last version bump
+ $version = 2009011000; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20090110)'; // Human-friendly version name