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', 0, 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
);
36 if ($hostid == $CFG->mnet_localhost_id
) {
37 if (!$course = get_record('course', 'id', $id) ) {
38 error('That\'s an invalid course id'.$id);
41 $course_stub = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1'));
43 $course->shortname
= $course_stub->coursename
;
44 $course->fullname
= $course_stub->coursename
;
47 require_login($course->id
);
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();
63 if (!empty($chooselog)) {
64 $userinfo = get_string('allparticipants');
65 $dateinfo = get_string('alldays');
68 if (!$u = get_record('user', 'id', $user) ) {
69 error('That\'s an invalid user!');
71 $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
74 $dateinfo = userdate($date, get_string('strftimedaydate'));
79 if ($hostid != $CFG->mnet_localhost_id ||
$course->id
== SITEID
) {
80 admin_externalpage_setup('reportlog');
81 admin_externalpage_print_header();
84 $navlinks[] = array('name' => $strreports, 'link' => "$CFG->wwwroot/course/report.php?id=$course->id", 'type' => 'misc');
85 $navlinks[] = array('name' => $strlogs, 'link' => "index.php?id=$course->id", 'type' => 'misc');
86 $navlinks[] = array('name' => "$userinfo, $dateinfo", 'link' => null, 'type' => 'misc');
87 $navigation = build_navigation($navlinks);
88 print_header($course->shortname
.': '. $strlogs, $course->fullname
, $navigation);
91 print_heading(format_string($course->fullname
) . ": $userinfo, $dateinfo (".usertimezone().")");
92 print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
94 if($hostid == $CFG->mnet_localhost_id
) {
95 print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
96 "index.php?id=$course->id&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction&group=$group",
97 $modname, $modid, $modaction, $group);
99 print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
102 case 'downloadascsv':
103 if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
104 $modid, $modaction, $group)) {
105 notify("No logs found!");
106 print_footer($course);
109 case 'downloadasods':
110 if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname,
111 $modid, $modaction, $group)) {
112 notify("No logs found!");
113 print_footer($course);
116 case 'downloadasexcel':
117 if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname,
118 $modid, $modaction, $group)) {
119 notify("No logs found!");
120 print_footer($course);
127 if ($hostid != $CFG->mnet_localhost_id ||
$course->id
== SITEID
) {
128 admin_externalpage_setup('reportlog');
129 admin_externalpage_print_header();
131 $navlinks[] = array('name' => $strreports, 'link' => "$CFG->wwwroot/course/report.php?id=$course->id", 'type' => 'misc');
132 $navlinks[] = array('name' => $strlogs, 'link' => null, 'type' => 'misc');
133 $navigation = build_navigation($navlinks);
134 print_header($course->shortname
.': '. $strlogs, $course->fullname
, $navigation, '');
137 print_heading(get_string('chooselogs') .':');
139 print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
142 print_heading(get_string('chooselivelogs') .':');
145 link_to_popup_window('/course/report/log/live.php?id='. $course->id
,'livelog', get_string('livelogs'), 500, 800);
146 echo '</h3></center>';
150 print_footer($course);