]> git.mjollnir.org Git - moodle.git/commitdiff
A big clean up of all the forum functions (including renaming them all
authormartin <martin>
Thu, 1 Aug 2002 03:50:27 +0000 (03:50 +0000)
committermartin <martin>
Thu, 1 Aug 2002 03:50:27 +0000 (03:50 +0000)
to start with forum_ ) and all the follow-on effects that caused
Some miscellaneous bug fixes and code clean-ups along the way

13 files changed:
course/lib.php
course/mod.php
course/social.php
course/topics.php
course/weeks.php
index.php
mod/forum/discuss.php
mod/forum/lib.php
mod/forum/post.php
mod/forum/search.php
mod/forum/subscribe.php
mod/forum/view.php
user/view.php

index bff3e98da156144ca1aac2fbfc437226383fd4ad..97e160fc2de7782486793fbabe5f97cd91e41be9 100644 (file)
@@ -425,4 +425,222 @@ function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
     echo "<IMG BORDER=0 SRC=\"$CFG->wwwroot/course/loggraph.php?id=$course->id&user=$userid&type=$type&date=$date\">";
 }
 
+
+
+/// MODULE FUNCTIONS /////////////////////////////////////////////////////////////////
+
+function add_course_module($mod) {
+    GLOBAL $db;
+
+    $timenow = time();
+
+    if (!$rs = $db->Execute("INSERT into course_modules 
+                                SET course   = '$mod->course', 
+                                    module   = '$mod->module',
+                                    instance = '$mod->instance',
+                                    section     = '$mod->section',
+                                    added    = '$timenow' ")) {
+        return 0;
+    }
+    
+    // Get it out again - this is the most compatible way to determine the ID
+    if ($rs = $db->Execute("SELECT id FROM course_modules 
+                            WHERE module = $mod->module AND added = $timenow")) {
+        return $rs->fields[0];
+    } else {
+        return 0;
+    }
+
+}
+
+function add_mod_to_section($mod) {
+// Returns the course_sections ID where the mod is inserted
+    GLOBAL $db;
+
+    if ($cw = get_record_sql("SELECT * FROM course_sections 
+                              WHERE course = '$mod->course' AND section = '$mod->section'") ) {
+
+        if ($cw->sequence) {
+            $newsequence = "$cw->sequence,$mod->coursemodule";
+        } else {
+            $newsequence = "$mod->coursemodule";
+        }
+        if (!$rs = $db->Execute("UPDATE course_sections SET sequence = '$newsequence' WHERE id = '$cw->id'")) {
+            return 0;
+        } else {
+            return $cw->id;     // Return course_sections ID that was used.
+        }
+       
+    } else {  // Insert a new record
+        if (!$rs = $db->Execute("INSERT into course_sections 
+                                 SET course   = '$mod->course', 
+                                     section     = '$mod->section',
+                                     summary  = '',
+                                     sequence = '$mod->coursemodule' ")) {
+            return 0;
+        }
+        // Get it out again - this is the most compatible way to determine the ID
+        if ($rs = $db->Execute("SELECT id FROM course_sections 
+                                WHERE course = '$mod->course' AND section = '$mod->section'")) {
+            return $rs->fields[0];
+        } else {
+            return 0;
+        }
+    }
+}
+
+function delete_course_module($mod) {
+    return set_field("course_modules", "deleted", 1, "id", $mod);
+}
+
+function delete_mod_from_section($mod, $section) {
+    GLOBAL $db;
+
+    if ($cw = get_record("course_sections", "id", "$section") ) {
+
+        $modarray = explode(",", $cw->sequence);
+
+        if ($key = array_keys ($modarray, $mod)) {
+            array_splice($modarray, $key[0], 1);
+            $newsequence = implode(",", $modarray);
+            return set_field("course_sections", "sequence", $newsequence, "id", $cw->id);
+        } else {
+            return false;
+        }
+       
+    } else {  
+        return false;
+    }
+}
+
+
+function move_module($id, $move) {
+    GLOBAL $db;
+
+    if (!$move) {
+        return true;
+    }
+
+    if (! $cm = get_record("course_modules", "id", $id)) {
+        error("This course module doesn't exist");
+    }
+    
+    if (! $thissection = get_record("course_sections", "id", $cm->section)) {
+        error("This course section doesn't exist");
+    }
+
+    $mods = explode(",", $thissection->sequence);
+
+    $len = count($mods);
+    $pos = array_keys($mods, $cm->id);
+    $thepos = $pos[0];
+
+    if ($len == 0 || count($pos) == 0 ) {
+        error("Very strange. Could not find the required module in this section.");
+    }
+
+    if ($len == 1) {
+        $first = true;
+        $last = true;
+    } else {
+        $first = ($thepos == 0);
+        $last  = ($thepos == $len - 1);
+    }
+
+    if ($move < 0) {    // Moving the module up
+
+        if ($first) {
+            if ($thissection->section == 1) {  // First section, do nothing
+                return true;
+            } else {               // Push onto end of previous section
+                $prevsectionnumber = $thissection->section - 1;
+                if (! $prevsection = get_record_sql("SELECT * FROM course_sections 
+                                                  WHERE course='$thissection->course'
+                                                  AND section='$prevsectionnumber' ")) {
+                    error("Previous section ($prevsection->id) doesn't exist");
+                }
+
+                if ($prevsection->sequence) {
+                    $newsequence = "$prevsection->sequence,$cm->id";
+                } else {
+                    $newsequence = "$cm->id";
+                }
+
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $prevsection->id)) {
+                    error("Previous section could not be updated");
+                }
+
+                if (! set_field("course_modules", "section", $prevsection->id, "id", $cm->id)) {
+                    error("Module could not be updated");
+                }
+
+                array_splice($mods, 0, 1);
+                $newsequence = implode(",", $mods);
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                    error("Module could not be updated");
+                }
+
+                return true;
+
+            }
+        } else {        // move up within this section
+            $swap = $mods[$thepos-1];
+            $mods[$thepos-1] = $mods[$thepos];
+            $mods[$thepos] = $swap;
+            
+            $newsequence = implode(",", $mods);
+            if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                error("This section could not be updated");
+            }
+            return true;
+        }
+
+    } else {            // Moving the module down
+
+        if ($last) {
+            $nextsectionnumber = $thissection->section + 1;
+            if ($nextsection = get_record_sql("SELECT * FROM course_sections 
+                                            WHERE course='$thissection->course'
+                                            AND section='$nextsectionnumber' ")) {
+
+                if ($nextsection->sequence) {
+                    $newsequence = "$cm->id,$nextsection->sequence";
+                } else {
+                    $newsequence = "$cm->id";
+                }
+
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $nextsection->id)) {
+                    error("Next section could not be updated");
+                }
+
+                if (! set_field("course_modules", "section", $nextsection->id, "id", $cm->id)) {
+                    error("Module could not be updated");
+                }
+
+                array_splice($mods, $thepos, 1);
+                $newsequence = implode(",", $mods);
+                if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                    error("This section could not be updated");
+                }
+                return true;
+
+            } else {        // There is no next section, so just return
+                return true;
+
+            }
+        } else {      // move down within this section
+            $swap = $mods[$thepos+1];
+            $mods[$thepos+1] = $mods[$thepos];
+            $mods[$thepos] = $swap;
+            
+            $newsequence = implode(",", $mods);
+            if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
+                error("This section could not be updated");
+            }
+            return true;
+        }
+    }
+}
+
+
 ?>
