Commit 9c82ff2a authored by skodak's avatar skodak
Browse files

MDL-17457 migrated all modules to new db/install.php; added upgrade.txt file...

MDL-17457 migrated all modules to new db/install.php; added upgrade.txt file for devs converting contrib modules
parent c20ce874
......@@ -382,7 +382,7 @@ function get_db_directories() {
* @param string $return The url to prompt the user to continue to
*/
function upgrade_plugins($type, $dir) {
global $CFG, $interactive, $DB;
global $CFG, $DB;
/// special cases
if ($type === 'mod') {
......@@ -521,20 +521,14 @@ function upgrade_plugins($type, $dir) {
/**
* Find and check all modules and load them up or upgrade them if necessary
*
* @uses $CFG
* @param string $return The url to prompt the user to continue to
* @todo Finish documenting this function
*/
function upgrade_activity_modules() {
global $CFG, $interactive, $DB, $unittest;
global $CFG, $DB;
if (!$mods = get_list_of_plugins('mod') ) {
print_error('nomodules', 'debug');
}
$updated_modules = false;
$strmodulesetup = get_string('modulesetup');
foreach ($mods as $mod) {
......@@ -547,11 +541,11 @@ function upgrade_activity_modules() {
unset($module);
if ( is_readable($fullmod .'/version.php')) {
include_once($fullmod .'/version.php'); // defines $module with version etc
if (is_readable($fullmod .'/version.php')) {
require($fullmod .'/version.php'); // defines $module with version etc
} else {
notify('Module '. $mod .': '. $fullmod .'/version.php was not readable');
continue;
error('Module '. $mod .': '. $fullmod .'/version.php was not readable'); // TODO: localise
}
$newupgrade = false;
......@@ -573,7 +567,6 @@ function upgrade_activity_modules() {
$info->requiremoodle = $module->requires;
upgrade_log_start();
notify(get_string('modulerequirementsnotmet', 'error', $info));
$updated_modules = true;
continue;
}
}
......@@ -627,8 +620,6 @@ function upgrade_activity_modules() {
/// Update message providers
message_update_providers('mod/'.$module->name);
$updated_modules = true;
} else {
print_error('cannotdowngrade', 'debug', '', (object)array('oldversion'=>$currmodule->version, 'newversion'=>$module->version));
}
......@@ -636,46 +627,31 @@ function upgrade_activity_modules() {
} else { // module not installed yet, so install it
upgrade_log_start();
print_heading($module->name);
$updated_modules = true;
// To avoid unnecessary output from the SQL queries in the CLI version
@set_time_limit(0); // To allow slow databases to complete the long SQL
/// Both old .sql files and new install.xml are supported
/// but we priorize install.xml (XMLDB) if present
if (file_exists($fullmod . '/db/install.xml')) {
$DB->get_manager()->install_from_xmldb_file($fullmod . '/db/install.xml'); //New method
$status = true;
/// Execute install.xml (XMLDB) - must be present
$DB->get_manager()->install_from_xmldb_file($fullmod . '/db/install.xml'); //New method
/// Post installation hook - optional
if (file_exists("$fullmod/db/install.php")) {
require_once("$fullmod/db/install.php");
$post_install_function = 'xmldb_'.$module->name.'_install';;
$post_install_function();
}
/// Continue with the installation, roles and other stuff
if ($status) {
if ($module->id = $DB->insert_record('modules', $module)) {
$module->id = $DB->insert_record('modules', $module);
/// Capabilities
update_capabilities('mod/'.$module->name);
/// Capabilities
update_capabilities('mod/'.$module->name);
/// Events
events_update_definition('mod/'.$module->name);
/// Events
events_update_definition('mod/'.$module->name);
/// Message providers
message_update_providers('mod/'.$module->name);
/// Message providers
message_update_providers('mod/'.$module->name);
/// Run local install function if there is one
$installfunction = $module->name.'_install';
if (function_exists($installfunction)) {
if (! $installfunction() ) {
notify('Encountered a problem running install function for '.$module->name.'!');
}
}
notify(get_string('modulesuccess', '', $module->name), 'notifysuccess');
print_upgrade_separator();
} else {
print_error('cannotaddmodule', '', '', $module->name);
}
} else {
print_error('cannotsetuptable', 'debug', '', $module->name);
}
notify(get_string('modulesuccess', '', $module->name), 'notifysuccess');
print_upgrade_separator();
}
/// Check submodules of this module if necessary
......@@ -710,8 +686,6 @@ function upgrade_activity_modules() {
}
}
}
return $updated_modules;
}
/**
......@@ -898,7 +872,6 @@ function upgrade_log_start($preinstall=false) {
build_navigation(array(array('name' => $strupgrade, 'link' => null, 'type' => 'misc'))), '',
upgrade_get_javascript(), false, ' ', ' ');
}
//$DB->set_debug(true); // should be configurable soon
ignore_user_abort(true);
register_shutdown_function('upgrade_finished_handler');
......
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_assignment_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('assignment', 'view', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'add', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'update', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'view submission', 'assignment', 'name');
upgrade_log_display_entry('assignment', 'upload', 'assignment', 'name');
}
......@@ -61,15 +61,4 @@
</INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('assignment', 'view', 'assignment', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('assignment', 'add', 'assignment', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('assignment', 'update', 'assignment', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('assignment', 'view submission', 'assignment', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('assignment', 'upload', 'assignment', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
......@@ -1966,13 +1966,6 @@ class mod_assignment_upload_file_form extends moodleform {
/// OTHER STANDARD FUNCTIONS ////////////////////////////////////////////////////////
/**
* Code to be executed when a module is installed
*/
function assignment_install() {
return true;
}
/**
* Deletes an assignment instance
*
......
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_chat_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('chat', 'view', 'chat', 'name');
upgrade_log_display_entry('chat', 'add', 'chat', 'name');
upgrade_log_display_entry('chat', 'update', 'chat', 'name');
upgrade_log_display_entry('chat', 'report', 'chat', 'name');
upgrade_log_display_entry('chat', 'talk', 'chat', 'name');
}
......@@ -89,15 +89,4 @@
</INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('chat', 'view', 'chat', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('chat', 'add', 'chat', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('chat', 'update', 'chat', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('chat', 'report', 'chat', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('chat', 'talk', 'chat', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_choice_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('choice', 'view', 'choice', 'name');
upgrade_log_display_entry('choice', 'update', 'choice', 'name');
upgrade_log_display_entry('choice', 'add', 'choice', 'name');
upgrade_log_display_entry('choice', 'report', 'choice', 'name');
upgrade_log_display_entry('choice', 'choose', 'choice', 'name');
upgrade_log_display_entry('choice', 'choose again', 'choice', 'name');
}
......@@ -56,16 +56,4 @@
</INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('choice', 'view', 'choice', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('choice', 'update', 'choice', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('choice', 'add', 'choice', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('choice', 'report', 'choice', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('choice', 'choose', 'choice', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('choice', 'choose again', 'choice', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_data_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('data', 'view', 'data', 'name');
upgrade_log_display_entry('data', 'add', 'data', 'name');
upgrade_log_display_entry('data', 'update', 'data', 'name');
upgrade_log_display_entry('data', 'record delete', 'data', 'name');
upgrade_log_display_entry('data', 'fields add', 'data_fields', 'name');
upgrade_log_display_entry('data', 'fields update', 'data_fields', 'name');
upgrade_log_display_entry('data', 'templates saved', 'data', 'name');
upgrade_log_display_entry('data', 'templates def', 'data', 'name');
}
......@@ -130,18 +130,4 @@
</KEYS>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'view', 'data', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'add', 'data', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'update', 'data', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'record delete', 'data', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'fields add', 'data_fields', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'fields update', 'data_fields', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'templates saved', 'data', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('data', 'templates def', 'data', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_feedback_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('feedback', 'startcomplete', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'submit', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'delete', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'view', 'feedback', 'name');
upgrade_log_display_entry('feedback', 'view all', 'course', 'shortname');
}
......@@ -158,15 +158,4 @@
</INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('feedback', 'startcomplete', 'feedback', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('feedback', 'submit', 'feedback', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('feedback', 'delete', 'feedback', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('feedback', 'view', 'feedback', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('feedback', 'view all', 'course', 'shortname')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
......@@ -29,13 +29,6 @@ if(!isset($SESSION->feedback) OR !is_object($SESSION->feedback)) {
$SESSION->feedback = new object();
}
/**
* Code to be executed when a module is installed
*/
function feedback_install() {
return true;
}
/**
* @param string $feature FEATURE_xx constant for requested feature
* @return mixed True if module supports feature, null if doesn't know
......
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_forum_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('forum', 'add', 'forum', 'name');
upgrade_log_display_entry('forum', 'update', 'forum', 'name');
upgrade_log_display_entry('forum', 'add discussion', 'forum_discussions', 'name');
upgrade_log_display_entry('forum', 'add post', 'forum_posts', 'subject');
upgrade_log_display_entry('forum', 'update post', 'forum_posts', 'subject');
upgrade_log_display_entry('forum', 'user report', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)');
upgrade_log_display_entry('forum', 'move discussion', 'forum_discussions', 'name');
upgrade_log_display_entry('forum', 'view subscribers', 'forum', 'name');
upgrade_log_display_entry('forum', 'view discussion', 'forum_discussions', 'name');
upgrade_log_display_entry('forum', 'view forum', 'forum', 'name');
upgrade_log_display_entry('forum', 'subscribe', 'forum', 'name');
upgrade_log_display_entry('forum', 'unsubscribe', 'forum', 'name');
}
......@@ -166,22 +166,4 @@
</INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'add', 'forum', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'update', 'forum', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'add discussion', 'forum_discussions', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'add post', 'forum_posts', 'subject')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'update post', 'forum_posts', 'subject')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'user report', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'move discussion', 'forum_discussions', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'view subscribers', 'forum', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'view discussion', 'forum_discussions', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'view forum', 'forum', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'subscribe', 'forum', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('forum', 'unsubscribe', 'forum', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
\ No newline at end of file
......@@ -30,14 +30,6 @@ define ('FORUM_AGGREGATE_SUM', 5);
/// STANDARD FUNCTIONS ///////////////////////////////////////////////////////////
/**
* Code to be executed when a module is installed
*/
function forum_install() {
return true;
}
/**
* Given an object containing all the necessary data,
* (defined by the form in mod_form.php) this function
......
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_glossary_install() {
global $DB;
/// Install logging support
upgrade_log_display_entry('glossary', 'add', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'view', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'view all', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'add entry', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update entry', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'add category', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update category', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'delete category', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'add comment', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'update comment', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'delete comment', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'approve entry', 'glossary', 'name');
upgrade_log_display_entry('glossary', 'view entry', 'glossary_entries', 'concept');
}
......@@ -151,24 +151,4 @@
</INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
<SENTENCES>
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'add', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'update', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'view', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'view all', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'add entry', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'update entry', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'add category', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'update category', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'delete category', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'add comment', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'update comment', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'delete comment', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'approve entry', 'glossary', 'name')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('glossary', 'view entry', 'glossary_entries', 'concept')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
<?php //$Id$
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.php
function xmldb_hotpot_install() {
global $DB;
/// Disable it by default
$DB->set_field('modules', 'visible', 0, array('name'=>'hotpot'));
/// Install logging support here
}
......@@ -18,6 +18,13 @@ function xmldb_hotpot_upgrade($oldversion) {
// ensure "hotpot_upgrade_grades" function is available
require_once $CFG->dirroot.'/mod/hotpot/lib.php';
hotpot_upgrade_grades();
upgrade_mod_savepoint(true, 2007101511, 'hotpot');
}
if ($result && $oldversion < 2008011200) {
// remove not used setting
unset_config('hotpot_initialdisable');
upgrade_mod_savepoint(true, 2008011200, 'hotpot');
}
return $result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment