id, "forum", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
$strforumposts = get_string('forumposts', 'forum');
$strparticipants = get_string('participants');
$strmode = get_string($mode, 'forum');
$fullname = fullname($user, isteacher($course->id));
if ($course->category) {
print_header("$course->shortname: $fullname: $strmode", "$course->fullname",
"wwwroot/course/view.php?id=$course->id\">$course->shortname ->
wwwroot/user/index.php?id=$course->id\">$strparticipants ->
wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname ->
$strforumposts -> $strmode");
} else {
print_header("$course->shortname: $fullname: $strmode", "$course->fullname",
"wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname ->
$strforumposts -> $strmode");
}
$currenttab = $mode;
include($CFG->dirroot.'/user/tabs.php'); /// Prints out tabs as part of user page
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and
$course->groupmodeforce and
!isteacheredit($course->id));
$groupid = $isseparategroups ? get_current_group($course->id) : NULL;
switch ($mode) {
case 'posts' :
$searchterms = array('userid:'.$user->id);
$extrasql = '';
break;
default:
$searchterms = array('userid:'.$user->id);
$extrasql = 'AND p.parent = 0';
break;
}
if ($posts = forum_search_posts($searchterms, $course->id, $page*$perpage, $perpage,
$totalcount, $groupid, $extrasql)) {
print_paging_bar($totalcount, $page, $perpage,
"user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&");
foreach ($posts as $post) {
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
error('Discussion ID was incorrect');
}
if (! $forum = get_record('forum', 'id', "$discussion->forum")) {
error("Could not find forum $discussion->forum");
}
$fullsubject = "id\">".format_string($forum->name,true)."";
if ($forum->type != 'single') {
$fullsubject .= " -> id\">".format_string($discussion->name,true)."";
if ($post->parent != 0) {
$fullsubject .= " -> discussion&parent=$post->id\">".format_string($post->subject,true)."";
}
}
if (isadmin() && $course->id == SITEID) {
$postcoursename = get_field('course', 'shortname', 'id', $forum->course);
$fullsubject = ''.$postcoursename.' -> '. $fullsubject;
}
$post->subject = $fullsubject;
/// Add the forum id to the post object - used by read tracking.
$post->forum = $forum->id;
$fulllink = "discussion#$post->id\">".
get_string("postincontext", "forum")."";
forum_print_post($post, $course->id, false, false, false, false, $fulllink);
echo "
";
}
print_paging_bar($totalcount, $page, $perpage,
"user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&");
} else {
print_heading(get_string('noposts', 'forum'));
}
print_footer($course);
?>