See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Displays different views of the logs. 19 * 20 * @package report_log 21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require('../../config.php'); 26 require_once($CFG->dirroot.'/course/lib.php'); 27 require_once($CFG->dirroot.'/report/log/locallib.php'); 28 require_once($CFG->libdir.'/adminlib.php'); 29 require_once($CFG->dirroot.'/lib/tablelib.php'); 30 31 $id = optional_param('id', 0, PARAM_INT);// Course ID. 32 $group = optional_param('group', 0, PARAM_INT); // Group to display. 33 $user = optional_param('user', 0, PARAM_INT); // User to display. 34 $date = optional_param('date', 0, PARAM_INT); // Date to display. 35 $modid = optional_param('modid', 0, PARAM_ALPHANUMEXT); // Module id or 'site_errors'. 36 $modaction = optional_param('modaction', '', PARAM_ALPHAEXT); // An action as recorded in the logs. 37 $page = optional_param('page', '0', PARAM_INT); // Which page to show. 38 $perpage = optional_param('perpage', '100', PARAM_INT); // How many per page. 39 $showcourses = optional_param('showcourses', false, PARAM_BOOL); // Whether to show courses if we're over our limit. 40 $showusers = optional_param('showusers', false, PARAM_BOOL); // Whether to show users if we're over our limit. 41 $chooselog = optional_param('chooselog', false, PARAM_BOOL); 42 $logformat = optional_param('download', '', PARAM_ALPHA); 43 $logreader = optional_param('logreader', '', PARAM_COMPONENT); // Reader which will be used for displaying logs. 44 $edulevel = optional_param('edulevel', -1, PARAM_INT); // Educational level. 45 $origin = optional_param('origin', '', PARAM_TEXT); // Event origin. 46 47 $params = array(); 48 if (!empty($id)) { 49 $params['id'] = $id; 50 } else { 51 $site = get_site(); 52 $id = $site->id; 53 } 54 if ($group !== 0) { 55 $params['group'] = $group; 56 } 57 if ($user !== 0) { 58 $params['user'] = $user; 59 } 60 if ($date !== 0) { 61 $params['date'] = $date; 62 } 63 if ($modid !== 0) { 64 $params['modid'] = $modid; 65 } 66 if ($modaction !== '') { 67 $params['modaction'] = $modaction; 68 } 69 if ($page !== '0') { 70 $params['page'] = $page; 71 } 72 if ($perpage !== '100') { 73 $params['perpage'] = $perpage; 74 } 75 if ($showcourses) { 76 $params['showcourses'] = $showcourses; 77 } 78 if ($showusers) { 79 $params['showusers'] = $showusers; 80 } 81 if ($chooselog) { 82 $params['chooselog'] = $chooselog; 83 } 84 if ($logformat !== '') { 85 $params['download'] = $logformat; 86 } 87 if ($logreader !== '') { 88 $params['logreader'] = $logreader; 89 } 90 if (($edulevel != -1)) { 91 $params['edulevel'] = $edulevel; 92 } 93 if ($origin !== '') { 94 $params['origin'] = $origin; 95 } 96 // Legacy store hack, as edulevel is not supported. 97 if ($logreader == 'logstore_legacy') { 98 $params['edulevel'] = -1; 99 $edulevel = -1; 100 } 101 $url = new moodle_url("/report/log/index.php", $params); 102 103 $PAGE->set_url('/report/log/index.php', array('id' => $id)); 104 $PAGE->set_pagelayout('report'); 105 106 // Get course details. 107 $course = null; 108 if ($id) { 109 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); 110 require_login($course); 111 $context = context_course::instance($course->id); 112 } else { 113 require_login(); 114 $context = context_system::instance(); 115 $PAGE->set_context($context); 116 } 117 118 require_capability('report/log:view', $context); 119 120 // When user choose to view logs then only trigger event. 121 if ($chooselog) { 122 // Trigger a report viewed event. 123 $event = \report_log\event\report_viewed::create(array('context' => $context, 'relateduserid' => $user, 124 'other' => array('groupid' => $group, 'date' => $date, 'modid' => $modid, 'modaction' => $modaction, 125 'logformat' => $logformat))); 126 $event->trigger(); 127 } 128 129 if (!empty($page)) { 130 $strlogs = get_string('logs'). ": ". get_string('page', 'report_log', $page + 1); 131 } else { 132 $strlogs = get_string('logs'); 133 } 134 $stradministration = get_string('administration'); 135 $strreports = get_string('reports'); 136 137 // Before we close session, make sure we have editing information in session. 138 $adminediting = optional_param('adminedit', -1, PARAM_BOOL); 139 if ($PAGE->user_allowed_editing() && $adminediting != -1) { 140 $USER->editing = $adminediting; 141 } 142 143 if (empty($course) || ($course->id == $SITE->id)) { 144 admin_externalpage_setup('reportlog', '', null, '', array('pagelayout' => 'report')); 145 $PAGE->set_title($SITE->shortname .': '. $strlogs); 146 } else { 147 $PAGE->set_title($course->shortname .': '. $strlogs); 148 $PAGE->set_heading($course->fullname); 149 } 150 151 $reportlog = new report_log_renderable($logreader, $course, $user, $modid, $modaction, $group, $edulevel, $showcourses, $showusers, 152 $chooselog, true, $url, $date, $logformat, $page, $perpage, 'timecreated DESC', $origin); 153 $readers = $reportlog->get_readers(); 154 $output = $PAGE->get_renderer('report_log'); 155 156 if (empty($readers)) { 157 echo $output->header(); 158 echo $output->heading(get_string('nologreaderenabled', 'report_log')); 159 } else { 160 if (!empty($chooselog)) { 161 // Delay creation of table, till called by user with filter. 162 $reportlog->setup_table(); 163 164 if (empty($logformat)) { 165 echo $output->header(); 166 $userinfo = get_string('allparticipants'); 167 $dateinfo = get_string('alldays'); 168 169 if ($user) { 170 $u = $DB->get_record('user', array('id' => $user, 'deleted' => 0), '*', MUST_EXIST); 171 $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context)); 172 } 173 if ($date) { 174 $dateinfo = userdate($date, get_string('strftimedaydate')); 175 } 176 if (!empty($course) && ($course->id != SITEID)) { 177 $PAGE->navbar->add("$userinfo, $dateinfo"); 178 } 179 echo $output->render($reportlog); 180 } else { 181 \core\session\manager::write_close(); 182 $reportlog->download(); 183 exit(); 184 } 185 } else { 186 echo $output->header(); 187 echo $output->heading(get_string('chooselogs') .':'); 188 echo $output->render($reportlog); 189 } 190 } 191 192 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body