index c8db9c45d4eab22488a4e344c4218d33f5cff6fc..d392d1f4c8ae88c57ede93c483a757145ee4c149 100644 (file)
 
     print_footer($course);
 
-    exit;
-
-
-/// FUNCTIONS //////////////////////////////////////////////////////////////////////
-
-function add_course_module($mod) {
-    GLOBAL $db;
-
-    $timenow = time();
-
-    if (!$rs = $db->Execute("INSERT into course_modules 
-                                SET course   = '$mod->course', 
-                                    module   = '$mod->module',
-                                    instance = '$mod->instance',
-                                    section     = '$mod->section',
-                                    added    = '$timenow' ")) {
-        return 0;
-    }
-    
-    // Get it out again - this is the most compatible way to determine the ID
-    if ($rs = $db->Execute("SELECT id FROM course_modules 
-                            WHERE module = $mod->module AND added = $timenow")) {
-        return $rs->fields[0];
-    } else {
-        return 0;
-    }
-
-}
-
-function add_mod_to_section($mod) {
-// Returns the course_sections ID where the mod is inserted
-    GLOBAL $db;
-
-    if ($cw = get_record_sql("SELECT * FROM course_sections 
-                              WHERE course = '$mod->course' AND section = '$mod->section'") ) {
-
-        if ($cw->sequence) {
-            $newsequence = "$cw->sequence,$mod->coursemodule";
-        } else {
-            $newsequence = "$mod->coursemodule";
-        }
-        if (!$rs = $db->Execute("UPDATE course_sections SET sequence = '$newsequence' WHERE id = '$cw->id'")) {
-            return 0;
-        } else {
-            return $cw->id;     // Return course_sections ID that was used.
-        }
-       
-    } else {  // Insert a new record
-        if (!$rs = $db->Execute("INSERT into course_sections 
-                                 SET course   = '$mod->course', 
-                                     section     = '$mod->section',
-                                     summary  = '',
-                                     sequence = '$mod->coursemodule' ")) {
-            return 0;
-        }
-        // Get it out again - this is the most compatible way to determine the ID
-        if ($rs = $db->Execute("SELECT id FROM course_sections 
-                                WHERE course = '$mod->course' AND section = '$mod->section'")) {
-            return $rs->fields[0];
-        } else {
-            return 0;
-        }
-    }
-}
-
-function delete_course_module($mod) {
-    return set_field("course_modules", "deleted", 1, "id", $mod);
-}
-
-function delete_mod_from_section($mod, $section) {
-    GLOBAL $db;
-
-    if ($cw = get_record("course_sections", "id", "$section") ) {
-
-        $modarray = explode(",", $cw->sequence);
-
-        if ($key = array_keys ($modarray, $mod)) {
-            array_splice($modarray, $key[0], 1);
-            $newsequence = implode(",", $modarray);
-            return set_field("course_sections", "sequence", $newsequence, "id", $cw->id);
-        } else {
-            return false;
-        }
-       
-    } else {  
-        return false;
-    }
-}
-
-
-function move_module($id, $move) {
-    GLOBAL $db;
-
-    if (!$move) {
-        return true;
-    }
-
-    if (! $cm = get_record("course_modules", "id", $id)) {
-        error("This course module doesn't exist");
-    }
-    
-    if (! $thissection = get_record("course_sections", "id", $cm->section)) {
-        error("This course section doesn't exist");
-    }
-
-    $mods = explode(",", $thissection->sequence);
-
-    $len = count($mods);
-    $pos = array_keys($mods, $cm->id);
-    $thepos = $pos[0];
-
-    if ($len == 0 || count($pos) == 0 ) {
-        error("Very strange. Could not find the required module in this section.");
-    }
-
-    if ($len == 1) {
-        $first = true;
-        $last = true;
-    } else {
-        $first = ($thepos == 0);
-        $last  = ($thepos == $len - 1);
-    }
-
-    if ($move < 0) {    // Moving the module up
-
-        if ($first) {
-            if ($thissection->section == 1) {  // First section, do nothing
-                return true;
-            } else {               // Push onto end of previous section
-                $prevsectionnumber = $thissection->section - 1;
-                if (! $prevsection = get_record_sql("SELECT * FROM course_sections 
-                                                  WHERE course='$thissection->course'
-                                                  AND section='$prevsectionnumber' ")) {
-                    error("Previous section ($prevsection->id) doesn't exist");
-                }
-
-                if ($prevsection->sequence) {
-                    $newsequence = "$prevsection->sequence,$cm->id";
-                } else {
-                    $newsequence = "$cm->id";
-                }
-
-                if (! set_field("course_sections", "sequence", $newsequence, "id", $prevsection->id)) {
-                    error("Previous section could not be updated");
-                }
-
-                if (! set_field("course_modules", "section", $prevsection->id, "id", $cm->id)) {
-                    error("Module could not be updated");
-                }
-
-                array_splice($mods, 0, 1);
-                $newsequence = implode(",", $mods);
-                if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
-                    error("Module could not be updated");
-                }
-
-                return true;
-
-            }
-        } else {        // move up within this section
-            $swap = $mods[$thepos-1];
-            $mods[$thepos-1] = $mods[$thepos];
-            $mods[$thepos] = $swap;
-            
-            $newsequence = implode(",", $mods);
-            if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
-                error("This section could not be updated");
-            }
-            return true;
-        }
-
-    } else {            // Moving the module down
-
-        if ($last) {
-            $nextsectionnumber = $thissection->section + 1;
-            if ($nextsection = get_record_sql("SELECT * FROM course_sections 
-                                            WHERE course='$thissection->course'
-                                            AND section='$nextsectionnumber' ")) {
-
-                if ($nextsection->sequence) {
-                    $newsequence = "$cm->id,$nextsection->sequence";
-                } else {
-                    $newsequence = "$cm->id";
-                }
-
-                if (! set_field("course_sections", "sequence", $newsequence, "id", $nextsection->id)) {
-                    error("Next section could not be updated");
-                }
-
-                if (! set_field("course_modules", "section", $nextsection->id, "id", $cm->id)) {
-                    error("Module could not be updated");
-                }
-
-                array_splice($mods, $thepos, 1);
-                $newsequence = implode(",", $mods);
-                if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
-                    error("This section could not be updated");
-                }
-                return true;
-
-            } else {        // There is no next section, so just return
-                return true;
-
-            }
-        } else {      // move down within this section
-            $swap = $mods[$thepos+1];
-            $mods[$thepos+1] = $mods[$thepos];
-            $mods[$thepos] = $swap;
-            
-            $newsequence = implode(",", $mods);
-            if (! set_field("course_sections", "sequence", $newsequence, "id", $thissection->id)) {
-                error("This section could not be updated");
-            }
-            return true;
-        }
-    }
-}
-
 ?>
-
-
index e6b70c2359fa771b5db495869bff424002a1074f..95f23f2142c924664009d38e6d294449f361dc35 100644 (file)
@@ -10,8 +10,8 @@
   <TR>
     <TD WIDTH="15%" VALIGN="TOP">
       <? 
-      //if ($news = get_course_news_forum($course->id)) {
-          //print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
+      //if ($news = forum_get_course_forum($course->id, "news")) {
+          //forum_print_latest_discussions($news->id, 5, "minimal", "DESC", false);
       //}
 
       //echo "<BR><BR>";
 
           print_side_block("", $admindata, "", $adminicon);
       }
-      ?>
 
-    </TD>
+      echo "</TD>";
 
-    <TD WIDTH="55%" VALIGN="TOP">
-      <? 
-      if (!$social = get_course_social_forum($course->id)) {
-          error("Could not find or create a social forum here");
-      }
+      echo "<TD WIDTH=\"55%\" VALIGN=\"TOP\">";
+      if ($social = forum_get_course_forum($course->id, "social")) {
+          if (forum_is_subscribed($USER->id, $social->id)) {
+              $subtext = "Unsubscribe";
+          } else {
+              $subtext = "Subscribe me by mail";
+          }
+          $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR><TD>Social Forum - Current Topics<TD ALIGN=RIGHT><FONT SIZE=1><A HREF=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</A></TD></TR></TABLE>";
+          print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
+          echo "<IMG ALT=\"\" HEIGHT=7 SRC=\"../pix/spacer.gif\"><BR>";
+    
+          forum_print_latest_discussions($social->id, 10, "plain", "DESC", false);
+          $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
 
-      $SESSION->fromdiscussion = "$CFG->wwwdir/course/view.php?id=$course->id";
-      if (forum_is_subscribed($USER->id, $social->id)) {
-          $subtext = "Unsubscribe";
       } else {
-          $subtext = "Subscribe me by mail";
+          notify("Could not find or create a social forum here");
       }
-      $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR><TD>Social Forum - Current Topics<TD ALIGN=RIGHT><FONT SIZE=1><A HREF=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</A></TD></TR></TABLE>";
-         print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
-      <IMG ALT="" HEIGHT=7 SRC="../pix/spacer.gif"><BR>
-
-      <? 
-          if ($social = get_course_social_forum($course->id)) {
-              print_forum_latest_topics($social->id, 10, "plain", "DESC", false);
-          } else {
-              error("Could not find or create a social forum here");
-          }
       ?>
-    
-    </TD>
-  </TR>
+    </TD> 
+  </TR> 
 </TABLE>
 
index e271a6493ce894611051ce60013159e414435635..e91c724950549a5acdb2a0393dcde977247c39ad 100644 (file)
@@ -85,7 +85,7 @@
         } else {
             $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
         }
-        if ($teacherforum = get_course_teacher_forum($course->id)) {
+        if ($teacherforum = forum_get_course_forum($course->id, "teacher")) {
             $admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
             $adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
         }
 
     // Print all the news items.
 
-    if ($news = get_course_news_forum($course->id)) {
+    if ($news = forum_get_course_forum($course->id, "news")) {
         print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
         print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
         echo "<FONT SIZE=1>";
-        print_forum_latest_topics($news->id, $course->newsitems, "minimal", "DESC", false);
+        forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
         echo "</FONT>";
         print_simple_box_end();
     }
index 2692c03c0522c62a4b612c6bf44cf93b82fa7518..bbf93a68dd9c8443e0d4523c4f765d6f8bde0bca 100644 (file)
@@ -68,7 +68,7 @@
             $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
         }
 
-        if ($teacherforum = get_course_teacher_forum($course->id)) {
+        if ($teacherforum = forum_get_course_forum($course->id, "teacher")) {
             $admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
             $adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
         }
 
     // Print all the news items.
 
-    if ($news = get_course_news_forum($course->id)) {
+    if ($news = forum_get_course_forum($course->id, "news")) {
         print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
         print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
         echo "<FONT SIZE=1>";
-        print_forum_latest_topics($news->id, $course->newsitems, "minimal", "DESC", false);
+        forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "DESC", false);
         echo "</FONT>";
         print_simple_box_end();
     }
index abf8edf32fbc02dba9cf8cf1e6aa7159d179fc2b..354acd4deaf514fc635e14a1d4d4ef64355d7c22 100644 (file)
--- a/index.php
+++ b/index.php
@@ -71,8 +71,8 @@
              print_all_courses();
 
          } else {
-             if (! $newsforum = get_course_news_forum($site->id)) {
-                 error("Could not find or create a main forum for the site");
+             if (! $newsforum = forum_get_course_forum($site->id, "news")) {
+                 error("Could not find or create a main news forum for the site");
              }
 
              if (isset($USER->id)) {
@@ -92,7 +92,7 @@
              }
              print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
-             print_forum_latest_topics($newsforum->id, $site->newsitems);
+             forum_print_latest_discussions($newsforum->id, $site->newsitems);
          }
       ?>
 
index 753811ca483a277cb762d90cad928369e74aaaec..85e13d00a882eef3ecf38bc20640c719eed88b3a 100644 (file)
@@ -41,7 +41,7 @@
         $navtail = "$discussion->name";
     }
 
-    if (! $post = get_forum_post_full($parent)) {
+    if (! $post = forum_get_post_full($parent)) {
         error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
     }
 
@@ -66,7 +66,7 @@
                  "$navmiddle -> $navtail", "", "", true, $updatebutton);
     }
 
-    print_discussion($course, $discussion, $post, $USER->mode);
+    forum_print_discussion($course, $discussion, $post, $USER->mode);
 
     print_footer($course);
 
index c3f0c4ee50ccc3a7dcc87026fe5b7cb27999ea37..3027b9f03360ae60ece040e047f893b3546b308b 100644 (file)
@@ -9,8 +9,9 @@ $FORUM_DISCUSS_MODES = array ( "1"  => "Display replies flat, with oldest first"
                                "2"  => "Display replies in threaded form",
                                "3"  => "Display replies in nested form");
 
+// These are course content forums that can be added to the course manually
 $FORUM_TYPE   = array ("general"    => "General forum",
-                       "eachuser"   => "Each $student posts a topic",
+                       "eachuser"   => "Each $student posts one discussion",
                        "single"     => "A single simple discussion");
 
 $FORUM_POST_RATINGS = array ("3" => "Outstanding", 
@@ -22,58 +23,43 @@ $FORUM_LONG_POST = 600;
 
 /// FUNCTIONS ///////////////////////////////////////////////////////////
 
-// How to set up special 1-per-course forums
 
-function get_course_news_forum($courseid) {
-    if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = 'news'")) {
-        return $forum;
-    } else {
-        // Doesn't exist, so create one now.
-        $forum->course = $courseid;
-        $forum->type = "news";
-        $forum->name = "News";
-        $forum->intro= "General news about this course";
-        $forum->open = 0;
-        $forum->assessed = 0;
-        $forum->forcesubscribe = 1;
-        $forum->timemodified = time();
-        $forum->id = insert_record("forum", $forum);
-        return get_record_sql("SELECT * from forum WHERE id = '$forum->id'");
-    }
-}
-
-
-function get_course_social_forum($courseid) {
-    if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = 'social'")) {
+function forum_get_course_forum($courseid, $type) {
+// How to set up special 1-per-course forums
+    if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = '$type'")) {
         return $forum;
     } else {
         // Doesn't exist, so create one now.
         $forum->course = $courseid;
-        $forum->type = "social";
-        $forum->name = "Social";
-        $forum->intro= "A forum for general socialising. Talk about anything you like!";
-        $forum->open = 1;
-        $forum->assessed = 0;
-        $forum->forcesubscribe = 0;
-        $forum->timemodified = time();
-        $forum->id = insert_record("forum", $forum);
-        return get_record_sql("SELECT * from forum WHERE id = '$forum->id'");
-    }
-}
-
+        $forum->type = "$type";
+        switch ($forum->type) {
+            case "news":
+                $forum->name = "News";
+                $forum->intro= "General news about this course";
+                $forum->open = 0;
+                $forum->assessed = 0;
+                $forum->forcesubscribe = 1;
+                break;
+            case "social":
+                $forum->name = "Social";
+                $forum->intro= "A forum for general socialising. Talk about anything you like!";
+                $forum->open = 1;
+                $forum->assessed = 0;
+                $forum->forcesubscribe = 0;
+                break;
+            case "teacher":
+                $forum->name = "Teacher Forum";
+                $forum->intro= "For teacher-only notes and discussion";
+                $forum->open = 0;
+                $forum->assessed = 0;
+                $forum->forcesubscribe = 0;
+                break;
+            default:
+                notify("That forum type doesn't exist!");
+                return false;
+                break;
 
-function get_course_teacher_forum($courseid) {
-    if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = 'teacher'")) {
-        return $forum;
-    } else {
-        // Doesn't exist, so create one now.
-        $forum->course = $courseid;
-        $forum->type = "teacher";
-        $forum->name = "Teacher Forum";
-        $forum->intro= "For teacher-only notes and discussion";
-        $forum->open = 0;
-        $forum->assessed = 0;
-        $forum->forcesubscribe = 0;
+        }
         $forum->timemodified = time();
         $forum->id = insert_record("forum", $forum);
         return get_record_sql("SELECT * from forum WHERE id = '$forum->id'");
@@ -81,7 +67,8 @@ function get_course_teacher_forum($courseid) {
 }
 
 
-function make_mail_post(&$post, $user, $touser, $course, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") {
+function forum_make_mail_post(&$post, $user, $touser, $course, 
+                              $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") {
 // Given the data about a posting, builds up the HTML to display it and 
 // returns the HTML in a string.  This is designed for sending via HTML email.
 
@@ -153,7 +140,7 @@ function make_mail_post(&$post, $user, $touser, $course, $ownpost=false, $reply=
 }
 
 
-function print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") {
+function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") {
     global $THEME, $USER, $CFG, $FORUM_LONG_POST;
 
     if ($post->parent) {
@@ -215,9 +202,9 @@ function print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false
     echo "<DIV ALIGN=right><P ALIGN=right>";
     if ($rate && $USER->id) {
         if ($USER->id == $post->userid) {
-            print_ratings($post->id);
+            print_forum_ratings($post->id);
         } else {
-            print_rating($post->id, $USER->id);
+            print_forum_rating($post->id, $USER->id);
         }
     }
     
@@ -255,7 +242,7 @@ function forum_shorten_post($message) {
 }
 
 
-function print_ratings($post) {
+function print_forum_ratings($post) {
 
     global $CFG, $PHPSESSID;
 
@@ -280,7 +267,7 @@ function print_ratings($post) {
     }
 }
 
-function print_rating($post, $user) {
+function print_forum_rating($post, $user) {
     global $FORUM_POST_RATINGS;
 
     if ($rs = get_record_sql("SELECT rating from forum_ratings WHERE user='$user' AND post='$post'")) {
@@ -297,7 +284,7 @@ function print_rating($post, $user) {
     }
 }
 
-function print_mode_form($discussion, $mode) {
+function print_forum_mode_form($discussion, $mode) {
     GLOBAL $FORUM_DISCUSS_MODES;
 
     echo "<CENTER><P>";
@@ -318,7 +305,7 @@ function print_forum_search_form($course, $search="") {
 }
 
 
-function count_discussion_replies($forum="0") {
+function forum_count_discussion_replies($forum="0") {
     if ($forum) {
         $forumselect = " AND d.forum = '$forum'";
     }
@@ -329,7 +316,7 @@ function count_discussion_replies($forum="0") {
 }
 
 
-function set_fromdiscussion() {
+function forum_set_return() {
     global $SESSION, $HTTP_REFERER;
 
     if (! $SESSION->fromdiscussion) {
@@ -338,7 +325,7 @@ function set_fromdiscussion() {
 }
 
 
-function go_back_to($default) {
+function forum_go_back_to($default) {
     global $SESSION;
 
     if ($SESSION->fromdiscussion) {
@@ -350,7 +337,7 @@ function go_back_to($default) {
     }
 }
 
-function get_forum_post_full($postid) {
+function forum_get_post_full($postid) {
     return get_record_sql("SELECT p.*, u.firstname, u.lastname, 
                                   u.email, u.picture, u.id as userid
                            FROM forum_posts p, user u 
@@ -358,7 +345,7 @@ function get_forum_post_full($postid) {
 }
 
 
-function add_new_post_to_database($post) {
+function forum_add_new_post($post) {
 
     $timenow = time();
     $post->created = $timenow;
@@ -368,7 +355,7 @@ function add_new_post_to_database($post) {
     return insert_record("forum_posts", $post);
 }
 
-function update_post_in_database($post) {
+function forum_update_post($post) {
     global $db;
 
     $timenow = time();
@@ -447,28 +434,27 @@ function forum_delete_discussion($discussion) {
 
 
 
-function print_user_discussions($course, $user) {
-    global $CFG;
+function forum_print_user_discussions($courseid, $userid) {
+    global $USER;
 
-    $topics = get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
-                            FROM forum_discussions d, forum_posts p, user u, forum f
-                            WHERE d.course = '$course->id' AND p.discussion = d.id AND 
-                                  p.parent = 0 AND p.user = u.id AND u.id = '$user->id'
-                                  AND d.forum = f.id AND f.type = 'eachuser'
-                            ORDER BY p.created DESC");
+    $discussions = get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
+                                    FROM forum_discussions d, forum_posts p, user u
+                                    WHERE d.course = '$courseid' AND p.discussion = d.id AND 
+                                          p.parent = 0 AND p.user = u.id AND u.id = '$userid'
+                                    ORDER BY p.created DESC");
     
-    if ($topics) {
+    if ($discussions) {
         echo "<HR>";
         print_heading("Discussion topics");
-        $replies = count_discussion_replies();
-        foreach ($topics as $topic) {
-            if ($replies[$topic->discussion]) {
-                $topic->replies = $replies[$topic->discussion]->replies;
+        $replies = forum_count_discussion_replies();
+        foreach ($discussions as $discussion) {
+            if ($replies[$discussion->discussion]) {
+                $discussion->replies = $replies[$discussion->discussion]->replies;
             } else {
-                $topic->replies = 0;
+                $discussion->replies = 0;
             }
-            $ownpost = ($topic->userid == $USER->id);
-            print_post($topic, $course->id, $ownpost, $reply=0, $link=1, $assessed=false);
+            $ownpost = ($discussion->userid == $USER->id);
+            forum_print_post($discussion, $course->id, $ownpost, $reply=0, $link=1, $assessed=false);
             echo "<BR>\n";
         }
     }
@@ -515,7 +501,7 @@ function forum_user_complete($course, $user, $mod, $forum) {
                 $footer = "";
             }
 
-            print_post($post, $course->id, $ownpost=false, $reply=false, $link=false, $rate=false, $footer);
+            pirint_post($post, $course->id, $ownpost=false, $reply=false, $link=false, $rate=false, $footer);
         }
 
     } else {
@@ -587,7 +573,7 @@ function forum_cron () {
                       "<A HREF=\"$CFG->wwwroot/mod/forum/index.php?id=$course->id\">Forums</A> ->".
                       "<A HREF=\"$CFG->wwwroot/mod/forum/view.php?f=$forum->id\">$forum->name</A> ->".
                       "<A HREF=\"$CFG->wwwroot/mod/forum/discuss.php?d=$discussion->id\">$discussion->name</A></FONT></P>";
-                      $posthtml .= make_mail_post($post, $userfrom, $userto, $course, false, true, false, false);
+                      $posthtml .= forum_make_mail_post($post, $userfrom, $userto, $course, false, true, false, false);
                     } else {
                       $posthtml = "";
                     }
@@ -636,20 +622,20 @@ function forum_unsubscribe($userid, $forumid) {
 }
 
 
-function user_has_posted_discussion($forumid, $userid) {
-    if ($topics = get_all_topics($forumid, "DESC", $userid)) {
+function forum_user_has_posted_discussion($forumid, $userid) {
+    if ($discussions = forum_get_discussions($forumid, "DESC", $userid)) {
         return true;
     } else {
         return false;
     }
 }
 
-function user_can_post_discussion($forum) {
+function forum_user_can_post_discussion($forum) {
 // $forum is an object
     global $USER;
 
     if ($forum->type == "eachuser") {
-        return (! user_has_posted_discussion($forum->id, $USER->id));
+        return (! forum_user_has_posted_discussion($forum->id, $USER->id));
     } else if ($forum->type == "teacher") {
         return isteacher($forum->course);
     } else if (isteacher($forum->course)) {
@@ -660,7 +646,7 @@ function user_can_post_discussion($forum) {
 }
 
 
-function get_all_topics($forum="0", $forum_sort="DESC", $user=0) {
+function forum_get_discussions($forum="0", $forum_sort="DESC", $user=0) {
     if ($user) {
         $userselect = " AND u.id = '$user' ";
     } else {
@@ -675,7 +661,7 @@ function get_all_topics($forum="0", $forum_sort="DESC", $user=0) {
 
 
 
-function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
+function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $forum_style="plain", $forum_sort="DESC") {
     global $CFG, $USER;
     
     if ($forum_id) {
@@ -694,48 +680,48 @@ function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style
         if (! $course = get_record("course", "category", 0)) {
             error("Could not find a top-level course!");
         }
-        if (! $forum = get_course_news_forum($course->id)) {
+        if (! $forum = forum_get_course_news_forum($course->id)) {
             error("Could not find or create a main forum in this course (id $course->id)");
         }
     }
 
-    if (user_can_post_discussion($forum)) {
+    if (forum_user_can_post_discussion($forum)) {
         echo "<P ALIGN=right>";
-        echo "<A HREF=\"$CFG->wwwroot/mod/forum/post.php?forum=$forum->id\">Add a new topic...</A>";
+        echo "<A HREF=\"$CFG->wwwroot/mod/forum/post.php?forum=$forum->id\">Add a new discussion topic...</A>";
         echo "</P>\n";
     }
 
-    if (! $topics = get_all_topics($forum->id, $forum_sort) ) {
+    if (! $discussions = forum_get_discussions($forum->id, $forum_sort) ) {
         echo "<P ALIGN=CENTER><B>There are no discussion topics yet in this forum.</B></P>";
 
     } else {
 
-        $replies = count_discussion_replies($forum->id);
+        $replies = forum_count_discussion_replies($forum->id);
 
-        $topiccount = 0;
+        $discussioncount = 0;
 
-        foreach ($topics as $topic) {
-            $topiccount++;
+        foreach ($discussions as $discussion) {
+            $discussioncount++;
 
-            if ($forum_numtopics && ($topiccount > $forum_numtopics)) {
-                echo "<P ALIGN=right><A HREF=\"$CFG->wwwroot/mod/forum/view.php?f=$forum->id\">Older topics</A> ...</P>";
+            if ($forum_numdiscussions && ($discussioncount > $forum_numdiscussions)) {
+                echo "<P ALIGN=right><A HREF=\"$CFG->wwwroot/mod/forum/view.php?f=$forum->id\">Older discussions</A> ...</P>";
                 break;
             }
-            if ($replies[$topic->discussion]) {
-                $topic->replies = $replies[$topic->discussion]->replies;
+            if ($replies[$discussion->discussion]) {
+                $discussion->replies = $replies[$discussion->discussion]->replies;
             } else {
-                $topic->replies = 0;
+                $discussion->replies = 0;
             }
-            $ownpost = ($topic->userid == $USER->id);
+            $ownpost = ($discussion->userid == $USER->id);
             switch ($forum_style) {
                 case "minimal":
-                    echo "<P><FONT COLOR=#555555>".userdate($topic->modified, "%e %B, %H:%M")."</FONT>";
-                    echo "<BR>$topic->subject ";
-                    echo "<A HREF=\"$CFG->wwwroot/mod/forum/discuss.php?d=$topic->discussion\">more...</A>";
+                    echo "<P><FONT COLOR=#555555>".userdate($discussion->modified, "%e %b, %H:%M")." - $discussion->firstname</FONT>";
+                    echo "<BR>$discussion->subject ";
+                    echo "<A HREF=\"$CFG->wwwroot/mod/forum/discuss.php?d=$discussion->discussion\">more...</A>";
                     echo "</P>\n";
                 break;
                 default:
-                    print_post($topic, $forum->course, $ownpost, $reply=0, $link=1, $assessed=false);
+                    forum_print_post($discussion, $forum->course, $ownpost, $reply=0, $link=1, $assessed=false);
                     echo "<BR>\n";
                 break;
             }
@@ -743,15 +729,15 @@ function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style
     }
 }
 
-function print_discussion($course, $discussion, $post, $mode) {
+function forum_print_discussion($course, $discussion, $post, $mode) {
 
     global $USER;
 
     $ownpost = ($USER->id == $post->user);
 
-    print_post($post, $course->id, $ownpost, $reply=true, $link=false, $rate=false);
+    forum_print_post($post, $course->id, $ownpost, $reply=true, $link=false, $rate=false);
 
-    print_mode_form($discussion->id, $mode);
+    print_forum_mode_form($discussion->id, $mode);
 
     if ($discussion->assessed && $USER->id) {
         echo "<FORM NAME=form METHOD=POST ACTION=rate.php>";
@@ -763,16 +749,16 @@ function print_discussion($course, $discussion, $post, $mode) {
         case -1 :  // Flat descending
         default:   
             echo "<UL>";
-            print_posts_flat($post->discussion, $course->id, $mode, $discussion->assessed);
+            forum_print_posts_flat($post->discussion, $course->id, $mode, $discussion->assessed);
             echo "</UL>";
             break;
 
         case 2 :   // Threaded 
-            print_posts_threaded($post->id, $course->id, 0, $discussion->assessed);
+            forum_print_posts_threaded($post->id, $course->id, 0, $discussion->assessed);
             break;
 
         case 3 :   // Nested
-            print_posts_nested($post->id, $course->id, $discussion->assessed);
+            forum_print_posts_nested($post->id, $course->id, $discussion->assessed);
             break;
     }
 
@@ -782,7 +768,7 @@ function print_discussion($course, $discussion, $post, $mode) {
     }
 }
 
-function print_posts_flat($discussion, $course, $direction, $assessed) { 
+function forum_print_posts_flat($discussion, $course, $direction, $assessed) { 
     global $USER;
 
     $reply = true;
@@ -800,14 +786,14 @@ function print_posts_flat($discussion, $course, $direction, $assessed) {
 
         foreach ($posts as $post) {
             $ownpost = ($USER->id == $post->user);
-            print_post($post, $course, $ownpost, $reply, $link, $assessed);
+            forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);
         }
     } else {
         return;
     }
 }
 
-function print_posts_threaded($parent, $course, $depth, $assessed) { 
+function forum_print_posts_threaded($parent, $course, $depth, $assessed) { 
     global $USER;
 
     $reply = true;
@@ -822,13 +808,13 @@ function print_posts_threaded($parent, $course, $depth, $assessed) {
             echo "<UL>";
             if ($depth > 0) {
                 $ownpost = ($USER->id == $post->user);
-                print_post($post, $course, $ownpost, $reply, $link, $assessed);  // link=true?
+                forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);  // link=true?
                 echo "<BR>";
             } else {
                 echo "<LI><P><B><A HREF=\"discuss.php?d=$post->discussion&parent=$post->id\">$post->subject</A></B> by $post->firstname $post->lastname, ".userdate($post->created)."</P>";
             }
 
-            print_posts_threaded($post->id, $course, $depth-1, $assessed);
+            forum_print_posts_threaded($post->id, $course, $depth-1, $assessed);
             echo "</UL>\n";
         }
     } else {
@@ -836,7 +822,7 @@ function print_posts_threaded($parent, $course, $depth, $assessed) {
     }
 }
 
-function print_posts_nested($parent, $course, $assessed) { 
+function forum_print_posts_nested($parent, $course, $assessed) { 
     global $USER;
 
     $reply = true;
@@ -852,9 +838,9 @@ function print_posts_nested($parent, $course, $assessed) {
             $ownpost = ($USER->id == $post->user);
 
             echo "<UL>";
-            print_post($post, $course, $ownpost, $reply, $link, $assessed);
+            forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);
             echo "<BR>";
-            print_posts_nested($post->id, $course, $assessed);
+            forum_print_posts_nested($post->id, $course, $assessed);
             echo "</UL>\n";
         }
     } else {
index c1ed084fb5d87dc0dc13bfe0986604211056c83a..ad6789139c4b10d362332e34cab66ed558f43323 100644 (file)
 
         if ($post->edit) {           // Updating a post
             $post->id = $post->edit;
-            if (update_post_in_database($post) ) {
+            if (forum_update_post($post) ) {
                 add_to_log($post->course, "forum", "update post", "discuss.php?d=$post->discussion&parent=$post->id", "$post->id");
-                redirect(go_back_to("discuss.php?d=$post->discussion"), "Your post was updated", 1);
+                redirect(forum_go_back_to("discuss.php?d=$post->discussion"), "Your post was updated", 1);
             } else {
                 error("Could not update your post due to an unknown error"); 
             }
         } else if ($post->discussion) { // Adding a new post to an existing discussion
-            if ($post->id = add_new_post_to_database($post)) {
+            if ($post->id = forum_add_new_post($post)) {
                 if ( ! forum_is_subscribed($USER->id, $post->forum) ) {
                     forum_subscribe($USER->id, $post->forum);
                 }
 
                 add_to_log($post->course, "forum", "add post", "discuss.php?d=$post->discussion&parent=$post->id", "$post->id");
-                redirect(go_back_to("discuss.php?d=$post->discussion"), 
+                redirect(forum_go_back_to("discuss.php?d=$post->discussion"), 
                          "Your post was successfully added.<P>You have ".format_time($CFG->maxeditingtime)." to edit it if you want to make any changes.", 3);
             } else {
                 error("Could not add the post due to an unknown error"); 
@@ -47,7 +47,7 @@
                     forum_subscribe($USER->id, $post->forum);
                 }
                 add_to_log($post->course, "forum", "add discussion", "discuss.php?d=$discussion->id", "$discussion->id");
-                redirect(go_back_to("view.php?f=$post->forum"), 
+                redirect(forum_go_back_to("view.php?f=$post->forum"), 
                          "Your post was successfully added.<P>You have ".format_time($CFG->maxeditingtime)." to edit it if you want to make any changes.", 5);
             } else {
                 error("Could not insert the new discussion.");
@@ -69,7 +69,7 @@
             error("The course number was incorrect ($forum)");
         }
 
-        if (! user_can_post_discussion($forum)) {
+        if (! forum_user_can_post_discussion($forum)) {
             error("Sorry, but you can not post a new discussion in this forum.");
         }
 
         $post->user = $USER->id;
         $post->message = "";
 
-        set_fromdiscussion();
-    
+        forum_set_return();
+
     } else if (isset($reply)) {      // User is writing a new reply
 
-        if (! $parent = get_forum_post_full($reply)) {
+        if (! $parent = forum_get_post_full($reply)) {
             error("Parent post ID was incorrect ($reply)");
         }
         if (! $discussion = get_record("forum_discussions", "id", $parent->discussion)) {
             $post->subject = "Re: ".$post->subject;
         }
 
-        set_fromdiscussion();
+        forum_set_return();
 
     } else if (isset($edit)) {  // User is editing their own post
 
-        if (! $post = get_forum_post_full($edit)) {
+        if (! $post = forum_get_post_full($edit)) {
             error("Post ID was incorrect");
         }
         if ($post->user <> $USER->id) {
             error("Sorry, but the maximum time for editing this post (".format_time($CFG->maxeditingtime).") has passed!");
         }
         if ($post->parent) {
-            if (! $parent = get_forum_post_full($post->parent)) {
+            if (! $parent = forum_get_post_full($post->parent)) {
                 error("Parent post ID was incorrect ($post->parent)");
             }
         }
         $post->course  = $course->id;
         $post->forum  = $forum->id;
 
-        set_fromdiscussion();
+        forum_set_return();
 
 
     } else if (isset($delete)) {  // User is deleting a post
 
-        if (! $post = get_forum_post_full($delete)) {
+        if (! $post = forum_get_post_full($delete)) {
             error("Post ID was incorrect");
         }
         if ($post->user <> $USER->id) {
 
             if ($post->totalscore) {
                 notice("Sorry, that cannot be deleted as people have already rated it", 
-                        go_back_to("discuss.php?d=$post->discussion"));
+                        forum_go_back_to("discuss.php?d=$post->discussion"));
 
             } else if (record_exists("forum_posts", "parent", $delete)) {
                 error("Sorry, that cannot be deleted as people have 
                         already responded to it", 
-                        go_back_to("discuss.php?id=$post->discussion"));
+                        forum_go_back_to("discuss.php?id=$post->discussion"));
 
             } else {
                 if (! $post->parent) {  // post is a discussion topic as well, so delete discussion
                 } else if (delete_records("forum_posts", "id", $post->id)) {
 
                     add_to_log($discussion->course, "forum", "delete post", "discuss.php?d=$post->discussion", "$post->id");
-                    redirect(go_back_to("discuss.php?d=$post->discussion"), 
+                    redirect(forum_go_back_to("discuss.php?d=$post->discussion"), 
                              "Your post was deleted", 1);
                 } else {
                     error("An error occurred while deleting record $post->id");
 
         } else { // User just asked to delete something
 
-            set_fromdiscussion();
+            forum_set_return();
 
             print_header();
             notice_yesno("Are you sure you want to delete this post?", 
                          $HTTP_REFERER);
                          
             echo "<CENTER><HR>";
-            print_post($post, 0, $ownpost=false, $reply=false, $link=false);
+            forum_print_post($post, 0, $ownpost=false, $reply=false, $link=false);
 
         }
 
 
     echo "<CENTER>";
     if (isset($parent)) {
-        print_post($parent, $course->id, $ownpost=false, $reply=false, $link=false);
+        forum_print_post($parent, $course->id, $ownpost=false, $reply=false, $link=false);
         echo "<H2>Your reply:</H2>";
     } else {
         echo "<H2>Your new discussion topic:</H2>";
index e9bd5287f26abb431b3844ca05caf06cdf354819..9be619d27767ab0a53d84d0d6a824063ea7e78fe 100644 (file)
@@ -64,7 +64,7 @@
                 $post->message = highlight("$search", $post->message);
 
                 $fulllink = "<P ALIGN=right><A HREF=\"discuss.php?d=$post->discussion&parent=$post->id\">See this post in context</A></P>";
-                print_post($post, $course->id, false, false, false, false, $fulllink);
+                forum_print_post($post, $course->id, false, false, false, false, $fulllink);
 
                 echo "<BR>";
             }
index 63806bb8c0f815a7e8d2309ef09681d8d6415817..12acc32eb9f53dcf80e28d70770c3be674b526b0 100644 (file)
@@ -32,7 +32,7 @@
         }
     }
 
-    $returnto = go_back_to("index.php?id=$course->id");
+    $returnto = forum_go_back_to("index.php?id=$course->id");
 
     if ($force and isteacher($course->id)) {
         if (forum_is_forcesubscribed($forum->id)) {
index 84a5a4c62d94d2cc3837715e0a78ac890418fb93..1b5462ea98c00098b8a8b49e15a0cc137045db2d 100644 (file)
                     error("Could not find the discussion in this forum");
                 }
             }
-            if (! $post = get_forum_post_full($discussion->firstpost)) {
+            if (! $post = forum_get_post_full($discussion->firstpost)) {
                 error("Could not find the first post in this forum");
             }
             forum_set_display_mode($mode);
-            print_discussion($course, $discussion, $post, $USER->mode);
+            forum_print_discussion($course, $discussion, $post, $USER->mode);
             break;
 
         case "eachuser":
             print_simple_box(text_to_html($forum->intro), "CENTER");
             echo "<P ALIGN=CENTER>";
-            if (user_can_post_discussion($forum)) {
+            if (forum_user_can_post_discussion($forum)) {
                 echo "This forum allows one discussion topic to be posted per person.";
             } else {
                 echo "&nbsp";
             }
             echo "</P>";
-            print_forum_latest_topics($forum->id, 0);
+            forum_print_latest_discussions($forum->id, 0);
             break;
 
         default:
             print_simple_box(text_to_html($forum->intro), "CENTER");
             echo "<P>&nbsp;</P>";
-            print_forum_latest_topics($forum->id, 0);
+            forum_print_latest_discussions($forum->id, 0);
             break;
     }
 
index 1a810dee9934c70e5149d2acf2b13c10e9983431..2c4d02f1e3cdfcc730acbd60a1298e2cad392336 100644 (file)
     }
     echo "</TR></TABLE></CENTER>\n";
 
-    print_user_discussions($course, $user);
+    forum_print_user_discussions($course->id, $user->id);
 
     print_footer($course);