From: vyshane Date: Tue, 22 Aug 2006 05:45:43 +0000 (+0000) Subject: Upgrade now works. Needs more testing. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9fa3350862df2c799e7c8bf1812552841a5836d1;p=moodle.git Upgrade now works. Needs more testing. --- diff --git a/mod/forum/db/mysql.php b/mod/forum/db/mysql.php index 97db13f99b..93661af546 100644 --- a/mod/forum/db/mysql.php +++ b/mod/forum/db/mysql.php @@ -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. } diff --git a/mod/forum/index.php b/mod/forum/index.php index 77d4b2402a..39c12e90e8 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -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 diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 087bb68c3c..dc791f6c18 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -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;