id; } if (! $user = get_record("user", "id", $id)) { error("User ID is incorrect"); } if (! $course = get_record("course", "id", $course)) { error("Course id is incorrect."); } $syscontext = get_context_instance(CONTEXT_SYSTEM); $usercontext = get_context_instance(CONTEXT_USER, $id); // do not force parents to enrol if (!get_record('role_assignments', 'userid', $USER->id, 'contextid', $usercontext->id)) { require_course_login($course); } if ($user->deleted) { print_header(); print_heading(get_string('userdeleted')); print_footer($course); die; } add_to_log($course->id, "forum", "user report", "user.php?course=$course->id&id=$user->id&mode=$mode", "$user->id"); $strforumposts = get_string('forumposts', 'forum'); $strparticipants = get_string('participants'); $strmode = get_string($mode, 'forum'); $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $syscontext)); $navlinks = array(); if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id)) || has_capability('moodle/site:viewparticipants', $syscontext)) { $navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'core'); } $navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", 'type' => 'title'); $navlinks[] = array('name' => $strforumposts, 'link' => '', 'type' => 'title'); $navlinks[] = array('name' => $strmode, 'link' => '', 'type' => 'title'); $navigation = build_navigation($navlinks); print_header("$course->shortname: $fullname: $strmode", $course->fullname,$navigation); $currenttab = $mode; $showroles = 1; include($CFG->dirroot.'/user/tabs.php'); /// Prints out tabs as part of user page switch ($mode) { case 'posts' : $searchterms = array('userid:'.$user->id); $extrasql = ''; break; default: $searchterms = array('userid:'.$user->id); $extrasql = 'AND p.parent = 0'; break; } echo '
'; if ($course->id == SITEID) { if (empty($CFG->forceloginforprofiles) || isloggedin()) { // Search throughout the whole site. $searchcourse = 0; } else { $searchcourse = SITEID; } } else { // Search only for posts the user made in this course. $searchcourse = $course->id; } // Get the posts. if ($posts = forum_search_posts($searchterms, $searchcourse, $page*$perpage, $perpage, $totalcount, $extrasql)) { print_paging_bar($totalcount, $page, $perpage, "user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&"); $discussions = array(); $forums = array(); $cms = array(); foreach ($posts as $post) { if (!isset($discussions[$post->discussion])) { if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) { error('Discussion ID was incorrect'); } $discussions[$post->discussion] = $discussion; } else { $discussion = $discussions[$post->discussion]; } if (!isset($forums[$discussion->forum])) { if (! $forum = get_record('forum', 'id', $discussion->forum)) { error("Could not find forum $discussion->forum"); } $forums[$discussion->forum] = $forum; } else { $forum = $forums[$discussion->forum]; } $ratings = null; if ($forum->assessed) { if ($scale = make_grades_menu($forum->scale)) { $ratings =new object(); $ratings->scale = $scale; $ratings->assesstimestart = $forum->assesstimestart; $ratings->assesstimefinish = $forum->assesstimefinish; $ratings->allow = false; } } if (!isset($cms[$forum->id])) { if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) { error('Course Module ID was incorrect'); } $cms[$forum->id] = $cm; unset($cm); // do not use cm directly, it would break caching } $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 ($course->id == SITEID && has_capability('moodle/site:config', $syscontext)) { $postcoursename = get_field('course', 'shortname', 'id', $forum->course); $fullsubject = ''.$postcoursename.' -> '. $fullsubject; } $post->subject = $fullsubject; $fulllink = "discussion#p$post->id\">". get_string("postincontext", "forum").""; forum_print_post($post, $discussion, $forum, $cms[$forum->id], $course, false, false, false, $ratings, $fulllink); echo "
"; } print_paging_bar($totalcount, $page, $perpage, "user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&"); } else { if ($mode == 'posts') { print_heading(get_string('noposts', 'forum')); } else { print_heading(get_string('nodiscussionsstartedby', 'forum')); } } echo '
'; print_footer($course); ?>