See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
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 live view of recent logs 19 * 20 * This file generates live view of recent logs. 21 * 22 * @package report_loglive 23 * @copyright 2011 Petr Skoda 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 use core\report_helper; 28 29 require('../../config.php'); 30 require_once($CFG->libdir.'/adminlib.php'); 31 require_once($CFG->dirroot.'/course/lib.php'); 32 33 $id = optional_param('id', 0, PARAM_INT); 34 $page = optional_param('page', 0, PARAM_INT); 35 $logreader = optional_param('logreader', '', PARAM_COMPONENT); // Reader which will be used for displaying logs. 36 37 if (empty($id)) { 38 admin_externalpage_setup('reportloglive', '', null, '', array('pagelayout' => 'report')); 39 $context = context_system::instance(); 40 $coursename = format_string($SITE->fullname, true, array('context' => $context)); 41 } else { 42 $course = get_course($id); 43 require_login($course); 44 $context = context_course::instance($course->id); 45 $coursename = format_string($course->fullname, true, array('context' => $context)); 46 } 47 require_capability('report/loglive:view', $context); 48 49 $params = array(); 50 if ($id != 0) { 51 $params['id'] = $id; 52 } 53 if ($page != 0) { 54 $params['page'] = $page; 55 } 56 if ($logreader !== '') { 57 $params['logreader'] = $logreader; 58 } 59 $url = new moodle_url("/report/loglive/index.php", $params); 60 61 $PAGE->set_url($url); 62 $PAGE->set_pagelayout('report'); 63 64 $renderable = new report_loglive_renderable($logreader, $id, $url, 0, $page); 65 $refresh = $renderable->get_refresh_rate(); 66 $logreader = $renderable->selectedlogreader; 67 68 $strlivelogs = get_string('livelogs', 'report_loglive'); 69 $strupdatesevery = get_string('updatesevery', 'moodle', $refresh); 70 71 72 $PAGE->set_url($url); 73 $PAGE->set_context($context); 74 $PAGE->set_title("$coursename: $strlivelogs"); 75 $PAGE->set_heading($coursename); 76 77 $output = $PAGE->get_renderer('report_loglive'); 78 echo $output->header(); 79 80 // Print selector dropdown. 81 $pluginname = get_string('pluginname', 'report_loglive'); 82 report_helper::print_report_selector($pluginname); 83 echo html_writer::div(get_string('livelogswithupdate', 'report_loglive', $strupdatesevery), 'mb-3'); 84 echo $output->reader_selector($renderable); 85 echo $output->toggle_liveupdate_button($renderable); 86 echo $output->render($renderable); 87 88 // Include and trigger ajax requests. 89 if ($page == 0 && !empty($logreader)) { 90 // Tell Js to fetch new logs only, by passing the latest timestamp of records in the table. 91 $until = $renderable->get_table()->get_until(); 92 $jsparams = array('since' => $until , 'courseid' => $id, 'page' => $page, 'logreader' => $logreader, 93 'interval' => $refresh, 'perpage' => $renderable->perpage); 94 $PAGE->requires->strings_for_js(array('pause', 'resume'), 'report_loglive'); 95 $PAGE->requires->yui_module('moodle-report_loglive-fetchlogs', 'Y.M.report_loglive.FetchLogs.init', array($jsparams)); 96 } 97 98 // Trigger a logs viewed event. 99 $event = \report_loglive\event\report_viewed::create(array('context' => $context)); 100 $event->trigger(); 101 102 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body