From e6874d9ff6cbb713cc26baee2a2c153d0cdf1feb Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 25 Oct 2002 09:10:40 +0000 Subject: [PATCH] Brand-new news and social forums are now also assigned course modules and put in section 0 of the course. --- mod/forum/lib.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index bf9f824266..1d311ca6dd 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -444,7 +444,31 @@ function forum_get_course_forum($courseid, $type) { } $forum->timemodified = time(); $forum->id = insert_record("forum", $forum); - return get_record_sql("SELECT * from forum WHERE id = '$forum->id'"); + + if ($forum->type != "teacher") { + if (! $module = get_record("modules", "name", "forum")) { + notify("Could not find forum module!!"); + return false; + } + $mod->course = $courseid; + $mod->module = $module->id; + $mod->instance = $forum->id; + $mod->section = 0; + if (! $mod->coursemodule = add_course_module($mod) ) { // assumes course/lib.php is loaded + notify("Could not add a new course module to the course '$course->fullname'"); + return false; + } + if (! $sectionid = add_mod_to_section($mod) ) { // assumes course/lib.php is loaded + notify("Could not add the new course module to that section"); + return false; + } + if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) { + notify("Could not update the course module with the correct section"); + return false; + } + } + + return get_record("forum", "id", "$forum->id"); } } -- 2.39.5