2 // Displays different views of the logs.
4 require_once('../../../config.php');
5 require_once('../../lib.php');
6 require_once('lib.php');
7 require_once($CFG->libdir
.'/adminlib.php');
9 $id = optional_param('id', 0, PARAM_INT
);// Course ID
11 $host_course = optional_param('host_course', '', PARAM_PATH
);// Course ID
13 if (empty($host_course)) {
14 $hostid = $CFG->mnet_localhost_id
;
20 list($hostid, $id) = explode('/', $host_course);
23 $group = optional_param('group', -1, PARAM_INT
); // Group to display
24 $user = optional_param('user', 0, PARAM_INT
); // User to display
25 $date = optional_param('date', 0, PARAM_FILE
); // Date to display - number or some string
26 $modname = optional_param('modname', '', PARAM_CLEAN
); // course_module->id
27 $modid = optional_param('modid', 0, PARAM_FILE
); // number or 'site_errors'
28 $modaction = optional_param('modaction', '', PARAM_PATH
); // an action as recorded in the logs
29 $page = optional_param('page', '0', PARAM_INT
); // which page to show
30 $perpage = optional_param('perpage', '100', PARAM_INT
); // how many per page
31 $showcourses = optional_param('showcourses', 0, PARAM_INT
); // whether to show courses if we're over our limit.
32 $showusers = optional_param('showusers', 0, PARAM_INT
); // whether to show users if we're over our limit.
33 $chooselog = optional_param('chooselog', 0, PARAM_INT
);
34 $logformat = optional_param('logformat', 'showashtml', PARAM_ALPHA
);
38 if ($hostid == $CFG->mnet_localhost_id
) {
39 if (!$course = get_record('course', 'id', $id) ) {
40 error('That\'s an invalid course id'.$id);
43 $course_stub = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1'));
45 $course->shortname
= $course_stub->coursename
;
46 $course->fullname
= $course_stub->coursename
;
49 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
51 require_capability('moodle/site:viewreports', $context);
53 add_to_log($course->id
, "course", "report log", "report/log/index.php?id=$course->id", $course->id
);
55 $strlogs = get_string('logs');
56 $stradministration = get_string('administration');
57 $strreports = get_string('reports');
59 session_write_close();
61 if (!empty($chooselog)) {
62 $userinfo = get_string('allparticipants');
63 $dateinfo = get_string('alldays');
66 if (!$u = get_record('user', 'id', $user) ) {
67 error('That\'s an invalid user!');
69 $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
72 $dateinfo = userdate($date, get_string('strftimedaydate'));
77 if ($hostid != $CFG->mnet_localhost_id ||
$course->id
== SITEID
) {
78 admin_externalpage_setup('reportlog');
79 admin_externalpage_print_header();
82 print_header($course->shortname
.': '. $strlogs, $course->fullname
,
83 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
84 <a href=\"$CFG->wwwroot/course/report.php?id=$course->id\">$strreports</a> ->
85 <a href=\"index.php?id=$course->id\">$strlogs</a> -> $userinfo, $dateinfo", '');
88 print_heading(format_string($course->fullname
) . ": $userinfo, $dateinfo (".usertimezone().")");
89 print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
91 if($hostid == $CFG->mnet_localhost_id
) {
92 print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
93 "index.php?id=$course->id&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction&group=$group",
94 $modname, $modid, $modaction, $group);
96 print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
100 if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
101 $modid, $modaction, $group)) {
102 notify("No logs found!");
103 print_footer($course);
106 case 'downloadasods':
107 if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname,
108 $modid, $modaction, $group)) {
109 notify("No logs found!");
110 print_footer($course);
113 case 'downloadasexcel':
114 if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname,
115 $modid, $modaction, $group)) {
116 notify("No logs found!");
117 print_footer($course);
124 if ($hostid != $CFG->mnet_localhost_id ||
$course->id
== SITEID
) {
125 admin_externalpage_setup('reportlog');
126 admin_externalpage_print_header();
128 print_header($course->shortname
.': '. $strlogs, $course->fullname
,
129 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
130 <a href=\"$CFG->wwwroot/course/report.php?id=$course->id\">$strreports</a> ->
134 print_heading(get_string('chooselogs') .':');
136 print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
139 print_heading(get_string('chooselivelogs') .':');
142 link_to_popup_window('/course/report/log/live.php?id='. $course->id
,'livelog', get_string('livelogs'), 500, 800);
143 echo '</h3></center>';
147 print_footer($course);