Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / mod / resource / db / postgres7.php
blob1a9ca381e93d50399da50ec615c42c0f13c407bc
1 <?php // $Id$
3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
4 //
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
12 global $CFG ;
14 if ($oldversion < 2004013101) {
15 modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'update', 'resource', 'name');");
16 modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('resource', 'add', 'resource', 'name');");
19 if ($oldversion < 2004071000) {
20 table_column("resource", "", "popup", "text", "", "", "", "", "alltext");
21 if ($resources = get_records_select("resource", "type='3' OR type='5'", "", "id, alltext")) {
22 foreach ($resources as $resource) {
23 $resource->popup = addslashes($resource->alltext);
24 $resource->alltext = "";
25 if (!update_record("resource", $resource)) {
26 notify("Error updating popup field for resource id = $resource->id");
30 require_once("$CFG->dirroot/course/lib.php");
31 rebuild_course_cache();
34 if ($oldversion < 2004071300) {
35 table_column("resource", "", "options", "varchar", "255", "", "", "", "popup");
38 if ($oldversion < 2004071303) {
39 table_column("resource", "type", "type", "varchar", "30", "", "", "", "");
41 modify_database("", "UPDATE prefix_resource SET type='reference' WHERE type='1';");
42 modify_database("", "UPDATE prefix_resource SET type='file', options='frame' WHERE type='2';");
43 modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='3';");
44 modify_database("", "UPDATE prefix_resource SET type='text', options='0' WHERE type='4';");
45 modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='5';");
46 modify_database("", "UPDATE prefix_resource SET type='html' WHERE type='6';");
47 modify_database("", "UPDATE prefix_resource SET type='file' WHERE type='7';");
48 modify_database("", "UPDATE prefix_resource SET type='text', options='3' WHERE type='8';");
49 modify_database("", "UPDATE prefix_resource SET type='directory' WHERE type='9';");
52 if ($oldversion < 2004080801) {
53 modify_database("", "UPDATE prefix_resource SET alltext=reference,type='html' WHERE type='reference';");
54 rebuild_course_cache();
57 if ($oldversion < 2004111200) {//drop first to avoid conflicts when upgrading
58 execute_sql("DROP INDEX {$CFG->prefix}resource_course_idx;",false);
60 modify_database('','CREATE INDEX prefix_resource_course_idx ON prefix_resource (course);');
63 if ($oldversion < 2005041100) { // replace wiki-like with markdown
64 include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
65 $wtm = new WikiToMarkdown();
66 $wtm->update( 'resource','alltext','options' );
69 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.
71 return true;