]> git.mjollnir.org Git - moodle.git/commitdiff
Brand-new news and social forums are now also assigned course modules and
authormoodler <moodler>
Fri, 25 Oct 2002 09:10:40 +0000 (09:10 +0000)
committermoodler <moodler>
Fri, 25 Oct 2002 09:10:40 +0000 (09:10 +0000)
put in section 0 of the course.

mod/forum/lib.php

index bf9f8242666264c53c74babdb0786bdc42ee6d1a..1d311ca6ddfea7c06392aea85d31956f1d1e9b76 100644 (file)
@@ -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");
     }
 }