2003-09-16 18:51:40 +00:00
|
|
|
<?PHP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function glossary_upgrade($oldversion) {
|
|
|
|
/// This function does anything necessary to upgrade
|
|
|
|
/// older versions to match current functionality
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
if ($oldversion < 2003091000) {
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}glossary` ".
|
|
|
|
" ADD `allowduplicatedentries` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `studentcanpost` , ".
|
|
|
|
" ADD `displayformat` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `allowduplicatedentries` , ".
|
|
|
|
" ADD `mainglossary` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `displayformat` ");
|
|
|
|
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
|
|
|
|
" ADD timecreated INT(10) UNSIGNED NOT NULL default '0' AFTER `format` , ".
|
|
|
|
" ADD timemodified INT(10) UNSIGNED NOT NULL default '0' AFTER `timecreated` , ".
|
|
|
|
" ADD teacherentry TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `timemodified` ");
|
|
|
|
|
|
|
|
execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete', 'glossary', 'name') ");
|
|
|
|
execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'delete entry', 'glossary', 'name') ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $oldversion < 2003091500 ) {
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}glossary_entries` ".
|
|
|
|
" ADD attachment VARCHAR(100) NOT NULL default '' AFTER `format`");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $oldversion < 2003091600 ) {
|
|
|
|
execute_sql(" ALTER TABLE `{$CFG->prefix}glossary` ".
|
|
|
|
" ADD `showspecial` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `mainglossary` , ".
|
|
|
|
" ADD `showalphabet` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showspecial` , ".
|
|
|
|
" ADD `showall` TINYINT(2) UNSIGNED DEFAULT '1' NOT NULL AFTER `showalphabet` ");
|
|
|
|
}
|
|
|
|
|
2003-09-18 23:53:05 +00:00
|
|
|
if ( $oldversion < 2003091800 ) {
|
|
|
|
|
|
|
|
execute_sql("CREATE TABLE `{$CFG->prefix}glossary_categories` (
|
|
|
|
`id` INT(10) unsigned NOT NULL auto_increment,
|
|
|
|
`glossaryid` INT(10) UNSIGNED NOT NULL default '0',
|
|
|
|
`name` VARCHAR(255) NOT NULL default '',
|
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
) TYPE=MyISAM COMMENT='all categories for glossary entries'");
|
|
|
|
|
|
|
|
execute_sql("CREATE TABLE `{$CFG->prefix}glossary_entries_categories` (
|
|
|
|
`categoryid` INT(10) UNSIGNED NOT NULL default '1',
|
|
|
|
`entryid` INT(10) UNSIGNED NOT NULL default '0',
|
|
|
|
PRIMARY KEY (`categoryid`, `entryid`)
|
|
|
|
) TYPE=MyISAM COMMENT='categories of each glossary entry'");
|
|
|
|
|
|
|
|
// creating a default category for every glossary
|
|
|
|
execute_sql("INSERT INTO `{$CFG->prefix}glossary_categories` (`glossaryid`, `name`)
|
|
|
|
SELECT `id`, '" . get_string("main","glossary") . "' FROM `{$CFG->prefix}glossary`");
|
|
|
|
|
2003-09-16 18:51:40 +00:00
|
|
|
|
2003-09-18 23:53:05 +00:00
|
|
|
// setting the default category for every entry.
|
|
|
|
execute_sql("INSERT INTO `{$CFG->prefix}glossary_entries_categories` (`categoryid`, `entryid`)
|
|
|
|
SELECT c.id, e.id
|
|
|
|
FROM `{$CFG->prefix}glossary_entries` e, `{$CFG->prefix}glossary_categories` c
|
|
|
|
WHERE e.glossaryid = c.glossaryid");
|
2003-09-16 18:51:40 +00:00
|
|
|
|
2003-09-18 23:53:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2003-09-16 18:51:40 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|