Upgrade now works. Needs more testing.

This commit is contained in:
vyshane
2006-08-22 05:45:43 +00:00
parent 021a7467b5
commit 9fa3350862
3 changed files with 20 additions and 19 deletions
+19 -12
View File
@@ -264,15 +264,17 @@ function forum_upgrade($oldversion) {
$mod->visible = 0;
$mod->visibleold = 0;
$mod->groupmode = 0;
print_object($mod);
if (!$cmid = add_course_module($mod)) {
error('Could not create new course module instance for the teacher forum');
} else {
$mod->coursemodule = $cmid;
if (!add_mod_to_section($mod)) {
error('Could not add new forum instance to section 0 in the course');
if (!$sectionid = add_mod_to_section($mod)) {
error('Could not add converted teacher forum instance to section 0 in the course');
} else {
if (!set_field('course_modules', 'section', $sectionid, 'id', $cmid)) {
error('Could not update course module with section id');
}
}
}
@@ -357,9 +359,6 @@ function forum_upgrade($oldversion) {
}
break;
}
// Drop column forum.open.
modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;');
// $forum->assessed defines whether forum rating is turned
// on (1 or 2) and who can rate posts:
@@ -378,7 +377,6 @@ function forum_upgrade($oldversion) {
break;
}
// $forum->assesspublic defines whether students can see
// everybody's ratings:
// 0 = Students can only see their own ratings
@@ -391,10 +389,19 @@ function forum_upgrade($oldversion) {
assign_capability('mod/forum:viewanyrating', CAP_ALLOW, $studentrole->id, $context->id);
break;
}
// Drop column forum.assesspublic.
modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;');
}
} // End foreach $teacherforums.
} // End foreach $forums.
// Drop column forum.open.
modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;');
// Drop column forum.assesspublic.
modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;');
// We need to rebuild all the course caches to refresh the state of
// the forum modules.
rebuild_course_cache();
} // End if.
}
+1 -1
View File
@@ -78,7 +78,7 @@
$generalforums = array(); // For now
$learningforums = get_all_instances_in_course("forum", $course);
if ($forums = get_records("forum", "course", $id, "name ASC")) { // All known forums
if ($learningforums) { // Copy "full" data into this complete array
-6
View File
@@ -1595,12 +1595,6 @@ function forum_get_course_forum($courseid, $type) {
$forum->assessed = 0;
$forum->forcesubscribe = 0;
break;
case "teacher":
$forum->name = addslashes(get_string("nameteacher", "forum"));
$forum->intro = addslashes(get_string("introteacher", "forum"));
$forum->assessed = 0;
$forum->forcesubscribe = 0;
break;
default:
notify("That forum type doesn't exist!");
return false;