id, $course->id)) {
$buttontext = "";
} else {
$cm->id = NULL;
$buttontext = "";
}
if ($forum->type == "teacher") {
if (!isteacher($course->id)) {
error("You must be a $course->teacher to view this forum");
}
}
/// Check to see if groups are being used in this forum
/// and if so, set $currentgroup to reflect the current group
$changegroup = isset($_GET['group']) ? $_GET['group'] : -1; // Group change requested?
if ($forum->type == "teacher") {
$groupmode = NOGROUPS;
} else {
$groupmode = groupmode($course, $cm); // Groups are being used
}
/// Editing teachers see all users, regardless of groups.
if (!isteacheredit($course->id)) {
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
} else {
$currentgroup = false;
}
if ($groupmode and ($currentgroup === false) and !isteacheredit($course->id)) {
print_heading(get_string("notingroup", "forum"));
exit;
}
/// Print settings and things in a table across the top
$forum->intro = trim($forum->intro);
if (!empty($forum->intro)) {
print_simple_box(format_text($forum->intro), 'center');
}
echo '
';
if (!empty($showall)) {
marking_forum_print_latest_discussions($forum->id, 0, 'header', '', $currentgroup, $groupmode);
} else {
marking_forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, 'header', '', $currentgroup, $groupmode, $page);
}
/// Check for users that haven't posted:
//Get students from forum_posts
$st_posts = get_records_sql("SELECT DISTINCT u.*
FROM {$CFG->prefix}user u,
{$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p
WHERE d.forum = '$forum->id' and
p.discussion = d.id and
u.id = p.userid");
echo '
';
foreach ($students as $student) {
if (!is_array($st_posts) || !array_key_exists($student->id, $st_posts)) {
echo 'Student '.fullname($student).' has not yet posted to this forum.
';
}
}
//------------------------------------------------------------------------------
function marking_forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5,
$forum_style="plain", $forum_sort="",
$currentgroup=0, $groupmode=-1, $page=-1) {
global $CFG, $USER, $forum, $cm, $course;
if ($groupmode == -1) { /// We need to reconstruct groupmode because none was given
if ($cm) {
$groupmode = groupmode($course, $cm);
} else {
$groupmode = SEPARATEGROUPS;
}
}
if ((!$forum_numdiscussions) && ($forum_style == "plain")) {
$forum_style = "header"; // Abbreviate display by default
}
if ($forum_style == "minimal") {
$forum_sort = "p.modified DESC";
}
$fullpost = false;
if ($forum_style == "plain") {
$fullpost = true;
}
/// Decides if current user is allowed to see ALL the current discussions or not
if (!$currentgroup and ($groupmode != SEPARATEGROUPS or isteacheredit($forum->course)) ) {
$visiblegroups = -1;
} else {
$visiblegroups = $currentgroup;
}
/// Get all the recent discussions we're allowed to see
if (! $discussions = forum_get_discussions($forum->id, $forum_sort, 0, $fullpost, $visiblegroups) ) {
if ($forum->type == "news") {
echo "
(".get_string("nonews", "forum").")
"; } else { echo "(".get_string("nodiscussions", "forum").")
"; } return; } //If forum_numdiscussions <= 0 don't paging (to avoid some divided by 0 errors) if ($forum_numdiscussions <= 0) { $page = -1; $forum_numdiscussions = 0; } $replies = forum_count_discussion_replies($forum->id); $canreply = forum_user_can_post($forum); $discussioncount = 0; $olddiscussionlink = false; $strdatestring = get_string("strftimerecentfull"); if ($forum_style == "minimal") { $strftimerecent = get_string("strftimerecent"); $strmore = get_string("more", "forum"); } if ($forum_style == "header") { echo "".get_string("discussion", "forum")." | "; echo "".get_string("startedby", "forum")." | "; if ($forum->open or $forum->type == "teacher") { echo "".get_string("replies", "forum")." | "; } echo "".get_string("lastpost", "forum")." | "; echo "
---|