mirror of
https://github.com/moodle/moodle.git
synced 2025-02-13 12:34:28 +01:00
134 lines
5.2 KiB
PHP
134 lines
5.2 KiB
PHP
<?php // $Id$
|
|
|
|
// Display user activity reports for a course
|
|
|
|
require_once('../../config.php');
|
|
require_once('lib.php');
|
|
|
|
$course = required_param('course'); // course id
|
|
$id = optional_param('id'); // user id
|
|
$mode = optional_param('mode', 'posts');
|
|
$page = optional_param('page', 0);
|
|
$perpage = optional_param('perpage', 5);
|
|
|
|
if (empty($id)) { // See your own profile by default
|
|
require_login();
|
|
$id = $USER->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, SITEID);
|
|
|
|
require_course_login($course);
|
|
|
|
|
|
add_to_log($course->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, has_capability('moodle/site:viewfullnames', $syscontext));
|
|
|
|
if ($course->category) {
|
|
print_header("$course->shortname: $fullname: $strmode", "$course->fullname",
|
|
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
<a href=\"$CFG->wwwroot/user/index.php?id=$course->id\">$strparticipants</a> ->
|
|
<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname</a> ->
|
|
$strforumposts -> $strmode");
|
|
} else {
|
|
print_header("$course->shortname: $fullname: $strmode", "$course->fullname",
|
|
"<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname</a> ->
|
|
$strforumposts -> $strmode");
|
|
}
|
|
|
|
$currenttab = $mode;
|
|
include($CFG->dirroot.'/user/tabs.php'); /// Prints out tabs as part of user page
|
|
|
|
$isseparategroups = /*
|
|
NOTE: isteacheredit is deprecated.
|
|
|
|
(($course->groupmode == SEPARATEGROUPS and
|
|
$course->groupmodeforce and
|
|
!isteacheredit($course->id))*/forum_get_separate_modules($course->id);
|
|
|
|
/*
|
|
NOTE: isteacheredit is deprecated.
|
|
|
|
//editting teacher can view everything so do not pass in groupid
|
|
if (isteacheredit ($course->id)){
|
|
$isseparategroups = false;
|
|
}
|
|
*/
|
|
|
|
$groupid = $isseparategroups ? /*get_current_group*/mygroupid($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;
|
|
}
|
|
|
|
echo '<div class="user-content">';
|
|
// Get the posts regardless of group first.
|
|
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 = "<a href=\"view.php?f=$forum->id\">".format_string($forum->name,true)."</a>";
|
|
if ($forum->type != 'single') {
|
|
$fullsubject .= " -> <a href=\"discuss.php?d=$discussion->id\">".format_string($discussion->name,true)."</a>";
|
|
if ($post->parent != 0) {
|
|
$fullsubject .= " -> <a href=\"discuss.php?d=$post->discussion&parent=$post->id\">".format_string($post->subject,true)."</a>";
|
|
}
|
|
}
|
|
|
|
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
|
if ($course->id == SITEID && has_capability('moodle/site:config', $context)) {
|
|
$postcoursename = get_field('course', 'shortname', 'id', $forum->course);
|
|
$fullsubject = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$forum->course.'">'.$postcoursename.'</a> -> '. $fullsubject;
|
|
}
|
|
|
|
$post->subject = $fullsubject;
|
|
|
|
$fulllink = "<a href=\"discuss.php?d=$post->discussion#$post->id\">".
|
|
get_string("postincontext", "forum")."</a>";
|
|
|
|
forum_print_post($post, $course->id, false, false, false, false, $fulllink);
|
|
|
|
echo "<br />";
|
|
}
|
|
|
|
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'));
|
|
}
|
|
echo '</div>';
|
|
print_footer($course);
|
|
|
|
?>
|
|
|