MDL-29030 migrate and cleanup log report

AMOS BEGIN
 MOV [log:view,coursereport_log],[log:view,report_log]
 MOV [log:viewtoday,coursereport_log],[log:viewtoday,report_log]
AMOS END
This commit is contained in:
Petr Skoda
2011-11-06 12:22:49 +01:00
parent 8a8f29c2f5
commit 033af4b7ba
16 changed files with 405 additions and 451 deletions
+8 -2
View File
@@ -831,13 +831,19 @@ function print_log_ods($course, $user, $date, $order='l.time DESC', $modname,
function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
global $CFG, $USER;
// note: this is a hack - we should not use plugins from core
if (!file_exists($CFG->dirroot.'/report/log/graph.php')) {
return;
}
if (empty($CFG->gdversion)) {
echo "(".get_string("gdneed").")";
} else {
// MDL-10818, do not display broken graph when user has no permission to view graph
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_COURSE, $course->id)) ||
if (has_capability('report/log:view', get_context_instance(CONTEXT_COURSE, $course->id)) ||
($course->showreports and $USER->id == $userid)) {
echo '<img src="'.$CFG->wwwroot.'/course/report/log/graph.php?id='.$course->id.
echo '<img src="'.$CFG->wwwroot.'/report/log/graph.php?id='.$course->id.
'&amp;user='.$userid.'&amp;type='.$type.'&amp;date='.$date.'" alt="" />';
}
}
-68
View File
@@ -1,68 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
$capabilities = array(
'coursereport/log:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:viewreports',
),
'coursereport/log:viewlive' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:viewreports',
),
'coursereport/log:viewtoday' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:viewreports',
)
);
-169
View File
@@ -1,169 +0,0 @@
<?php
// Displays different views of the logs.
require_once('../../../config.php');
require_once('../../lib.php');
require_once('lib.php');
require_once($CFG->libdir.'/adminlib.php');
$id = optional_param('id', 0, PARAM_INT);// Course ID
$host_course = optional_param('host_course', '', PARAM_PATH);// Course ID
if (empty($host_course)) {
$hostid = $CFG->mnet_localhost_id;
if (empty($id)) {
$site = get_site();
$id = $site->id;
}
} else {
list($hostid, $id) = explode('/', $host_course);
}
$group = optional_param('group', 0, PARAM_INT); // Group to display
$user = optional_param('user', 0, PARAM_INT); // User to display
$date = optional_param('date', 0, PARAM_FILE); // Date to display - number or some string
$modname = optional_param('modname', '', PARAM_PLUGIN); // course_module->id
$modid = optional_param('modid', 0, PARAM_FILE); // number or 'site_errors'
$modaction = optional_param('modaction', '', PARAM_PATH); // an action as recorded in the logs
$page = optional_param('page', '0', PARAM_INT); // which page to show
$perpage = optional_param('perpage', '100', PARAM_INT); // how many per page
$showcourses = optional_param('showcourses', 0, PARAM_INT); // whether to show courses if we're over our limit.
$showusers = optional_param('showusers', 0, PARAM_INT); // whether to show users if we're over our limit.
$chooselog = optional_param('chooselog', 0, PARAM_INT);
$logformat = optional_param('logformat', 'showashtml', PARAM_ALPHA);
$params = array();
if ($id !== 0) $params['id'] = $id;
if ($host_course !== '') $params['host_course'] = $host_course;
if ($group !== 0) $params['group'] = $group;
if ($user !== 0) $params['user'] = $user;
if ($date !== 0) $params['date'] = $date;
if ($modname !== '') $params['modname'] = $modname;
if ($modid !== 0) $params['modid'] = $modid;
if ($modaction !== '') $params['modaction'] = $modaction;
if ($page !== '0') $params['page'] = $page;
if ($perpage !== '100') $params['perpage'] = $perpage;
if ($showcourses !== 0) $params['showcourses'] = $showcourses;
if ($showusers !== 0) $params['showusers'] = $showusers;
if ($chooselog !== 0) $params['chooselog'] = $chooselog;
if ($logformat !== 'showashtml') $params['logformat'] = $logformat;
$PAGE->set_url('/course/report/log/index.php', $params);
$PAGE->set_pagelayout('report');
if ($hostid == $CFG->mnet_localhost_id) {
if (!$course = $DB->get_record('course', array('id'=>$id))) {
print_error('That\'s an invalid course id'.$id);
}
} else {
$course_stub = $DB->get_record('mnet_log', array('hostid'=>$hostid, 'course'=>$id), '*', true);
$course->id = $id;
$course->shortname = $course_stub->coursename;
$course->fullname = $course_stub->coursename;
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('coursereport/log:view', $context);
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
$strlogs = get_string('logs');
$stradministration = get_string('administration');
$strreports = get_string('reports');
session_get_instance()->write_close();
$navlinks = array();
if (!empty($chooselog)) {
$userinfo = get_string('allparticipants');
$dateinfo = get_string('alldays');
if ($user) {
if (!$u = $DB->get_record('user', array('id'=>$user))) {
print_error('That\'s an invalid user!');
}
$userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
}
if ($date) {
$dateinfo = userdate($date, get_string('strftimedaydate'));
}
switch ($logformat) {
case 'showashtml':
if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)));
$PAGE->navbar->add($strlogs, new moodle_url('/course/report/log/index.php', array('id'=>$course->id)));
$PAGE->navbar->add("$userinfo, $dateinfo");
echo $OUTPUT->header();
}
echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo, $dateinfo (".usertimezone().")");
print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
if($hostid == $CFG->mnet_localhost_id) {
print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
"index.php?id=$course->id&amp;chooselog=1&amp;user=$user&amp;date=$date&amp;modid=$modid&amp;modaction=$modaction&amp;group=$group",
$modname, $modid, $modaction, $group);
} else {
print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
}
break;
case 'downloadascsv':
if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
$modid, $modaction, $group)) {
echo $OUTPUT->notification("No logs found!");
echo $OUTPUT->footer();
}
exit;
case 'downloadasods':
if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname,
$modid, $modaction, $group)) {
echo $OUTPUT->notification("No logs found!");
echo $OUTPUT->footer();
}
exit;
case 'downloadasexcel':
if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname,
$modid, $modaction, $group)) {
echo $OUTPUT->notification("No logs found!");
echo $OUTPUT->footer();
}
exit;
}
} else {
if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
}
echo $OUTPUT->heading(get_string('chooselogs') .':');
print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
$livelogs = get_string('livelogs');
$url = new moodle_url('/course/report/log/live.php', array('id'=>$course->id));
$link = new action_link($url, $livelogs, new popup_action('click', $url, 'livelog', array('height' => 500, 'width' => 800)));
echo $OUTPUT->render($link);
}
echo $OUTPUT->footer();
exit;
-44
View File
@@ -1,44 +0,0 @@
<?php
// Display link to live logs in separate window
require_once('../../../config.php');
require_once('../../lib.php');
require_once('lib.php');
require_once($CFG->libdir.'/adminlib.php');
$id = optional_param('id', 0, PARAM_INT);// Course ID
if (!$course = $DB->get_record('course', array('id'=>$id)) ) {
print_error('invalidcourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('coursereport/log:viewlive', $context);
$strlogs = get_string('logs');
$strreports = get_string('reports');
if ($course->id == SITEID) {
admin_externalpage_setup('reportloglive');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strreports, new moodle_url('/course/report.php', array('id'=>$course->id)), navigation_node::TYPE_CUSTOM);
$PAGE->navbar->add($strlogs);
echo $OUTPUT->header();
}
echo $OUTPUT->heading(get_string('loglive', 'coursereport_log'));
echo $OUTPUT->container_start('info');
$link = new moodle_url('/course/report/log/live.php?id='. $course->id);
echo $OUTPUT->action_link($link, get_string('livelogs'), new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
-43
View File
@@ -1,43 +0,0 @@
<?php
// Displays live view of recent logs
require_once("../../../config.php");
require_once("../../lib.php");
$id = required_param('id', PARAM_INT);
$page = optional_param('page', 0, PARAM_INT); // which page to show
if (! $course = $DB->get_record("course", array("id"=>$id))) {
print_error('invalidcourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('coursereport/log:viewlive', $context);
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
session_get_instance()->write_close();
$strlivelogs = get_string("livelogs");
$strupdatesevery = get_string("updatesevery", "moodle", COURSE_LIVELOG_REFRESH);
$PAGE->set_url('/course/report/log/live.php', array('id'=>$course->id));
$PAGE->set_pagelayout('popup');
$PAGE->set_title("$strlivelogs ($strupdatesevery)");
$PAGE->set_periodic_refresh_delay(COURSE_LIVELOG_REFRESH);
$PAGE->set_heading($strlivelogs);
echo $OUTPUT->header();
$user=0;
$date=time() - 3600;
print_log($course, $user, $date, "l.time DESC", $page, 500,
"live.php?id=$course->id&amp;user=$user&amp;date=$date");
echo $OUTPUT->footer();
exit;
-23
View File
@@ -1,23 +0,0 @@
<?php
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/course/report/log/lib.php');
if (has_capability('coursereport/log:view', $context)) {
echo $OUTPUT->heading(get_string('chooselogs') .':');
print_log_selector_form($course);
}
if (has_capability('coursereport/log:viewlive', $context)) {
echo $OUTPUT->heading(get_string('chooselivelogs') .':');
echo '<p>';
$link = new moodle_url('/course/report/log/live.php?id='. $course->id);
echo $OUTPUT->action_link($link, get_string('livelogs'), new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
echo '</p>';
}
-29
View File
@@ -1,29 +0,0 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
$plugin->version = 2010090501;
$plugin->requires = 2010090501;
+55
View File
@@ -0,0 +1,55 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capabilities
*
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'report/log:view' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'coursereport/log:view',
),
'report/log:viewtoday' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'coursereport/log:viewtoday',
)
);
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -16,16 +15,19 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'coursereport_log', language 'en', branch 'MOODLE_20_STABLE'
* Post installation and migration code.
*
* @package coursereport_log
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package report
* @subpackage log
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['loglive'] = 'Live logs';
$string['log:view'] = 'View course logs';
$string['log:viewlive'] = 'View live logs';
$string['log:viewtoday'] = 'View today\'s logs';
$string['pluginpagetype'] = 'Logs course report';
$string['pluginname'] = 'Logs';
defined('MOODLE_INTERNAL') || die;
function xmldb_report_log_install() {
// this is a hack which is needed for cleanup of original coursereport_log stuff
unset_all_config_for_plugin('coursereport_log');
capabilities_cleanup('coursereport_log');
}
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -18,13 +17,14 @@
/**
* Produces a graph of log accesses
*
* @copyright 1999 Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package course
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../../config.php");
require_once("../../lib.php");
require("../../config.php");
require_once("$CFG->dirroot/course/lib.php");
require_once("$CFG->libdir/graphlib.php");
$id = required_param('id', PARAM_INT); // Course ID
@@ -32,7 +32,7 @@ $type = required_param('type', PARAM_FILE); // Graph Type
$user = optional_param('user', 0, PARAM_INT); // Student ID
$date = optional_param('date', 0, PARAM_INT); // A time of a day (in GMT)
$url = new moodle_url('/course/report/log/graph.php', array('id'=>$id,'type'=>$type));
$url = new moodle_url('/report/log/graph.php', array('id'=>$id,'type'=>$type));
if ($user !== 0) {
$url->param('user', $user);
}
@@ -49,7 +49,7 @@ require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!$course->showreports or $USER->id != $user) {
require_capability('coursereport/log:view', $context);
require_capability('report/log:view', $context);
}
if ($user) {
+182
View File
@@ -0,0 +1,182 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Displays different views of the logs.
*
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/report/log/locallib.php');
require_once($CFG->libdir.'/adminlib.php');
$id = optional_param('id', 0, PARAM_INT);// Course ID
$host_course = optional_param('host_course', '', PARAM_PATH);// Course ID
if (empty($host_course)) {
$hostid = $CFG->mnet_localhost_id;
if (empty($id)) {
$site = get_site();
$id = $site->id;
}
} else {
list($hostid, $id) = explode('/', $host_course);
}
$group = optional_param('group', 0, PARAM_INT); // Group to display
$user = optional_param('user', 0, PARAM_INT); // User to display
$date = optional_param('date', 0, PARAM_FILE); // Date to display - number or some string
$modname = optional_param('modname', '', PARAM_PLUGIN); // course_module->id
$modid = optional_param('modid', 0, PARAM_FILE); // number or 'site_errors'
$modaction = optional_param('modaction', '', PARAM_PATH); // an action as recorded in the logs
$page = optional_param('page', '0', PARAM_INT); // which page to show
$perpage = optional_param('perpage', '100', PARAM_INT); // how many per page
$showcourses = optional_param('showcourses', 0, PARAM_INT); // whether to show courses if we're over our limit.
$showusers = optional_param('showusers', 0, PARAM_INT); // whether to show users if we're over our limit.
$chooselog = optional_param('chooselog', 0, PARAM_INT);
$logformat = optional_param('logformat', 'showashtml', PARAM_ALPHA);
$params = array();
if ($id !== 0) $params['id'] = $id;
if ($host_course !== '') $params['host_course'] = $host_course;
if ($group !== 0) $params['group'] = $group;
if ($user !== 0) $params['user'] = $user;
if ($date !== 0) $params['date'] = $date;
if ($modname !== '') $params['modname'] = $modname;
if ($modid !== 0) $params['modid'] = $modid;
if ($modaction !== '') $params['modaction'] = $modaction;
if ($page !== '0') $params['page'] = $page;
if ($perpage !== '100') $params['perpage'] = $perpage;
if ($showcourses !== 0) $params['showcourses'] = $showcourses;
if ($showusers !== 0) $params['showusers'] = $showusers;
if ($chooselog !== 0) $params['chooselog'] = $chooselog;
if ($logformat !== 'showashtml') $params['logformat'] = $logformat;
$PAGE->set_url('/report/log/index.php', $params);
$PAGE->set_pagelayout('report');
if ($hostid == $CFG->mnet_localhost_id) {
if (!$course = $DB->get_record('course', array('id'=>$id))) {
print_error('That\'s an invalid course id'.$id);
}
} else {
$course_stub = $DB->get_record('mnet_log', array('hostid'=>$hostid, 'course'=>$id), '*', true);
$course->id = $id;
$course->shortname = $course_stub->coursename;
$course->fullname = $course_stub->coursename;
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('report/log:view', $context);
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
$strlogs = get_string('logs');
$stradministration = get_string('administration');
$strreports = get_string('reports');
session_get_instance()->write_close();
$navlinks = array();
if (!empty($chooselog)) {
$userinfo = get_string('allparticipants');
$dateinfo = get_string('alldays');
if ($user) {
if (!$u = $DB->get_record('user', array('id'=>$user))) {
print_error('That\'s an invalid user!');
}
$userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
}
if ($date) {
$dateinfo = userdate($date, get_string('strftimedaydate'));
}
switch ($logformat) {
case 'showashtml':
if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add("$userinfo, $dateinfo");
echo $OUTPUT->header();
}
echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo, $dateinfo (".usertimezone().")");
print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
if($hostid == $CFG->mnet_localhost_id) {
print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
"index.php?id=$course->id&amp;chooselog=1&amp;user=$user&amp;date=$date&amp;modid=$modid&amp;modaction=$modaction&amp;group=$group",
$modname, $modid, $modaction, $group);
} else {
print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
}
break;
case 'downloadascsv':
if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
$modid, $modaction, $group)) {
echo $OUTPUT->notification("No logs found!");
echo $OUTPUT->footer();
}
exit;
case 'downloadasods':
if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname,
$modid, $modaction, $group)) {
echo $OUTPUT->notification("No logs found!");
echo $OUTPUT->footer();
}
exit;
case 'downloadasexcel':
if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname,
$modid, $modaction, $group)) {
echo $OUTPUT->notification("No logs found!");
echo $OUTPUT->footer();
}
exit;
}
} else {
if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
admin_externalpage_setup('reportlog');
echo $OUTPUT->header();
} else {
$PAGE->set_title($course->shortname .': '. $strlogs);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
}
echo $OUTPUT->heading(get_string('chooselogs') .':');
print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
}
echo $OUTPUT->footer();
exit;
+5 -2
View File
@@ -15,12 +15,15 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'report_log'
* Lang strings.
*
* @package report
* @subpackage log
* @copyright 2011 Petr Skoda (http://skodak.org)
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['log:view'] = 'View course logs';
$string['log:viewtoday'] = 'View today\'s logs';
$string['pluginpagetype'] = 'Logs course report';
$string['pluginname'] = 'Logs';
+57
View File
@@ -0,0 +1,57 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Libs
*
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
/**
* This function extends the navigation with the report items
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $course The course to object for the report
* @param stdClass $context The context of the course
*/
function report_log_extend_navigation_course($navigation, $course, $context) {
global $CFG, $OUTPUT;
if (has_capability('report/log:view', $context)) {
$url = new moodle_url('/report/log/index.php', array('id'=>$course->id));
$navigation->add(get_string('pluginname', 'report_log'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
}
}
/**
* Return a list of page types
* @param string $pagetype current page type
* @param stdClass $parentcontext Block's parent context
* @param stdClass $currentcontext Current context of block
* @return array
*/
function report_log_page_type_list($pagetype, $parentcontext, $currentcontext) {
$array = array(
'*' => get_string('page-x', 'pagetype'),
'course-report-*' => get_string('page-course-report-x', 'pagetype'),
'course-report-log-index' => get_string('pluginpagetype', 'report_log')
);
return $array;
}
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -18,11 +17,16 @@
/**
* This file contains functions used by the log reports
*
* @package course
* @copyright 1999 onwards Martin Dougiamas http://moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
require_once(dirname(__FILE__).'/lib.php');
function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $selecteddate='today',
$modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
@@ -134,7 +138,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
$courses = array();
$sites = array();
if ($CFG->mnet_localhost_id == $hostid) {
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
if ($ccc = $DB->get_records("course", null, "fullname","id,fullname,category")) {
foreach ($ccc as $cc) {
if ($cc->id == SITEID) {
@@ -146,7 +150,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
}
}
} else {
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
$sql = "SELECT DISTINCT course, coursename FROM {mnet_log} where hostid = ?";
if ($ccc = $DB->get_records_sql($sql, array($hostid))) {
foreach ($ccc as $cc) {
@@ -195,7 +199,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
}
}
if (has_capability('coursereport/log:view', $sitecontext) && !$course->category) {
if (has_capability('report/log:view', $sitecontext) && !$course->category) {
$activities["site_errors"] = get_string("siteerrors");
if ($modid === "site_errors") {
$selectedactivity = "site_errors";
@@ -244,21 +248,21 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
$selecteddate = $today;
}
echo "<form class=\"logselectform\" action=\"$CFG->wwwroot/course/report/log/index.php\" method=\"get\">\n";
echo "<form class=\"logselectform\" action=\"$CFG->wwwroot/report/log/index.php\" method=\"get\">\n";
echo "<div>\n";//invisible fieldset here breaks wrapping
echo "<input type=\"hidden\" name=\"chooselog\" value=\"1\" />\n";
echo "<input type=\"hidden\" name=\"showusers\" value=\"$showusers\" />\n";
echo "<input type=\"hidden\" name=\"showcourses\" value=\"$showcourses\" />\n";
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
$cid = empty($course->id)? '1' : $course->id;
echo html_writer::select($dropdown, "host_course", $hostid.'/'.$cid);
} else {
$courses = array();
$courses[$course->id] = $course->fullname . ((empty($course->category)) ? ' ('.get_string('site').') ' : '');
echo html_writer::select($courses,"id",$course->id, false);
if (has_capability('coursereport/log:view', $sitecontext)) {
if (has_capability('report/log:view', $sitecontext)) {
$a = new stdClass();
$a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
print_string('logtoomanycourses','moodle',$a);
}
@@ -289,7 +293,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
$users[0] = get_string('allparticipants');
}
echo html_writer::select($users, "user", $selecteduser, false);
$a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showusers=1&showcourses=$showcourses";
print_string('logtoomanyusers','moodle',$a);
}
@@ -365,7 +369,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
$users[$CFG->siteguest] = get_string('guestuser');
}
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
if ($ccc = $DB->get_records("course", null, "fullname", "id,fullname,category")) {
foreach ($ccc as $cc) {
if ($cc->category) {
@@ -408,7 +412,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
}
}
if (has_capability('coursereport/log:view', $sitecontext) && ($course->id == SITEID)) {
if (has_capability('report/log:view', $sitecontext) && ($course->id == SITEID)) {
$activities["site_errors"] = get_string("siteerrors");
if ($modid === "site_errors") {
$selectedactivity = "site_errors";
@@ -457,21 +461,21 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
$selecteddate = $today;
}
echo "<form class=\"logselectform\" action=\"$CFG->wwwroot/course/report/log/index.php\" method=\"get\">\n";
echo "<form class=\"logselectform\" action=\"$CFG->wwwroot/report/log/index.php\" method=\"get\">\n";
echo "<div>\n";
echo "<input type=\"hidden\" name=\"chooselog\" value=\"1\" />\n";
echo "<input type=\"hidden\" name=\"showusers\" value=\"$showusers\" />\n";
echo "<input type=\"hidden\" name=\"showcourses\" value=\"$showcourses\" />\n";
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
if (has_capability('report/log:view', $sitecontext) && $showcourses) {
echo html_writer::select($courses, "id", $course->id, false);
} else {
// echo '<input type="hidden" name="id" value="'.$course->id.'" />';
$courses = array();
$courses[$course->id] = $course->fullname . (($course->id == SITEID) ? ' ('.get_string('site').') ' : '');
echo html_writer::select($courses,"id",$course->id, false);
if (has_capability('coursereport/log:view', $sitecontext)) {
if (has_capability('report/log:view', $sitecontext)) {
$a = new stdClass();
$a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
print_string('logtoomanycourses','moodle',$a);
}
@@ -503,7 +507,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
}
echo html_writer::select($users, "user", $selecteduser, false);
$a = new stdClass();
$a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
$a->url = "$CFG->wwwroot/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showusers=1&showcourses=$showcourses";
print_string('logtoomanyusers','moodle',$a);
}
@@ -522,34 +526,3 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
echo '</div>';
echo '</form>';
}
/**
* This function extends the navigation with the report items
*
* @param navigation_node $navigation The navigation node to extend
* @param stdClass $course The course to object for the report
* @param stdClass $context The context of the course
*/
function log_report_extend_navigation($navigation, $course, $context) {
global $CFG, $OUTPUT;
if (has_capability('coursereport/log:view', $context)) {
$url = new moodle_url('/course/report/log/index.php', array('id'=>$course->id));
$navigation->add(get_string('pluginname', 'coursereport_log'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
}
}
/**
* Return a list of page types
* @param string $pagetype current page type
* @param stdClass $parentcontext Block's parent context
* @param stdClass $currentcontext Current context of block
*/
function log_page_type_list($pagetype, $parentcontext, $currentcontext) {
$array = array(
'*' => get_string('page-x', 'pagetype'),
'course-report-*' => get_string('page-course-report-x', 'pagetype'),
'course-report-log-index' => get_string('pluginpagetype', 'coursereport_log')
//course-report-log-live not included as theres no blocks on the live log page
);
return $array;
}
+24 -2
View File
@@ -1,10 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Links and settings
*
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
// just a link to course report
$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/course/report/log/index.php?id=".SITEID, 'coursereport/log:view'));
$ADMIN->add('reports', new admin_externalpage('reportloglive', get_string('loglive', 'coursereport_log'), "$CFG->wwwroot/course/report/log/indexlive.php?id=".SITEID, 'coursereport/log:viewlive'));
$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/report/log/index.php?id=".SITEID, 'report/log:view'));
// no report settings
$settings = null;
+30
View File
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version info
*
* @package report
* @subpackage log
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2011110202; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011102700.01; // Requires this Moodle version
$plugin->component = 'report_log'; // Full name of the plugin (used for diagnostics)