mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-29030 new loglive report plugin
AMOS BEGIN CPY [log:viewlive,coursereport_log,[loglive:view,report_loglive] MOV [livelogs,core],[livelogs,report_loglive] CPY [loglive,coursereport_log],[pluginname,report_loglive] AMOS END
This commit is contained in:
parent
e20de26278
commit
8a8f29c2f5
@ -31,7 +31,6 @@ require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
define('COURSE_MAX_LOG_DISPLAY', 150); // days
|
||||
define('COURSE_MAX_LOGS_PER_PAGE', 1000); // records
|
||||
define('COURSE_LIVELOG_REFRESH', 60); // Seconds
|
||||
define('COURSE_MAX_RECENT_PERIOD', 172800); // Two days, in seconds
|
||||
define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); // courses
|
||||
define('COURSE_MAX_COURSES_PER_DROPDOWN',1000); // max courses in log dropdown before switching to optional
|
||||
|
@ -902,7 +902,6 @@ $string['liketologin'] = 'Would you like to log in now with a full user account?
|
||||
$string['list'] = 'List';
|
||||
$string['listfiles'] = 'List of files in {$a}';
|
||||
$string['listofallpeople'] = 'List of all people';
|
||||
$string['livelogs'] = 'Live logs from the past hour';
|
||||
$string['local'] = 'Local';
|
||||
$string['localplugindeleteconfirm'] = 'You are about to completely delete the local plugin \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?';
|
||||
$string['localplugins'] = 'Local plugins';
|
||||
|
@ -304,7 +304,7 @@ class plugin_manager {
|
||||
),
|
||||
|
||||
'coursereport' => array(
|
||||
'log', 'stats'
|
||||
'stats'
|
||||
),
|
||||
|
||||
'datafield' => array(
|
||||
@ -407,7 +407,7 @@ class plugin_manager {
|
||||
|
||||
'report' => array(
|
||||
'backups', 'completion', 'configlog', 'courseoverview',
|
||||
'log', 'outline', 'participation', 'progress', 'questioninstances', 'security', 'stats'
|
||||
'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances', 'security', 'stats'
|
||||
),
|
||||
|
||||
'repository' => array(
|
||||
|
40
report/loglive/db/access.php
Normal file
40
report/loglive/db/access.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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 loglive
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'report/loglive:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
92
report/loglive/index.php
Normal file
92
report/loglive/index.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?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 live view of recent logs
|
||||
*
|
||||
* @package report
|
||||
* @subpackage loglive
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
if (!defined('REPORT_LOGLIVE_REFRESH')) {
|
||||
define('REPORT_LOGLIVE_REFRESH', 60); // Seconds
|
||||
}
|
||||
|
||||
$id = optional_param('id', $SITE->id, PARAM_INT);
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$inpopup = optional_param('inpopup', 0, PARAM_BOOL);
|
||||
|
||||
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
|
||||
|
||||
require_login($course);
|
||||
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('report/loglive:view', $context);
|
||||
|
||||
$strlivelogs = get_string('livelogs', 'report_loglive');
|
||||
|
||||
if ($inpopup) {
|
||||
session_get_instance()->write_close();
|
||||
|
||||
add_to_log($course->id, 'course', 'report live', "report/loglive/index.php?id=$course->id", $course->id);
|
||||
|
||||
$date = time() - 3600;
|
||||
|
||||
$url = new moodle_url('/report/loglive/index.php', array('id'=>$course->id, 'user'=>0, 'date'=>$date, 'inpopup'=>1));
|
||||
|
||||
$strupdatesevery = get_string('updatesevery', 'moodle', REPORT_LOGLIVE_REFRESH);
|
||||
|
||||
$coursename = format_string($course->fullname, true, array('context'=>$context));
|
||||
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title("$coursename: $strlivelogs ($strupdatesevery)");
|
||||
$PAGE->set_periodic_refresh_delay(REPORT_LOGLIVE_REFRESH);
|
||||
$PAGE->set_heading($strlivelogs);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
print_log($course, 0, $date, "l.time DESC", $page, 500, $url);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if ($course->id == SITEID) {
|
||||
admin_externalpage_setup('reportloglive');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
} else {
|
||||
$PAGE->set_url('/report/log/live.php', array('id'=>$course->id));
|
||||
$PAGE->set_title($course->shortname .': '. $strlogs);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('pluginname', 'report_loglive'));
|
||||
|
||||
echo $OUTPUT->container_start('info');
|
||||
$link = new moodle_url('/report/loglive/index.php', array('id'=>$course->id, 'inpopup'=>1));
|
||||
echo $OUTPUT->action_link($link, $strlivelogs, new popup_action('click', $link, 'livelog', array('height' => 500, 'width' => 800)));
|
||||
echo $OUTPUT->container_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
28
report/loglive/lang/en/report_loglive.php
Normal file
28
report/loglive/lang/en/report_loglive.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Lang strings.
|
||||
*
|
||||
* @package report
|
||||
* @subpackage loglive
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['loglive:view'] = 'View live logs';
|
||||
$string['pluginname'] = 'Live logs';
|
||||
$string['livelogs'] = 'Live logs from the past hour';
|
44
report/loglive/lib.php
Normal file
44
report/loglive/lib.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?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, public API.
|
||||
*
|
||||
* NOTE: page type not included because there can not be any blocks in popups
|
||||
*
|
||||
* @package report
|
||||
* @subpackage loglive
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @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_loglive_extend_navigation_course($navigation, $course, $context) {
|
||||
global $CFG, $OUTPUT;
|
||||
if (has_capability('report/loglive:view', $context)) {
|
||||
$url = new moodle_url('/report/loglive/index.php', array('id'=>$course->id, 'inpopup'=>1));
|
||||
$action = new action_link($url, get_string('pluginname', 'report_loglive'), new popup_action('click', $url));
|
||||
$navigation->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
}
|
||||
}
|
32
report/loglive/settings.php
Normal file
32
report/loglive/settings.php
Normal file
@ -0,0 +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 loglive
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @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('reportloglive', get_string('pluginname', 'report_loglive'), "$CFG->wwwroot/report/loglive/index.php", 'report/loglive:view'));
|
||||
|
||||
// no report settings
|
||||
$settings = null;
|
30
report/loglive/version.php
Normal file
30
report/loglive/version.php
Normal 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 loglive
|
||||
* @copyright 2011 Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2011110200; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2011102700.01; // Requires this Moodle version
|
||||
$plugin->component = 'report_loglive'; // Full name of the plugin (used for diagnostics)
|
Loading…
x
Reference in New Issue
Block a user