Default theme is standardwhite, and added filterall
[moodle.git] / lib / db / postgres7.php
CommitLineData
31f0900c 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// Versions are defined by /version.php
17//
18// This file is tailored to PostgreSQL 7
19
e7311a0a 20function main_upgrade($oldversion=0) {
5867bfb5 21
4d744a22 22 global $CFG, $THEME, $db;
5867bfb5 23
e40488f8 24 $result = true;
5867bfb5 25
26
db70b54b 27 if ($oldversion < 2003010101) {
28 delete_records("log_display", "module", "user");
29 $new->module = "user";
30 $new->action = "view";
31 $new->mtable = "user";
32 $new->field = "CONCAT(firstname,\" \",lastname)";
33 insert_record("log_display", $new);
34
35 delete_records("log_display", "module", "course");
36 $new->module = "course";
37 $new->action = "view";
38 $new->mtable = "course";
39 $new->field = "fullname";
40 insert_record("log_display", $new);
41 $new->action = "update";
42 insert_record("log_display", $new);
43 $new->action = "enrol";
44 insert_record("log_display", $new);
45 }
1924074c 46
047d30d1 47 //support user based course creating
1924074c 48 if ($oldversion < 2003032400) {
a273084d 49 execute_sql("CREATE TABLE {$CFG->prefix}user_coursecreators (
1924074c 50 id int8 SERIAL PRIMARY KEY,
51 userid int8 NOT NULL default '0'
52 )");
047d30d1 53 }
1acfbce5 54
047d30d1 55 if ($oldversion < 2003041400) {
1acfbce5 56 table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
57 }
718ad19f 58
047d30d1 59 if ($oldversion < 2003042104) { // Try to update permissions of all files
718ad19f 60 if ($files = get_directory_list($CFG->dataroot)) {
61 echo "Attempting to update permissions for all files... ignore any errors.";
62 foreach ($files as $file) {
839f2456 63 echo "$CFG->dataroot/$file<br />";
b369ff55 64 @chmod("$CFG->dataroot/$file", $CFG->directorypermissions);
718ad19f 65 }
66 }
67 }
68
13df5aee 69 if ($oldversion < 2003042400) {
70 // Rebuild all course caches, because of changes to do with visible variable
71 if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
72 require_once("$CFG->dirroot/course/lib.php");
73 foreach ($courses as $course) {
74 $modinfo = serialize(get_array_of_activities($course->id));
75
76 if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
77 notify("Could not cache module information for course '$course->fullname'!");
78 }
79 }
80 }
81 }
31f0900c 82
047d30d1 83 if ($oldversion < 2003042500) {
84 // Convert all usernames to lowercase.
85 $users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
86 $cerrors = "";
87 $rarray = array();
88
89 foreach ($users as $user) { // Check for possible conflicts
90 $lcname = trim(moodle_strtolower($user->username));
91 if (in_array($lcname, $rarray)) {
e40488f8 92 $cerrors .= $user->id."->".$lcname.'<br/>' ;
047d30d1 93 } else {
94 array_push($rarray,$lcname);
95 }
e40488f8 96 }
047d30d1 97
e40488f8 98 if ($cerrors != '') {
047d30d1 99 notify("Error: Cannot convert usernames to lowercase.
100 Following usernames would overlap (id->username):<br/> $cerrors .
101 Please resolve overlapping errors.");
e40488f8 102 $result = false;
047d30d1 103 }
104
105 $cerrors = "";
839f2456 106 echo "Checking userdatabase:<br />";
047d30d1 107 foreach ($users as $user) {
108 $lcname = trim(moodle_strtolower($user->username));
109 if ($lcname != $user->username) {
110 $convert = set_field("user" , "username" , $lcname, "id", $user->id);
111 if (!$convert) {
e40488f8 112 if ($cerrors){
113 $cerrors .= ", ";
114 }
115 $cerrors .= $item;
047d30d1 116 } else {
117 echo ".";
e40488f8 118 }
119 }
047d30d1 120 }
121 if ($cerrors != '') {
122 notify("There were errors when converting following usernames to lowercase.
123 '$cerrors' . Sorry, but you will need to fix your database by hand.");
124 $result = false;
e40488f8 125 }
126 }
047d30d1 127
e209e0b0 128 if ($oldversion < 2003042700) {
129 /// Changing to multiple indexes
ea563f8f 130 execute_sql(" CREATE INDEX {$CFG->prefix}log_coursemoduleaction_idx ON {$CFG->prefix}log (course,module,action) ");
131 execute_sql(" CREATE INDEX {$CFG->prefix}log_courseuserid_idx ON {$CFG->prefix}log (course,userid) ");
e209e0b0 132 }
b86fc0e2 133
134 if ($oldversion < 2003042801) {
135 execute_sql("CREATE TABLE {$CFG->prefix}course_display (
136 id SERIAL PRIMARY KEY,
137 course integer NOT NULL default '0',
138 userid integer NOT NULL default '0',
139 display integer NOT NULL default '0'
140 )");
141
ea563f8f 142 execute_sql("CREATE INDEX {$CFG->prefix}course_display_courseuserid_idx ON {$CFG->prefix}course_display (course,userid)");
b86fc0e2 143 }
7d99d695 144
145 if ($oldversion < 2003050400) {
146 table_column("course_sections", "", "visible", "integer", "1", "unsigned", "1", "", "");
147 }
e209e0b0 148
465fd00e 149 if ($oldversion < 2003050401) {
150 table_column("user", "", "lang", "VARCHAR", "5", "", "$CFG->lang" ,"NOT NULL","");
151 }
7e6b0b3b 152
153 if ($oldversion < 2003050900) {
154 table_column("modules", "", "visible", "integer", "1", "unsigned", "1", "", "");
155 }
156
5867bfb5 157 if ($oldversion < 2003050902) {
158 if (get_records("modules", "name", "pgassignment")) {
159 print_simple_box("Note: the pgassignment module will soon be deleted from CVS! Go to the new 'Manage Modules' page and DELETE IT from your system", "center", "50%", "$THEME->cellheading", "20", "noticebox");
160 }
161 }
162
7adf6787 163 if ($oldversion < 2003051600) {
164 print_simple_box("Thanks for upgrading!<p>There are many changes since the last release. Please read the release notes carefully. If you are using CUSTOM themes you will need to edit them. You will also need to check your site's config.php file.", "center", "50%", "$THEME->cellheading", "20", "noticebox");
165 }
166
7f2a3e67 167 if ($oldversion < 2003052300) {
168 table_column("user", "", "autosubscribe", "integer", "1", "unsigned", "1", "", "htmleditor");
169 }
170
a6d82c3f 171 if ($oldversion < 2003072100) {
172 table_column("course", "", "visible", "integer", "1", "unsigned", "1", "", "marker");
173 }
174
dd0bd508 175 if ($oldversion < 2003072101) {
176 table_column("course_sections", "sequence", "sequence", "text", "", "", "", "", "");
177 }
178
a8fa25d1 179 if ($oldversion < 2003072800) {
180 print_simple_box("The following database index improves performance, but can be quite large - if you are upgrading and you have problems with a limited quota you may want to delete this index later from the '{$CFG->prefix}log' table in your database", "center", "50%", "$THEME->cellheading", "20", "noticebox");
1dbb6e50 181 flush();
a8fa25d1 182 execute_sql(" CREATE INDEX {$CFG->prefix}log_timecoursemoduleaction_idx ON {$CFG->prefix}log (time,course,module,action) ");
183 execute_sql(" CREATE INDEX {$CFG->prefix}user_students_courseuserid_idx ON {$CFG->prefix}user_students (course,userid) ");
184 execute_sql(" CREATE INDEX {$CFG->prefix}user_teachers_courseuserid_idx ON {$CFG->prefix}user_teachers (course,userid) ");
185 }
186
c2cb4545 187 if ($oldversion < 2003072802) {
188 table_column("course_categories", "", "description", "text", "", "", "");
189 table_column("course_categories", "", "parent", "integer", "10", "unsigned");
190 table_column("course_categories", "", "sortorder", "integer", "10", "unsigned");
191 table_column("course_categories", "", "courseorder", "text", "", "", "");
192 table_column("course_categories", "", "visible", "integer", "1", "unsigned", "1");
193 table_column("course_categories", "", "timemodified", "integer", "10", "unsigned");
194 }
195
d2b6ba70 196 if ($oldversion < 2003080400) {
c7ce6d80 197 notify("If the following command fails you may want to change the type manually, from TEXT to INTEGER. Moodle should keep working even if you don't.");
d2b6ba70 198 table_column("course_categories", "courseorder", "courseorder", "integer", "10", "unsigned");
199 table_column("course", "", "sortorder", "integer", "10", "unsigned", "0", "", "category");
200 }
201
a142b3b4 202 if ($oldversion < 2003081502) {
203 execute_sql(" CREATE TABLE {$CFG->prefix}scale (
204 id SERIAL PRIMARY KEY,
205 courseid integer NOT NULL default '0',
206 userid integer NOT NULL default '0',
207 name varchar(255) NOT NULL default '',
208 scale text,
209 description text,
210 timemodified integer NOT NULL default '0'
211 )");
212 }
213
11402bbd 214 if ($oldversion < 2003081503) {
6f4f04df 215 table_column("forum", "", "scale", "integer", "10", "unsigned", "0", "", "assessed");
11402bbd 216 get_scales_menu(0); // Just to force the default scale to be created
217 }
218
73047f2f 219 if ($oldversion < 2003081600) {
220 table_column("user_teachers", "", "editall", "integer", "1", "unsigned", "1", "", "role");
221 table_column("user_teachers", "", "timemodified", "integer", "10", "unsigned", "0", "", "editall");
222 }
50b5487c 223
9936fe81 224 if ($oldversion < 2003081900) {
225 table_column("course_categories", "courseorder", "coursecount", "integer", "10", "unsigned", "0");
226 }
227
f63823b3 228 if ($oldversion < 2003080700) {
229 notify("Cleaning up categories and course ordering...");
6bc502cc 230 fix_course_sortorder();
f63823b3 231 }
232
233
fff79722 234 if ($oldversion < 2003082001) {
235 table_column("course", "", "showgrades", "integer", "2", "unsigned", "1", "", "format");
236 }
237
3052e775 238 if ($oldversion < 2003082101) {
239 execute_sql(" CREATE INDEX {$CFG->prefix}course_category_idx ON {$CFG->prefix}course (category) ");
240 }
d0117715 241 if ($oldversion < 2003082702) {
242 execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname,\" \",lastname)') ");
243 }
3052e775 244
e71f132d 245 if ($oldversion < 2003091000) {
246 # Old field that was never added!
247 table_column("course", "", "showrecent", "integer", "10", "unsigned", "1", "", "numsections");
248 }
249
aac94fd0 250 if ($oldversion < 2003091400) {
251 table_column("course_modules", "", "indent", "integer", "5", "unsigned", "0", "", "score");
252 }
253
4909e176 254 if ($oldversion < 2003092900) {
255 table_column("course", "", "maxbytes", "integer", "10", "unsigned", "0", "", "marker");
256 }
aac94fd0 257
4d744a22 258 if ($oldversion < 2003102700) {
259 table_column("user_students", "", "timeaccess", "integer", "10", "unsigned", "0", "", "time");
260 table_column("user_teachers", "", "timeaccess", "integer", "10", "unsigned", "0", "", "timemodified");
261
4d744a22 262 $db->debug = false;
29b25b04 263 $CFG->debug = 0;
264 notify("Calculating access times. Please wait - this may take a long time on big sites...", "green");
265 flush();
266
267 if ($courses = get_records_select("course", "category > 0")) {
268 foreach ($courses as $course) {
269 notify("Processing $course->fullname ...", "green");
270 flush();
271 if ($users = get_records_select("user_teachers", "course = '$course->id'",
272 "id", "id, userid, timeaccess")) {
273 foreach ($users as $user) {
274 $loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log WHERE course = '$course->id' and userid = '$user->userid' ORDER by time DESC");
275 if (empty($loginfo->time)) {
276 $loginfo->time = 0;
277 }
278 execute_sql("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$loginfo->time'
279 WHERE userid = '$user->userid' AND course = '$course->id'", false);
280
281 }
282 }
283
284 if ($users = get_records_select("user_students", "course = '$course->id'",
285 "id", "id, userid, timeaccess")) {
286 foreach ($users as $user) {
287 $loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log
288 WHERE course = '$course->id' and userid = '$user->userid'
289 ORDER by time DESC");
290 if (empty($loginfo->time)) {
291 $loginfo->time = 0;
292 }
293 execute_sql("UPDATE {$CFG->prefix}user_students
294 SET timeaccess = '$loginfo->time'
295 WHERE userid = '$user->userid' AND course = '$course->id'", false);
296
297 }
298 }
299 }
4d744a22 300 }
29b25b04 301 notify("All courses complete.", "green");
4d744a22 302 $db->debug = true;
303 }
304
3f125001 305 if ($oldversion < 2003103100) {
306 table_column("course", "", "showreports", "integer", "4", "unsigned", "0", "", "maxbytes");
307 }
308
4d744a22 309
f374fb10 310 if ($oldversion < 2003121600) {
0da33e07 311 execute_sql("CREATE TABLE {$CFG->prefix}groups (
f374fb10 312 id SERIAL PRIMARY KEY,
313 courseid integer NOT NULL default '0',
314 name varchar(255) NOT NULL default '',
315 description text,
316 lang varchar(10) NOT NULL default '',
317 picture integer NOT NULL default '0',
318 timecreated integer NOT NULL default '0',
319 timemodified integer NOT NULL default '0'
320 )");
321
0da33e07 322 execute_sql("CREATE INDEX {$CFG->prefix}groups_idx ON {$CFG->prefix}groups (courseid) ");
f374fb10 323
0da33e07 324 execute_sql("CREATE TABLE {$CFG->prefix}groups_members (
f374fb10 325 id SERIAL PRIMARY KEY,
326 groupid integer NOT NULL default '0',
327 userid integer NOT NULL default '0',
328 timeadded integer NOT NULL default '0'
329 )");
330
0da33e07 331 execute_sql("CREATE INDEX {$CFG->prefix}groups_members_idx ON {$CFG->prefix}groups_members (groupid) ");
f374fb10 332 }
333
334 if ($oldversion < 2003122600) {
335 table_column("course", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
336 table_column("course", "", "groupmodeforce", "integer", "4", "unsigned", "0", "", "groupmode");
337 }
338
ddc7afad 339 if ($oldversion < 2004010900) {
340 table_column("course_modules", "", "groupmode", "integer", "4", "unsigned", "0", "", "visible");
341 }
342
5fba04fb 343 if ($oldversion < 2004011700) {
344 modify_database("", "CREATE TABLE prefix_event (
345 id SERIAL PRIMARY KEY,
346 name varchar(255) NOT NULL default '',
347 description text,
348 courseid integer NOT NULL default '0',
349 groupid integer NOT NULL default '0',
350 userid integer NOT NULL default '0',
351 modulename varchar(20) NOT NULL default '',
352 instance integer NOT NULL default '0',
353 eventtype varchar(20) NOT NULL default '',
354 timestart integer NOT NULL default '0',
355 timeduration integer NOT NULL default '0',
356 timemodified integer NOT NULL default '0'
357 ); ");
358
359 modify_database("", "CREATE INDEX prefix_event_courseid_idx ON prefix_event (courseid);");
360 modify_database("", "CREATE INDEX prefix_event_userid_idx ON prefix_event (userid);");
361 }
362
363
70812e39 364 if ($oldversion < 2004012800) {
365 modify_database("", "CREATE TABLE prefix_user_preferences (
366 id SERIAL PRIMARY KEY,
367 userid integer NOT NULL default '0',
368 name varchar(50) NOT NULL default '',
369 value varchar(255) NOT NULL default ''
370 ); ");
371
372 modify_database("", "CREATE INDEX prefix_user_preferences_useridname_idx ON prefix_user_preferences (userid,name);");
373 }
374
ba39fa10 375 if ($oldversion < 2004012900) {
376 table_column("config", "value", "value", "text", "", "", "");
377 }
69d79bc3 378
379 if ($oldversion < 2004013101) {
380 table_column("log", "", "cmid", "integer", "10", "unsigned", "0", "", "module");
4da1a0a1 381 set_config("upgrade", "logs");
69d79bc3 382 }
95d45757 383
b3153e4b 384 if ($oldversion < 2004020900) {
385 table_column("course", "", "lang", "varchar", "5", "", "", "", "groupmodeforce");
386 }
387
45121ffb 388 if ($oldversion < 2004020903) {
389 modify_database("", "CREATE TABLE prefix_cache_text (
d363047e 390 id SERIAL PRIMARY KEY,
391 md5key varchar(32) NOT NULL default '',
392 formattedtext text,
393 timemodified integer NOT NULL default '0'
394 );");
395 }
396
d523d2ea 397 if ($oldversion < 2004021000) {
398 $textfilters = array();
399 for ($i=1; $i<=10; $i++) {
400 $variable = "textfilter$i";
401 if (!empty($CFG->$variable)) { /// No more filters
402 if (is_readable("$CFG->dirroot/".$CFG->$variable)) {
403 $textfilters[] = $CFG->$variable;
404 }
405 }
406 }
407 $textfilters = implode(',', $textfilters);
408 if (empty($textfilters)) {
409 $textfilters = 'mod/glossary/dynalink.php';
410 }
411 set_config('textfilters', $textfilters);
412 }
413
f1d604cb 414 if ($oldversion < 2004021201) {
415 modify_database("", "CREATE TABLE prefix_cache_filters (
416 id SERIAL PRIMARY KEY,
417 filter varchar(32) NOT NULL default '',
418 version integer NOT NULL default '0',
419 md5key varchar(32) NOT NULL default '',
420 rawtext text,
421 timemodified integer NOT NULL default '0'
422 );");
423
424 modify_database("", "CREATE INDEX prefix_cache_filters_filtermd5key_idx ON prefix_cache_filters (filter,md5key);");
425 modify_database("", "CREATE INDEX prefix_cache_text_md5key_idx ON prefix_cache_text (md5key);");
426 }
d523d2ea 427
3c0561cf 428 if ($oldversion < 2004021500) {
429 table_column("groups", "", "hidepicture", "integer", "2", "unsigned", "0", "", "picture");
430 }
431
9e353ce7 432 if ($oldversion < 2004021700) {
433 if (!empty($CFG->textfilters)) {
434 $CFG->textfilters = str_replace("tex_filter.php", "filter.php", $CFG->textfilters);
435 $CFG->textfilters = str_replace("multilang.php", "filter.php", $CFG->textfilters);
436 $CFG->textfilters = str_replace("censor.php", "filter.php", $CFG->textfilters);
437 $CFG->textfilters = str_replace("mediaplugin.php", "filter.php", $CFG->textfilters);
438 $CFG->textfilters = str_replace("algebra_filter.php", "filter.php", $CFG->textfilters);
828aeff2 439 $CFG->textfilters = str_replace("dynalink.php", "filter.php", $CFG->textfilters);
9e353ce7 440 set_config("textfilters", $CFG->textfilters);
441 }
442 }
443
8199e3f0 444 if ($oldversion < 2004022000) {
445 table_column("user", "", "emailstop", "integer", "1", "unsigned", "0", "not null", "email");
446 }
447
828aeff2 448 if ($oldversion < 2004022200) { /// Final renaming I hope. :-)
449 if (!empty($CFG->textfilters)) {
450 $CFG->textfilters = str_replace("/filter.php", "", $CFG->textfilters);
a4dda51f 451 $CFG->textfilters = str_replace("mod/glossary/dynalink.php", "mod/glossary", $CFG->textfilters);
828aeff2 452 $textfilters = explode(',', $CFG->textfilters);
453 foreach ($textfilters as $key => $textfilter) {
454 $textfilters[$key] = trim($textfilter);
455 }
456 set_config("textfilters", implode(',',$textfilters));
457 }
458 }
459
4bf58667 460 if ($oldversion < 2004030702) { /// Because of the renaming of Czech language pack
461 execute_sql("UPDATE {$CFG->prefix}user SET lang = 'cs' WHERE lang = 'cz'");
462 execute_sql("UPDATE {$CFG->prefix}course SET lang = 'cs' WHERE lang = 'cz'");
7277e306 463 }
464
0f3fe4b6 465 if ($oldversion < 2004041800) { /// Integrate Block System from contrib
466 table_column("course", "", "blockinfo", "varchar", "255", "", "", "not null", "modinfo");
467 }
468
822ede92 469 if ($oldversion < 2004042600) { /// Rebuild course caches for resource icons
470 include_once("$CFG->dirroot/course/lib.php");
471 rebuild_course_cache();
472 }
473
cda21d48 474 if ($oldversion < 2004042700) { /// Increase size of lang fields
37aaf074 475 table_column("user", "lang", "lang", "varchar", "10", "", "en");
476 table_column("groups", "lang", "lang", "varchar", "10", "", "");
477 table_column("course", "lang", "lang", "varchar", "10", "", "");
478 }
479
009cc726 480 if ($oldversion < 2004042701) { /// Add hiddentopics field to control hidden topics behaviour
464fd803 481 #table_column("course", "", "hiddentopics", "integer", "1", "unsigned", "0", "not null", "visible");
482 #See 'hiddensections' further down
009cc726 483 }
484
cda21d48 485 if ($oldversion < 2004042702) { /// Add a format field for the description
486 table_column("event", "", "format", "integer", "4", "unsigned", "0", "not null", "description");
487 }
488
464fd803 489 if ($oldversion < 2004043001) { /// Add hiddentopics field to control hidden topics behaviour
490 table_column("course", "", "hiddensections", "integer", "2", "unsigned", "0", "not null", "visible");
19a40309 491 }
dcd338ff 492
493 if ($oldversion < 2004050400) { /// add a visible field for events
05ba8bd0 494 table_column("event", "", "visible", "smallint", "1", "", "1", "not null", "timeduration");
dcd338ff 495 if ($events = get_records('event')) {
496 foreach($events as $event) {
497 if ($moduleid = get_field('modules', 'id', 'name', $event->modulename)) {
498 if (get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $event->instance) == 0) {
499 set_field('event', 'visible', 0, 'id', $event->id);
500 }
501 }
502 }
503 }
504 }
19a40309 505
3cac987a 506 if ($oldversion < 2004052800) { /// First version tagged "1.4 development", version.php 1.227
e02c35b2 507 set_config('siteblocksadded', true); /// This will be used later by the block upgrade
3cac987a 508 }
509
62b80756 510 if ($oldversion < 2004053000) { /// set defaults for site course
511 $site = get_site();
a7e07837 512 set_field('course', 'numsections', 0, 'id', $site->id);
62b80756 513 set_field('course', 'groupmodeforce', 1, 'id', $site->id);
514 set_field('course', 'teacher', get_string('administrator'), 'id', $site->id);
515 set_field('course', 'teachers', get_string('administrators'), 'id', $site->id);
516 set_field('course', 'student', get_string('user'), 'id', $site->id);
517 set_field('course', 'students', get_string('users'), 'id', $site->id);
518 }
519
cc21211e 520 if ($oldversion < 2004060100) {
521 set_config('digestmailtime', 0);
522 table_column('user', "", 'maildigest', 'smallint', '1', '', '0', 'not null', 'mailformat');
cc21211e 523 }
524
faef9f7b 525 if ($oldversion < 2004062400) {
526 table_column('user_teachers', "", 'timeend', 'int', '10', 'unsigned', '0', 'not null', 'editall');
527 table_column('user_teachers', "", 'timestart', 'int', '10', 'unsigned', '0', 'not null', 'editall');
528 }
529
838ee71b 530 if ($oldversion < 2004062401) {
531 table_column('course', '', 'idnumber', 'varchar', '100', '', '', 'not null', 'shortname');
532 execute_sql('UPDATE '.$CFG->prefix.'course SET idnumber = shortname'); // By default
533 }
534
8c5c6133 535 if ($oldversion < 2004062600) {
536 table_column('course', '', 'cost', 'varchar', '10', '', '', 'not null', 'lang');
537 }
838ee71b 538
18763fd4 539 if ($oldversion < 2004072900) {
540 table_column('course', '', 'enrolperiod', 'int', '10', 'unsigned', '0', 'not null', 'startdate');
541 }
542
f28db22d 543 if ($oldversion < 2004072901) { // Fixing error in schema
544 if ($record = get_record('log_display', 'module', 'course', 'action', 'update')) {
545 delete_records('log_display', 'module', 'course', 'action', 'update');
546 insert_record('log_display', $record, false, 'module');
547 }
548 }
549
9fb216e8 550 if ($oldversion < 2004081200) { // Fixing version errors in some blocks
551 set_field('blocks', 'version', 2004081200, 'name', 'admin');
552 set_field('blocks', 'version', 2004081200, 'name', 'calendar_month');
553 set_field('blocks', 'version', 2004081200, 'name', 'course_list');
554 }
555
4e11ad4f 556 if ($oldversion < 2004081500) { // Adding new "auth" field to user table to allow more flexibility
557 table_column('user', '', 'auth', 'varchar', '20', '', 'manual', 'not null', 'id');
558
559 execute_sql("UPDATE {$CFG->prefix}user SET auth = 'manual'"); // Set everyone to 'manual' to be sure
560
561 if ($admins = get_admins()) { // Set all the NON-admins to whatever the current auth module is
562 $adminlist = array();
563 foreach ($admins as $user) {
564 $adminlist[] = $user->id;
565 }
566 $adminlist = implode(',', $adminlist);
567 execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE id NOT IN ($adminlist)");
568 }
569 }
c14964b0 570
571 if ($oldversion < 2004082600) {
572 //update auth-fields for external users
573 include_once ($CFG->dirroot."/auth/".$CFG->auth."/lib.php");
574 if (function_exists('auth_get_userlist')) {
575 $externalusers = auth_get_userlist();
576 if (!empty($externalusers)){
577 $externalusers = '\''. implode('\',\'',$externalusers).'\'';
578 execute_sql("UPDATE {$CFG->prefix}user SET auth = '$CFG->auth' WHERE username IN ($externalusers)");
579 }
580 }
581 }
582
3cac987a 583 if ($oldversion < 2004082900) { // Make sure guest is "manual" too.
584 set_field('user', 'auth', 'manual', 'username', 'guest');
585 }
586
d35757eb 587 /* Just commenteed unused fields out
01e2ea5f 588 if ($oldversion < 2004090300) { // Add guid-field used in user syncronization
589 table_column('user', '', 'guid', 'varchar', '128', '', '', '', 'auth');
590 execute_sql("CREATE INDEX {$CFG->prefix}user_auth_guid_idx ON {$CFG->prefix}user (auth, guid)");
591 }
d35757eb 592 */
01e2ea5f 593
d35757eb 594 if ($oldversion < 2004091900) { //Modify idnumber to hold longer keys
595 set_field('user', 'auth', 'manual', 'username', 'guest');
596 table_column('user', 'idnumber', 'idnumber', 'varchar', '64', '', '', '', '');
17f3e7d0 597 execute_sql("DROP INDEX {$CFG->prefix}user_idnumber_idx ;",false);// added in case of conflicts with upgrade from 14stable
598 execute_sql("DROP INDEX {$CFG->prefix}user_auth_idx ;",false);// added in case of conflicts with upgrade from 14stable
d35757eb 599 execute_sql("CREATE INDEX {$CFG->prefix}user_idnumber_idx ON {$CFG->prefix}user (idnumber)");
600 execute_sql("CREATE INDEX {$CFG->prefix}user_auth_idx ON {$CFG->prefix}user (auth)");
601 }
602
5a2432d4 603 if ($oldversion < 2004092000) { //redoing this just to be sure that column type is text (postgres type changes didnt work when this was done first time)
604 table_column("config", "value", "value", "text", "", "", "");
605 }
42b90599 606
607 if ($oldversion < 2004093001) { // add new table for sessions storage
608 execute_sql(" CREATE TABLE {$CFG->prefix}sessions (
609 sesskey char(32) PRIMARY KEY,
610 expiry integer NOT null,
611 expireref varchar(64),
612 data text NOT null
613 );");
614
615 execute_sql(" CREATE INDEX {$CFG->prefix}sessions_expiry_idx ON {$CFG->prefix}sessions (expiry)");
616 }
bb043e38 617
618 if ($oldversion < 2004111500) { // Update any users/courses using wrongly-named lang pack
619 execute_sql("UPDATE {$CFG->prefix}user SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
620 execute_sql("UPDATE {$CFG->prefix}course SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
621 }
17f3e7d0 622
623 if ($oldversion < 2004111700) { // add indexes- drop them first silently to avoid conflicts when upgrading.
624 execute_sql("DROP INDEX {$CFG->prefix}course_idnumber_idx;",false);
625 execute_sql("DROP INDEX {$CFG->prefix}course_shortname_idx;",false);
626 execute_sql("DROP INDEX {$CFG->prefix}user_students_userid_idx;",false);
627 execute_sql("DROP INDEX {$CFG->prefix}user_teachers_userid_idx;",false);
628
629 modify_database("","CREATE INDEX {$CFG->prefix}course_idnumber_idx ON {$CFG->prefix}course (idnumber);" );
630 modify_database("","CREATE INDEX {$CFG->prefix}course_shortname_idx ON {$CFG->prefix}course (shortname);" );
631 modify_database("","CREATE INDEX {$CFG->prefix}user_students_userid_idx ON {$CFG->prefix}user_students (userid);");
632 modify_database("","CREATE INDEX {$CFG->prefix}user_teachers_userid_idx ON {$CFG->prefix}user_teachers (userid);");
633 }
634
635 if ($oldversion < 2004111700) { // add an index to event for timestart and timeduration- drop them first silently to avoid conflicts when upgrading.
275c630a 636 execute_sql("DROP INDEX {$CFG->prefix}event_timestart_idx;",false);
637 execute_sql("DROP INDEX {$CFG->prefix}event_timeduration_idx;",false);
17f3e7d0 638
639 modify_database('','CREATE INDEX prefix_event_timestart_idx ON prefix_event (timestart);');
640 modify_database('','CREATE INDEX prefix_event_timeduration_idx ON prefix_event (timeduration);');
641 }
642
643 if ($oldversion < 2004117000) { // add an index on the groups_members table- drop them first silently to avoid conflicts when upgrading.
275c630a 644 execute_sql("DROP INDEX {$CFG->prefix}groups_members_userid_idx;",false);
17f3e7d0 645
646 modify_database('','CREATE INDEX prefix_groups_members_userid_idx ON prefix_groups_members (userid);');
647 }
d35757eb 648
17f3e7d0 649 if ($oldversion < 2004111700) { //add indexes on modules and course_modules- drop them first silently to avoid conflicts when upgrading.
275c630a 650 execute_sql("DROP INDEX {$CFG->prefix}course_modules_visible_idx;",false);
651 execute_sql("DROP INDEX {$CFG->prefix}course_modules_course_idx;",false);
652 execute_sql("DROP INDEX {$CFG->prefix}course_modules_module_idx;",false);
653 execute_sql("DROP INDEX {$CFG->prefix}course_modules_instance_idx;",false);
654 execute_sql("DROP INDEX {$CFG->prefix}course_modules_deleted_idx;",false);
655 execute_sql("DROP INDEX {$CFG->prefix}modules_name_idx;",false);
17f3e7d0 656
657 modify_database('','CREATE INDEX prefix_course_modules_visible_idx ON prefix_course_modules (visible);');
658 modify_database('','CREATE INDEX prefix_course_modules_course_idx ON prefix_course_modules (course);');
659 modify_database('','CREATE INDEX prefix_course_modules_module_idx ON prefix_course_modules (module);');
660 modify_database('','CREATE INDEX prefix_course_modules_instance_idx ON prefix_course_modules (instance);');
661 modify_database('','CREATE INDEX prefix_course_modules_deleted_idx ON prefix_course_modules (deleted);');
662 modify_database('','CREATE INDEX prefix_modules_name_idx ON prefix_modules (name);');
663 }
664
665 if ($oldversion < 2004111700) { // add an index on user students timeaccess (used for sorting)- drop them first silently to avoid conflicts when upgrading
275c630a 666 execute_sql("DROP INDEX {$CFG->prefix}user_students_timeaccess_idx;",false);
17f3e7d0 667
668 modify_database('','CREATE INDEX prefix_user_students_timeaccess_idx ON prefix_user_students (timeaccess);');
669 }
670
671 if ($oldversion < 2004111700) { //add indexes on faux foreign keys - drop them first silently to avoid conflicts when upgrading.
275c630a 672 execute_sql("DROP INDEX {$CFG->prefix}course_sections_coursesection_idx;",false);
673 execute_sql("DROP INDEX {$CFG->prefix}scale_courseid_idx;",false);
674 execute_sql("DROP INDEX {$CFG->prefix}user_admins_userid_idx;",false);
675 execute_sql("DROP INDEX {$CFG->prefix}user_coursecreators_userid_idx;",false);
17f3e7d0 676
677 modify_database('','CREATE INDEX prefix_course_sections_coursesection_idx ON prefix_course_sections (course,section);');
678 modify_database('','CREATE INDEX prefix_scale_courseid_idx ON prefix_scale (courseid);');
679 modify_database('','CREATE INDEX prefix_user_admins_userid_idx ON prefix_user_admins (userid);');
680 modify_database('','CREATE INDEX prefix_user_coursecreators_userid_idx ON prefix_user_coursecreators (userid);');
681 }
682
ffa5f71b 683 if ($oldversion < 2004111700) { // make new indexes on user table.
684 fix_course_sortorder(0,0,1);
685
275c630a 686 execute_sql("DROP INDEX {$CFG->prefix}course_category_idx;",false);
687 execute_sql("DROP INDEX {$CFG->prefix}course_category_sortorder_uk;",false);
ffa5f71b 688 modify_database('', "CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course(category,sortorder)");
689
275c630a 690 execute_sql("DROP INDEX {$CFG->prefix}user_deleted_idx;",false);
691 execute_sql("DROP INDEX {$CFG->prefix}user_confirmed_idx;",false);
692 execute_sql("DROP INDEX {$CFG->prefix}user_firstname_idx;",false);
693 execute_sql("DROP INDEX {$CFG->prefix}user_lastname_idx;",false);
694 execute_sql("DROP INDEX {$CFG->prefix}user_city_idx;",false);
695 execute_sql("DROP INDEX {$CFG->prefix}user_country_idx;",false);
696 execute_sql("DROP INDEX {$CFG->prefix}user_lastaccess_idx;",false);
ffa5f71b 697
698 modify_database("","CREATE INDEX prefix_user_deleted_idx ON prefix_user (deleted)");
699 modify_database("","CREATE INDEX prefix_user_confirmed_idx ON prefix_user (confirmed)");
700 modify_database("","CREATE INDEX prefix_user_firstname_idx ON prefix_user (firstname)");
701 modify_database("","CREATE INDEX prefix_user_lastname_idx ON prefix_user (lastname)");
702 modify_database("","CREATE INDEX prefix_user_city_idx ON prefix_user (city)");
703 modify_database("","CREATE INDEX prefix_user_country_idx ON prefix_user (country)");
704 modify_database("","CREATE INDEX prefix_user_lastaccess_idx ON prefix_user (lastaccess)");
705 }
706
707 if ($oldversion < 2004111700) { // one more index for email (for sorting)
275c630a 708 execute_sql("DROP INDEX {$CFG->prefix}user_email_idx;",false);
ffa5f71b 709
710 modify_database('','CREATE INDEX prefix_user_email_idx ON prefix_user (email);');
711 }
5cd79686 712
713 if ($oldversion < 2004112200) { // new 'enrol' field for enrolment tables
714 table_column('user_students', '', 'enrol', 'varchar', '20', '', '', 'not null');
715 table_column('user_teachers', '', 'enrol', 'varchar', '20', '', '', 'not null');
716 modify_database("","CREATE INDEX {$CFG->prefix}user_students_enrol_idx ON {$CFG->prefix}user_students (enrol);");
91137862 717 modify_database("","CREATE INDEX {$CFG->prefix}user_teachers_enrol_idx ON {$CFG->prefix}user_teachers (enrol);");
5cd79686 718 }
f1f2c125 719
720 if ($oldversion < 2004112300) { // update log display to use correct postgres friendly sql
721 execute_sql("UPDATE {$CFG->prefix}log_display SET field='firstname||\' \'||lastname' WHERE module='user' AND action='view' AND mtable='user'");
722 execute_sql("UPDATE {$CFG->prefix}log_display SET field='firstname||\' \'||lastname' WHERE module='course' AND action='user report' AND mtable='user'");
723 }
724
b110348b 725 if ($oldversion < 2004112400) {
726
727 /// Delete duplicate enrolments
728 /// and then tell the database course,userid is a unique combination
729 if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid ".
730 "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
731 foreach ($users as $user) {
732 delete_records_select("user_students", "userid = '$user->userid' ".
733 "AND course = '$user->course' AND id <> '$user->id'");
734 }
735 }
736 flush();
737
b692d2be 738 // drop some indexes quietly -- they may or may not exist depending on what version
739 // the user upgrades from
b110348b 740 execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_idx ", false);
b692d2be 741 execute_sql("DROP INDEX {$CFG->prefix}user_students_courseuserid_uk ", false);
b110348b 742 modify_database('','CREATE UNIQUE INDEX prefix_user_students_courseuserid_uk ON prefix_user_students (course,userid);');
743
744 /// Delete duplicate teacher enrolments
745 /// and then tell the database course,userid is a unique combination
746 if ($users = get_records_select("user_teachers", "userid > 0 GROUP BY course, userid ".
747 "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
748 foreach ($users as $user) {
749 delete_records_select("user_teachers", "userid = '$user->userid' ".
750 "AND course = '$user->course' AND id <> '$user->id'");
751 }
752 }
753 flush();
754
b692d2be 755 // drop some indexes quietly -- they may or may not exist depending on what version
756 // the user upgrades from
b110348b 757 execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_idx ", false);
b692d2be 758 execute_sql("DROP INDEX {$CFG->prefix}user_teachers_courseuserid_uk ", false);
b110348b 759 modify_database('','CREATE UNIQUE INDEX prefix_user_teachers_courseuserid_uk ON prefix_user_teachers (course,userid);');
760 }
761
b692d2be 762 if ($oldversion < 2004112401) {
763 // some postgres databases may have a non-unique index mislabeled unique.
764 fix_course_sortorder(0,0,1);
765 execute_sql("DROP INDEX {$CFG->prefix}course_category_sortorder_uk ", false);
766 execute_sql("DROP INDEX {$CFG->prefix}course_category_idx ", false);
767 modify_database('', "CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course(category,sortorder);");
768
769 // odd! username was missing its unique index!
770 // first silently drop it just in case...
71dcd6c0 771 execute_sql("ALTER TABLE {$CFG->prefix}user DROP CONSTRAINT {$CFG->prefix}user_username_uk;", false);
b692d2be 772 execute_sql("DROP INDEX {$CFG->prefix}user_username_uk", false);
773 modify_database('', "CREATE UNIQUE INDEX prefix_user_username_uk ON prefix_user (username);");
774
775 }
027a1604 776
777 if ($oldversion < 2004112900) {
778 table_column('user', '', 'policyagreed', 'integer', '1', 'unsigned', '0', 'not null', 'confirmed');
779 }
1a5bc046 780
781 if ($oldversion < 2004121400) {
782 table_column('groups', '', 'password', 'varchar', '50', '', '', 'not null', 'description');
783 }
ffce79c0 784
785 if ($oldversion < 2004121600) {
786 modify_database('',"CREATE TABLE prefix_dst_preset (
787 id SERIAL PRIMARY KEY,
788 name varchar(48) NOT NULL default '',
789 apply_offset integer NOT NULL default '0',
790 activate_index integer NOT NULL default '1',
791 activate_day integer NOT NULL default '1',
792 activate_month integer NOT NULL default '1',
793 activate_time char(5) NOT NULL default '03:00',
794 deactivate_index integer NOT NULL default '1',
795 deactivate_day integer NOT NULL default '1',
796 deactivate_month integer NOT NULL default '2',
797 deactivate_time char(5) NOT NULL default '03:00',
91b4c5ee 798 last_change integer NOT NULL default '0',
799 next_change integer NOT NULL default '0',
ffce79c0 800 current_offset integer NOT NULL default '0'
91b4c5ee 801 );");
0eacb23c 802 }
803
804 if ($oldversion < 2004122800) {
805 execute_sql("DROP TABLE {$CFG->prefix}message", false);
806 execute_sql("DROP TABLE {$CFG->prefix}message_read", false);
807 execute_sql("DROP TABLE {$CFG->prefix}message_contacts", false);
ffce79c0 808
0eacb23c 809 execute_sql("DROP INDEX {$CFG->prefix}message_useridfrom_idx", false);
810 execute_sql("DROP INDEX {$CFG->prefix}message_useridto_idx", false);
811 execute_sql("DROP INDEX {$CFG->prefix}message_read_useridfrom_idx", false);
812 execute_sql("DROP INDEX {$CFG->prefix}message_read_useridto_idx", false);
813 execute_sql("DROP INDEX {$CFG->prefix}message_contacts_useridcontactid_idx", false);
ffce79c0 814
815 modify_database('',"CREATE TABLE prefix_message (
816 id SERIAL PRIMARY KEY,
817 useridfrom integer NOT NULL default '0',
818 useridto integer NOT NULL default '0',
819 message text,
0eacb23c 820 timecreated integer NOT NULL default '0',
ffce79c0 821 messagetype varchar(50) NOT NULL default ''
822 );
823
824 CREATE INDEX prefix_message_useridfrom_idx ON prefix_message (useridfrom);
825 CREATE INDEX prefix_message_useridto_idx ON prefix_message (useridto);
826
827 CREATE TABLE prefix_message_read (
828 id SERIAL PRIMARY KEY,
829 useridfrom integer NOT NULL default '0',
830 useridto integer NOT NULL default '0',
831 message text,
0eacb23c 832 timecreated integer NOT NULL default '0',
833 timeread integer NOT NULL default '0',
ffce79c0 834 messagetype varchar(50) NOT NULL default '',
835 mailed integer NOT NULL default '0'
836 );
837
838 CREATE INDEX prefix_message_read_useridfrom_idx ON prefix_message_read (useridfrom);
839 CREATE INDEX prefix_message_read_useridto_idx ON prefix_message_read (useridto);
840 ");
0eacb23c 841
842 modify_database('',"CREATE TABLE prefix_message_contacts (
843 id SERIAL PRIMARY KEY,
844 userid integer NOT NULL default '0',
845 contactid integer NOT NULL default '0',
846 blocked integer NOT NULL default '0'
847 );
848
849 CREATE INDEX prefix_message_contacts_useridcontactid_idx ON prefix_message_contacts (userid,contactid);
850 ");
851
852 modify_database('',"INSERT INTO prefix_log_display VALUES ('message', 'write', 'user', 'firstname||\' \'||lastname');
853 INSERT INTO prefix_log_display VALUES ('message', 'read', 'user', 'firstname||\' \'||lastname');
854 ");
ffce79c0 855 }
e53c030b 856
857 if ($oldversion < 2004122801) {
858 table_column('message', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'message');
859 table_column('message_read', '', 'format', 'integer', '4', 'unsigned', '0', 'not null', 'message');
860 }
0eacb23c 861
ffce79c0 862
36f01e7b 863 if ($oldversion < 2005010100) {
864 modify_database('',"INSERT INTO prefix_log_display VALUES ('message', 'add contact', 'user', 'firstname||\' \'||lastname');
865 INSERT INTO prefix_log_display VALUES ('message', 'remove contact', 'user', 'firstname||\' \'||lastname');
866 INSERT INTO prefix_log_display VALUES ('message', 'block contact', 'user', 'firstname||\' \'||lastname');
867 INSERT INTO prefix_log_display VALUES ('message', 'unblock contact', 'user', 'firstname||\' \'||lastname');
868 ");
869 }
870
2765411a 871 if ($oldversion < 2005011000) { // Create a .htaccess file in dataroot, just in case
872 if (!file_exists($CFG->dataroot.'/.htaccess')) {
873 if ($handle = fopen($CFG->dataroot.'/.htaccess', 'w')) { // For safety
874 @fwrite($handle, "deny from all\r\n");
875 @fclose($handle);
876 notify("Created a default .htaccess file in $CFG->dataroot");
877 }
878 }
879 }
880
b61efafb 881 if ($oldversion < 2005012500) { // add new table for meta courses.
483b7158 882 /*
b61efafb 883 modify_database("","CREATE TABLE prefix_meta_course (
884 id SERIAL primary key,
885 parent_course integer NOT NULL,
886 child_course integer NOT NULL
887 );");
888
889 modify_database("","CREATE INDEX prefix_meta_course_parent_idx ON prefix_meta_course (parent_course);");
890 modify_database("","CREATE INDEX prefix_meta_course_child_idx ON prefix_meta_course (child_course);");
891 table_column('course','','meta_course','integer','1','','0','not null');
483b7158 892 */ // taking this OUT for upgrade from 1.4 to 1.5 (those tracking head will have already seen it)
b61efafb 893 }
894
5f37b628 895 if ($oldversion < 2005012501) { //fix table names for consistency
896 execute_sql("DROP TABLE {$CFG->prefix}meta_course",false); // drop silently
897 execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN meta_course",false); // drop silently
898
899 modify_database("","CREATE TABLE prefix_course_meta (
900 id SERIAL primary key,
901 parent_course integer NOT NULL,
902 child_course integer NOT NULL
903 );");
904
905 modify_database("","CREATE INDEX prefix_course_meta_parent_idx ON prefix_course_meta (parent_course);");
906 modify_database("","CREATE INDEX prefix_course_meta_child_idx ON prefix_course_meta (child_course);");
907 table_column('course','','metacourse','integer','1','','0','not null');
908 }
909
4c3911f9 910 if ($oldversion < 2005020100) {
911 fix_course_sortorder(0, 1, 1);
912 }
913
915602ea 914 if ($oldversion < 2005021000) { // New fields for theme choices
915 table_column('course', '', 'theme', 'varchar', '50', '', '', '', 'lang');
916 table_column('groups', '', 'theme', 'varchar', '50', '', '', '', 'lang');
917 table_column('user', '', 'theme', 'varchar', '50', '', '', '', 'lang');
918 }
919
41b7678d 920 if ($oldversion < 2005021700) {
921 table_column('user', '', 'dstpreset', 'int', '10', '', '0', 'not null', 'timezone');
922 }
923
ceff9307 924 if ($oldversion < 2005021800) {
925 modify_database("","CREATE TABLE adodb_logsql (
926 created timestamp NOT NULL,
927 sql0 varchar(250) NOT NULL,
928 sql1 text NOT NULL,
929 params text NOT NULL,
930 tracer text NOT NULL,
931 timer decimal(16,6) NOT NULL
932 );");
933 }
934
13222d99 935 if ($oldversion < 2005022400) {
936 table_column('dst_preset', '', 'family', 'varchar', '100', '', '', 'not null', 'name');
937 table_column('dst_preset', '', 'year', 'int', '10', '', '0', 'not null', 'family');
938 }
939
766d2bf3 940 if ($oldversion < 2005030501) {
941 table_column('user', '', 'msn', 'varchar', '50', '', '', '', 'icq');
942 table_column('user', '', 'aim', 'varchar', '50', '', '', '', 'icq');
943 table_column('user', '', 'yahoo', 'varchar', '50', '', '', '', 'icq');
944 table_column('user', '', 'skype', 'varchar', '50', '', '', '', 'icq');
945 }
946
1789c548 947 if ($oldversion < 2005032300) {
948 table_column('user', 'dstpreset', 'timezonename', 'varchar', '100');
949 execute_sql('UPDATE `'.$CFG->prefix.'user` SET timezonename = \'\'');
950 }
951
4eb25d43 952
66336c5f 953 if ($oldversion < 2005032600) {
954 execute_sql('DROP TABLE '.$CFG->prefix.'dst_preset', false);
955 modify_database('',"CREATE TABLE prefix_timezone (
956 id SERIAL PRIMARY KEY,
957 name varchar(100) NOT NULL default '',
958 year integer NOT NULL default '0',
959 rule varchar(20) NOT NULL default '',
960 gmtoff integer NOT NULL default '0',
961 dstoff integer NOT NULL default '0',
962 dst_month integer NOT NULL default '0',
963 dst_startday integer NOT NULL default '0',
964 dst_weekday integer NOT NULL default '0',
965 dst_skipweeks integer NOT NULL default '0',
966 dst_time varchar(5) NOT NULL default '00:00',
967 std_month integer NOT NULL default '0',
968 std_startday integer NOT NULL default '0',
969 std_weekday integer NOT NULL default '0',
970 std_skipweeks integer NOT NULL default '0',
971 std_time varchar(5) NOT NULL default '00:00'
972 );");
973 }
974
4eb25d43 975 if ($oldversion < 2005032800) {
976 /// Need GRADE TABLES HERE!
977 }
978
17f3e7d0 979 return $result;
e40488f8 980}
f374fb10 981
95d45757 982?>