2002-10-05 17:20:24 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
function journal_upgrade($oldversion) {
|
|
|
|
// This function does anything necessary to upgrade
|
|
|
|
// older versions to match current functionality
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
global $CFG;
|
|
|
|
|
2002-10-05 17:20:24 +00:00
|
|
|
$result = true;
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
if ($oldversion < 2002081000) {
|
|
|
|
if (! execute_sql("ALTER TABLE `journal_entries` ADD `mailed` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL")) {
|
|
|
|
$result = false;
|
|
|
|
}
|
2002-10-12 06:20:56 +00:00
|
|
|
}
|
|
|
|
if ($oldversion < 2002101200) {
|
2003-08-18 05:47:04 +00:00
|
|
|
execute_sql(" ALTER TABLE `journal_entries` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `text` ");
|
2002-10-05 17:20:24 +00:00
|
|
|
}
|
2002-12-23 09:39:26 +00:00
|
|
|
if ($oldversion < 2002122300) {
|
|
|
|
execute_sql("ALTER TABLE `journal_entries` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
|
|
|
|
}
|
|
|
|
|
2003-08-18 05:47:04 +00:00
|
|
|
if ($oldversion < 2003081701) {
|
|
|
|
table_column("journal", "assessed", "assessed", "integer", "10", "", "0");
|
|
|
|
table_column("journal_entries", "rating", "rating", "integer", "10", "", "0");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oldversion < 2003081705) {
|
|
|
|
$defaultscale = NULL;
|
|
|
|
$defaultscale->courseid = 0;
|
|
|
|
$defaultscale->userid = 0;
|
|
|
|
$defaultscale->timemodified = time();
|
|
|
|
$defaultscale->name = get_string("journalrating2", "journal");
|
|
|
|
$defaultscale->scale = get_string("journalrating1", "journal").",".
|
|
|
|
get_string("journalrating2", "journal").",".
|
|
|
|
get_string("journalrating3", "journal");
|
|
|
|
|
|
|
|
if ($defaultscale->id = insert_record("scale", $defaultscale)) {
|
|
|
|
execute_sql("UPDATE {$CFG->prefix}journal SET assessed = '-$defaultscale->id'", false);
|
|
|
|
} else {
|
|
|
|
notify("An error occurred while inserting the default journal scale");
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
}
|
2002-10-05 17:20:24 +00:00
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|