Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 report_helper::save_selected_report($id, $url); 65 66 $renderable = new report_loglive_renderable($logreader, $id, $url, 0, $page); 67 $refresh = $renderable->get_refresh_rate(); 68 $logreader = $renderable->selectedlogreader; 69 70 $strlivelogs = get_string('livelogs', 'report_loglive'); 71 $strupdatesevery = get_string('updatesevery', 'moodle', $refresh); 72 73 74 $PAGE->set_url($url); 75 $PAGE->set_context($context); 76 $PAGE->set_title("$coursename: $strlivelogs ($strupdatesevery)"); 77 $PAGE->set_heading("$coursename: $strlivelogs ($strupdatesevery)"); 78 79 $output = $PAGE->get_renderer('report_loglive'); 80 echo $output->header(); 81 82 // Print selector dropdown. 83 $pluginname = get_string('pluginname', 'report_loglive'); 84 report_helper::print_report_selector($pluginname); 85 echo $output->reader_selector($renderable); 86 echo $output->toggle_liveupdate_button($renderable); 87 echo $output->render($renderable); 88 89 // Include and trigger ajax requests. 90 if ($page == 0 && !empty($logreader)) { 91 // Tell Js to fetch new logs only, by passing the latest timestamp of records in the table. 92 $until = $renderable->get_table()->get_until(); 93 $jsparams = array('since' => $until , 'courseid' => $id, 'page' => $page, 'logreader' => $logreader, 94 'interval' => $refresh, 'perpage' => $renderable->perpage); 95 $PAGE->requires->strings_for_js(array('pause', 'resume'), 'report_loglive'); 96 $PAGE->requires->yui_module('moodle-report_loglive-fetchlogs', 'Y.M.report_loglive.FetchLogs.init', array($jsparams)); 97 } 98 99 // Trigger a logs viewed event. 100 $event = \report_loglive\event\report_viewed::create(array('context' => $context)); 101 $event->trigger(); 102 103 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body