This patches allow you to select sorting order method of the discussion topics. In current version of Moodle1.8 the list of discussion topics is displayed in order of 'Last Post' only. We can not follow the relationship a topic and next topic.
After applying these three paches we can select three sorting methods of discussion topics. One is origginal sorting method (Last Post), and the others are sorting by 'First Post (From older)' and 'First Post (From newer)' according to date of discussion topic.
(1) mod/forum/view.php, Line199
print_box_start('rsslink');
rss_print_link($course->id, $userid, "forum", $forum->id, $tooltiptext);
print_box_end(); // subscription}
// Adding (From here)
print_box_start('sortorder');
if (!isset($_COOKIE['sortorderfirstpost'])) $sortorderfirstpost = 1;
else $sortorderfirstpost = $_COOKIE['sortorderfirstpost'];
echo "<span class=\"helplink\">Sort discussion topics in order of  ";
if ($sortorderfirstpost <> 1) {
echo "<a title=\"Display discussion topics in order of Last Post\" href=\"subscribe.php?id=$forum->id&sortorder=1\">(Last Post)</a> ";
}
if ($sortorderfirstpost <> 2) {
echo "<a title=\"Display discussion topics in order of First Post(From Older)\" href=\"subscribe.php?id=$forum->id&sortorder=2\">(First Post/Older)</a> ";
}
if ($sortorderfirstpost <> 3) {
echo "<a title=\"Display discussion topics in order of First Post(From Newer)\" href=\"subscribe.php?id=$forum->id&sortorder=3\">(First Post/Newer) </a>";
}
echo "</span>";
print_box_end();
// Adding (To here)
print_box_end(); // subscriptionprint_box_end(); // forumcontrol
print_box(' ', 'clearer');
(2) mod/forum/subscribe.php, Line73.
notice_yesno(get_string('noguestsubscribe', 'forum').'<br /><br />'.get_string('liketologin'),
$wwwroot, $_SERVER['HTTP_REFERER']);
print_footer($course);
exit;
}$returnto = forum_go_back_to("index.php?id=$course->id");
// Adding (From here)
$sortorder = optional_param('sortorder', 0, PARAM_INT);
if ($sortorder > 0) {
setcookie("sortorderfirstpost", $sortorder);
redirect($returnto, "Sorting order of Discussion topics has changed.", 1);
}
// Adding (To here)
if ($force and has_capability('mod/forum:managesubscriptions', $context)) {
if (forum_is_forcesubscribed($forum->id)) {
forum_forcesubscribe($forum->id, 0);
redirect($returnto, get_string("everyonecannowchoose", "forum"), 1);
} else {
forum_forcesubscribe($forum->id, 1);
redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
}
}
(3) mod/forum/lib.php, Line3486,in function forum_print_latest_discussions()
function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $displayformat='plain', $sort='',
$currentgroup=-1, $groupmode=-1, $page=-1, $cm=NULL) {
global $CFG, $USER;
// Adding (From here)
if (isset($_COOKIE['sortorderfirstpost'])) {
switch ($_COOKIE['sortorderfirstpost']) {
case "2": $sort = "d.firstpost"; break;
case "3": $sort = "d.firstpost DESC"; break;
default : $sort = '';
}
}
// Adding (To here)
if (!$cm) {
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
error('Course Module ID was incorrect');
}
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);