diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 39ed7ba019a..af7edf25853 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -22,6 +22,7 @@ $FORUM_SHORT_POST = 300; // Less than this is "short" $FORUM_LONG_POST = 600; // More than this is "long" +$FORUM_MANY_DISCUSSIONS = 10; /// FUNCTIONS /////////////////////////////////////////////////////////// @@ -237,6 +238,56 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link echo "\n\n\n"; } + +function forum_print_post_header(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") { + global $THEME, $USER, $CFG, $FORUM_LONG_POST; + + if ($post->parent) { + echo "
";
+ echo "
(".get_string("nodiscussions", "forum").") "; + return; - } else { + } + + if ((!$forum_numdiscussions) && ($forum_style == "plain") && (count($discussions) > $FORUM_MANY_DISCUSSIONS) ) { + $forum_style = "header"; // Abbreviate display if it's going to be long. + } - $replies = forum_count_discussion_replies($forum->id); + $replies = forum_count_discussion_replies($forum->id); - $discussioncount = 0; + $discussioncount = 0; - foreach ($discussions as $discussion) { - $discussioncount++; + foreach ($discussions as $discussion) { + $discussioncount++; - if ($forum_numdiscussions && ($discussioncount > $forum_numdiscussions)) { - echo "wwwroot/mod/forum/view.php?f=$forum->id\">"; - echo get_string("olderdiscussions", "forum")." ... "; - break; - } - if ($replies[$discussion->discussion]) { - $discussion->replies = $replies[$discussion->discussion]->replies; - } else { - $discussion->replies = 0; - } - $ownpost = ($discussion->userid == $USER->id); - switch ($forum_style) { - case "minimal": - echo "".userdate($discussion->modified, "%e %b, %H:%M")." - $discussion->firstname";
- echo " \n"; - break; - } + if ($forum_numdiscussions && ($discussioncount > $forum_numdiscussions)) { + echo " wwwroot/mod/forum/view.php?f=$forum->id\">"; + echo get_string("olderdiscussions", "forum")." ... "; + break; + } + if ($replies[$discussion->discussion]) { + $discussion->replies = $replies[$discussion->discussion]->replies; + } else { + $discussion->replies = 0; + } + $ownpost = ($discussion->userid == $USER->id); + switch ($forum_style) { + case "minimal": + echo "".userdate($discussion->modified, "%e %b, %H:%M")." - $discussion->firstname";
+ echo " \n"; + break; } } } |