3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
5 // IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
6 // LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
8 function resource_upgrade($oldversion) {
9 // This function does anything necessary to upgrade
10 // older versions to match current functionality
14 if ($oldversion < 2003082000) {
15 table_column("resource", "course", "course", "integer", "10", "unsigned", "0");
18 if ($oldversion < 2004013101) {
19 modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'update', 'resource', 'name');");
20 modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'add', 'resource', 'name');");
23 if ($oldversion < 2004071000) {
24 table_column("resource", "", "popup", "text", "", "", "", "", "alltext");
25 if ($resources = get_records_select("resource", "type='3' OR type='5'", "", "id, alltext")) {
26 foreach ($resources as $resource) {
27 $resource->popup
= addslashes($resource->alltext
);
28 $resource->alltext
= "";
29 if (!update_record("resource", $resource)) {
30 notify("Error updating popup field for resource id = $resource->id");
34 require_once("$CFG->dirroot/course/lib.php");
35 rebuild_course_cache();
38 if ($oldversion < 2004071300) {
39 table_column("resource", "", "options", "varchar", "255", "", "", "", "popup");
42 if ($oldversion < 2004071303) {
43 table_column("resource", "type", "type", "varchar", "30", "", "", "", "");
45 modify_database("", "UPDATE prefix_resource SET type='reference' WHERE type='1';");
46 modify_database("", "UPDATE prefix_resource SET type='file', options='frame' WHERE type='2';");
47 modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='3';");
48 modify_database("", "UPDATE prefix_resource SET type='text', options='0' WHERE type='4';");
49 modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='5';");
50 modify_database("", "UPDATE prefix_resource SET type='html' WHERE type='6';");
51 modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';");
52 modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';");
53 modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';");
56 if ($oldversion < 2004080801) {
57 modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';");
58 rebuild_course_cache();
61 if ($oldversion < 2004111200) { //drop first to avoid conflicts when upgrading
62 execute_sql("ALTER TABLE {$CFG->prefix}resource DROP INDEX course;",false);
64 modify_database('','ALTER TABLE prefix_resource ADD INDEX course (course);');
67 if ($oldversion < 2005041100) { // replace wiki-like with markdown
68 include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
69 $wtm = new WikiToMarkdown();
70 $wtm->update( 'resource','alltext','options' );
73 if ($oldversion < 2006042800) {
74 execute_sql("UPDATE {$CFG->prefix}resource SET reference='' WHERE reference IS NULL");
75 table_column('resource','reference','reference','varchar','255','','','not null');
78 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.