added some strings for labels for dateselector and datetimeselector day, month etc...
[moodle.git] / lib / db / upgrade.php
CommitLineData
4e423cbf 1<?PHP //$Id$
2
3// This file keeps track of upgrades to Moodle.
4//
5// Sometimes, changes between versions involve
6// alterations to database structures and other
7// major things that may break installations.
8//
9// The upgrade function in this file will attempt
10// to perform all the necessary actions to upgrade
11// your older installtion to the current version.
12//
13// If there's something it cannot do itself, it
14// will tell you what you need to do.
15//
16// The commands in here will all be database-neutral,
17// using the functions defined in lib/ddllib.php
18
19
20function xmldb_main_upgrade($oldversion=0) {
21
22 global $CFG, $THEME, $db;
23
24 $result = true;
25
26 if ($oldversion < 2006100401) {
27 /// Only for those tracking Moodle 1.7 dev, others will have these dropped in moodle_install_roles()
4c2275d5 28 if (!empty($CFG->rolesactive)) {
acc26e71 29 drop_table(new XMLDBTable('user_students'));
30 drop_table(new XMLDBTable('user_teachers'));
31 drop_table(new XMLDBTable('user_coursecreators'));
32 drop_table(new XMLDBTable('user_admins'));
4e423cbf 33 }
34 }
35
e27a9437 36 if ($oldversion < 2006100601) { /// Disable the exercise module because it's unmaintained
37 if ($module = get_record('modules', 'name', 'exercise')) {
38 if ($module->visible) {
39 // Hide/disable the module entry
40 set_field('modules', 'visible', '0', 'id', $module->id);
41 // Save existing visible state for all activities
42 set_field('course_modules', 'visibleold', '1', 'visible' ,'1', 'module', $module->id);
43 set_field('course_modules', 'visibleold', '0', 'visible' ,'0', 'module', $module->id);
44 // Hide all activities
45 set_field('course_modules', 'visible', '0', 'module', $module->id);
46
47 require_once($CFG->dirroot.'/course/lib.php');
48 rebuild_course_cache(); // Rebuld cache for all modules because they might have changed
49 }
50 }
51 }
52
49e67510 53 if ($oldversion < 2006101001) { /// Disable the LAMS module by default
54 if (!count_records('lams')) {
55 set_field('modules', 'visible', 0, 'name', 'lams'); // Disable it by default
56 }
57 }
74807b43 58
59 if ($result && $oldversion < 2006102600) {
60
61 /// Define fields to be added to user_info_field
62 $table = new XMLDBTable('user_info_field');
63 $field = new XMLDBField('description');
64 $field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'categoryid');
65 $field1 = new XMLDBField('param1');
66 $field1->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'defaultdata');
67 $field2 = new XMLDBField('param2');
68 $field2->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param1');
69 $field3 = new XMLDBField('param3');
70 $field3->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param2');
71 $field4 = new XMLDBField('param4');
72 $field4->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param3');
73 $field5 = new XMLDBField('param5');
74 $field5->setAttributes(XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null, 'param4');
75
76 /// Launch add fields
77 $result = $result && add_field($table, $field);
78 $result = $result && add_field($table, $field1);
79 $result = $result && add_field($table, $field2);
80 $result = $result && add_field($table, $field3);
81 $result = $result && add_field($table, $field4);
82 $result = $result && add_field($table, $field5);
83 }
84
7d0e5a95 85 if ($result && $oldversion < 2006112000) {
86
87 /// Define field attachment to be added to post
88 $table = new XMLDBTable('post');
89 $field = new XMLDBField('attachment');
90 $field->setAttributes(XMLDB_TYPE_CHAR, '100', null, null, null, null, null, null, 'format');
91
92 /// Launch add field attachment
93 $result = $result && add_field($table, $field);
94 }
54dc87b8 95
96 if ($result && $oldversion < 2006112200) {
97
98 /// Define field imagealt to be added to user
99 $table = new XMLDBTable('user');
100 $field = new XMLDBField('imagealt');
101 $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null, 'trustbitmask');
102
103 /// Launch add field imagealt
104 $result = $result && add_field($table, $field);
105
106 $table = new XMLDBTable('user');
107 $field = new XMLDBField('screenreader');
108 $field->setAttributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null, null, '0', 'imagealt');
109
110 /// Launch add field screenreader
111 $result = $result && add_field($table, $field);
112 }
49e67510 113
7b678e0a 114 if ($oldversion < 2006120300) { /// Delete guest course section settings
115 // following code can be executed repeatedly, such as when upgrading from 1.7.x - it is ok
116 if ($guest = get_record('user', 'username', 'guest')) {
117 execute_sql("DELETE FROM {$CFG->prefix}course_display where userid=$guest->id ;", true);
118 }
119 }
120
9c0f063b 121 if ($oldversion < 2006120400) { /// Remove secureforms config setting
122 execute_sql("DELETE FROM {$CFG->prefix}config where name='secureforms' ;", true);
123 }
124
4e423cbf 125 return $result;
74807b43 126
4e423cbf 127}
128
129?>