[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 46 $params = array(); 47 if (!empty($id)) { 48 $params['id'] = $id; 49 } else { 50 $site = get_site(); 51 $id = $site->id; 52 } 53 if ($group !== 0) { 54 $params['group'] = $group; 55 } 56 if ($user !== 0) { 57 $params['user'] = $user; 58 } 59 if ($date !== 0) { 60 $params['date'] = $date; 61 } 62 if ($modid !== 0) { 63 $params['modid'] = $modid; 64 } 65 if ($modaction !== '') { 66 $params['modaction'] = $modaction; 67 } 68 if ($page !== '0') { 69 $params['page'] = $page; 70 } 71 if ($perpage !== '100') { 72 $params['perpage'] = $perpage; 73 } 74 if ($showcourses) { 75 $params['showcourses'] = $showcourses; 76 } 77 if ($showusers) { 78 $params['showusers'] = $showusers; 79 } 80 if ($chooselog) { 81 $params['chooselog'] = $chooselog; 82 } 83 if ($logformat !== '') { 84 $params['download'] = $logformat; 85 } 86 if ($logreader !== '') { 87 $params['logreader'] = $logreader; 88 } 89 if (($edulevel != -1)) { 90 $params['edulevel'] = $edulevel; 91 } 92 93 // Legacy store hack, as edulevel is not supported. 94 if ($logreader == 'logstore_legacy') { 95 $params['edulevel'] = -1; 96 $edulevel = -1; 97 } 98 $url = new moodle_url("/report/log/index.php", $params); 99 100 $PAGE->set_url('/report/log/index.php', array('id' => $id)); 101 $PAGE->set_pagelayout('report'); 102 103 // Get course details. 104 $course = null; 105 if ($id) { 106 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); 107 require_login($course); 108 $context = context_course::instance($course->id); 109 } else { 110 require_login(); 111 $context = context_system::instance(); 112 $PAGE->set_context($context); 113 } 114 115 require_capability('report/log:view', $context); 116 117 // When user choose to view logs then only trigger event. 118 if ($chooselog) { 119 // Trigger a report viewed event. 120 $event = \report_log\event\report_viewed::create(array('context' => $context, 'relateduserid' => $user, 121 'other' => array('groupid' => $group, 'date' => $date, 'modid' => $modid, 'modaction' => $modaction, 122 'logformat' => $logformat))); 123 $event->trigger(); 124 } 125 126 if (!empty($page)) { 127 $strlogs = get_string('logs'). ": ". get_string('page', 'report_log', $page + 1); 128 } else { 129 $strlogs = get_string('logs'); 130 } 131 $stradministration = get_string('administration'); 132 $strreports = get_string('reports'); 133 134 // Before we close session, make sure we have editing information in session. 135 $adminediting = optional_param('adminedit', -1, PARAM_BOOL); 136 if ($PAGE->user_allowed_editing() && $adminediting != -1) { 137 $USER->editing = $adminediting; 138 } 139 140 if (empty($course) || ($course->id == $SITE->id)) { 141 admin_externalpage_setup('reportlog', '', null, '', array('pagelayout' => 'report')); 142 $PAGE->set_title($SITE->shortname .': '. $strlogs); 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'); 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 $userinfo = get_string('allparticipants'); 164 $dateinfo = get_string('alldays'); 165 166 if ($user) { 167 $u = $DB->get_record('user', array('id' => $user, 'deleted' => 0), '*', MUST_EXIST); 168 $userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context)); 169 } 170 if ($date) { 171 $dateinfo = userdate($date, get_string('strftimedaydate')); 172 } 173 if (!empty($course) && ($course->id != SITEID)) { 174 $PAGE->navbar->add("$userinfo, $dateinfo"); 175 } 176 echo $output->render($reportlog); 177 } else { 178 \core\session\manager::write_close(); 179 $reportlog->download(); 180 exit(); 181 } 182 } else { 183 echo $output->header(); 184 echo $output->heading(get_string('chooselogs') .':'); 185 echo $output->render($reportlog); 186 } 187 } 188 189 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |