diff --git a/course/lib.php b/course/lib.php
index f9c4d87d34c..e545270d700 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -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 'wwwroot.'/report/log/graph.php?id='.$course->id.
'&user='.$userid.'&type='.$type.'&date='.$date.'" alt="" />';
}
}
diff --git a/course/report/log/db/access.php b/course/report/log/db/access.php
deleted file mode 100644
index 7a4021becef..00000000000
--- a/course/report/log/db/access.php
+++ /dev/null
@@ -1,68 +0,0 @@
- 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',
- )
-);
-
-
diff --git a/course/report/log/index.php b/course/report/log/index.php
deleted file mode 100644
index 015d17d2db4..00000000000
--- a/course/report/log/index.php
+++ /dev/null
@@ -1,169 +0,0 @@
-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&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction&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;
-
diff --git a/course/report/log/indexlive.php b/course/report/log/indexlive.php
deleted file mode 100644
index 09978b98e84..00000000000
--- a/course/report/log/indexlive.php
+++ /dev/null
@@ -1,44 +0,0 @@
-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();
-
-
diff --git a/course/report/log/live.php b/course/report/log/live.php
deleted file mode 100644
index 30622333a62..00000000000
--- a/course/report/log/live.php
+++ /dev/null
@@ -1,43 +0,0 @@
-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&user=$user&date=$date");
-
- echo $OUTPUT->footer();
-
- exit;
-
-
diff --git a/course/report/log/mod.php b/course/report/log/mod.php
deleted file mode 100644
index 3c278a63be0..00000000000
--- a/course/report/log/mod.php
+++ /dev/null
@@ -1,23 +0,0 @@
-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 '
'; - $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 '
'; - } - diff --git a/course/report/log/version.php b/course/report/log/version.php deleted file mode 100644 index 819c2f13db1..00000000000 --- a/course/report/log/version.php +++ /dev/null @@ -1,29 +0,0 @@ -version = 2010090501; -$plugin->requires = 2010090501; - - diff --git a/report/log/db/access.php b/report/log/db/access.php new file mode 100644 index 00000000000..212af735b74 --- /dev/null +++ b/report/log/db/access.php @@ -0,0 +1,55 @@ +. + +/** + * 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', + ) +); + + diff --git a/course/report/log/lang/en/coursereport_log.php b/report/log/db/install.php similarity index 57% rename from course/report/log/lang/en/coursereport_log.php rename to report/log/db/install.php index 1a59f3f43bd..71e64986134 100644 --- a/course/report/log/lang/en/coursereport_log.php +++ b/report/log/db/install.php @@ -1,5 +1,4 @@ . /** - * 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'); +} + diff --git a/course/report/log/graph.php b/report/log/graph.php similarity index 93% rename from course/report/log/graph.php rename to report/log/graph.php index cf13b2cae97..579baf998f7 100644 --- a/course/report/log/graph.php +++ b/report/log/graph.php @@ -1,5 +1,4 @@ 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) { diff --git a/report/log/index.php b/report/log/index.php new file mode 100644 index 00000000000..3b21a194587 --- /dev/null +++ b/report/log/index.php @@ -0,0 +1,182 @@ +. + +/** + * 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&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction&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; + diff --git a/report/log/lang/en/report_log.php b/report/log/lang/en/report_log.php index 9a447d9202c..a8ae48e0d96 100644 --- a/report/log/lang/en/report_log.php +++ b/report/log/lang/en/report_log.php @@ -15,12 +15,15 @@ // along with Moodle. If not, see