Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
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 use core\report_helper; 26 27 require('../../config.php'); 28 require_once($CFG->dirroot.'/course/lib.php'); 29 require_once($CFG->dirroot.'/report/log/locallib.php'); 30 require_once($CFG->libdir.'/adminlib.php'); 31 require_once($CFG->dirroot.'/lib/tablelib.php'); 32 33 $id = optional_param('id', 0, PARAM_INT);// Course ID. 34 $group = optional_param('group', 0, PARAM_INT); // Group to display. 35 $user = optional_param('user', 0, PARAM_INT); // User to display. 36 $date = optional_param('date', 0, PARAM_INT); // Date to display. 37 $modid = optional_param('modid', 0, PARAM_ALPHANUMEXT); // Module id or 'site_errors'. 38 $modaction = optional_param('modaction', '', PARAM_ALPHAEXT); // An action as recorded in the logs. 39 $page = optional_param('page', '0', PARAM_INT); // Which page to show. 40 $perpage = optional_param('perpage', '100', PARAM_INT); // How many per page. 41 $showcourses = optional_param('showcourses', false, PARAM_BOOL); // Whether to show courses if we're over our limit. 42 $showusers = optional_param('showusers', false, PARAM_BOOL); // Whether to show users if we're over our limit. 43 $chooselog = optional_param('chooselog', false, PARAM_BOOL); 44 $logformat = optional_param('download', '', PARAM_ALPHA); 45 $logreader = optional_param('logreader', '', PARAM_COMPONENT); // Reader which will be used for displaying logs. 46 $edulevel = optional_param('edulevel', -1, PARAM_INT); // Educational level. 47 $origin = optional_param('origin', '', PARAM_TEXT); // Event origin. 48 49 $params = array(); 50 if (!empty($id)) { 51 $params['id'] = $id; 52 } else { 53 $id = $SITE->id; 54 } 55 if ($group !== 0) { 56 $params['group'] = $group; 57 } 58 if ($user !== 0) { 59 $params['user'] = $user; 60 } 61 if ($date !== 0) { 62 $params['date'] = $date; 63 } 64 if ($modid !== 0) { 65 $params['modid'] = $modid; 66 } 67 if ($modaction !== '') { 68 $params['modaction'] = $modaction; 69 } 70 if ($page !== '0') { 71 $params['page'] = $page; 72 } 73 if ($perpage !== '100') { 74 $params['perpage'] = $perpage; 75 } 76 if ($showcourses) { 77 $params['showcourses'] = $showcourses; 78 } 79 if ($showusers) { 80 $params['showusers'] = $showusers; 81 } 82 if ($chooselog) { 83 $params['chooselog'] = $chooselog; 84 } 85 if ($logformat !== '') { 86 $params['download'] = $logformat; 87 } 88 if ($logreader !== '') { 89 $params['logreader'] = $logreader; 90 } 91 if (($edulevel != -1)) { 92 $params['edulevel'] = $edulevel; 93 } 94 if ($origin !== '') { 95 $params['origin'] = $origin; 96 } 97 $url = new moodle_url("/report/log/index.php", $params); 98 99 $PAGE->set_url('/report/log/index.php', array('id' => $id)); 100 $PAGE->set_pagelayout('report'); 101 102 // Get course details. 103 if ($id != $SITE->id) { 104 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); 105 require_login($course); 106 $context = context_course::instance($course->id); 107 } else { 108 $course = $SITE; 109 require_login(); 110 $context = context_system::instance(); 111 $PAGE->set_context($context); 112 } 113 114 require_capability('report/log:view', $context); 115 116 // When user choose to view logs then only trigger event. 117 if ($chooselog) { 118 // Trigger a report viewed event. 119 $event = \report_log\event\report_viewed::create(array('context' => $context, 'relateduserid' => $user, 120 'other' => array('groupid' => $group, 'date' => $date, 'modid' => $modid, 'modaction' => $modaction, 121 'logformat' => $logformat))); 122 $event->trigger(); 123 } 124 125 if (!empty($page)) { 126 $strlogs = get_string('logs'). ": ". get_string('page', 'report_log', $page + 1); 127 } else { 128 $strlogs = get_string('logs'); 129 } 130 $stradministration = get_string('administration'); 131 $strreports = get_string('reports'); 132 133 // Before we close session, make sure we have editing information in session. 134 $adminediting = optional_param('adminedit', -1, PARAM_BOOL); 135 if ($PAGE->user_allowed_editing() && $adminediting != -1) { 136 $USER->editing = $adminediting; 137 } 138 139 if ($course->id == $SITE->id) { 140 admin_externalpage_setup('reportlog', '', null, '', array('pagelayout' => 'report')); 141 $PAGE->set_title($strlogs); 142 $PAGE->set_primary_active_tab('siteadminnode'); 143 } else { 144 $PAGE->set_title($course->shortname .': '. $strlogs); 145 $PAGE->set_heading($course->fullname); 146 } 147 148 $reportlog = new report_log_renderable($logreader, $course, $user, $modid, $modaction, $group, $edulevel, $showcourses, $showusers, 149 $chooselog, true, $url, $date, $logformat, $page, $perpage, 'timecreated DESC', $origin); 150 $readers = $reportlog->get_readers(); 151 $output = $PAGE->get_renderer('report_log'); 152 153 if (empty($readers)) { 154 echo $output->header(); 155 echo $output->heading(get_string('nologreaderenabled', 'report_log')); 156 } else { 157 if (!empty($chooselog)) { 158 // Delay creation of table, till called by user with filter. 159 $reportlog->setup_table(); 160 161 if (empty($logformat)) { 162 echo $output->header(); 163 // Print selector dropdown. 164 $pluginname = get_string('pluginname', 'report_log'); 165 report_helper::print_report_selector($pluginname); 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 // Print selector dropdown. 188 $pluginname = get_string('pluginname', 'report_log'); 189 report_helper::print_report_selector($pluginname); 190 echo $output->heading(get_string('chooselogs') .':', 3); 191 echo $output->render($reportlog); 192 } 193 } 194 195 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body