MDL-17463 - reparate capabilities for course and admin reports; backported from HEAD
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$report_courseoverview_capabilities = array(
|
||||
|
||||
'report/courseoverview:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_SYSTEM,
|
||||
'legacy' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -12,7 +12,11 @@
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
} else {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
$course = get_site();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('report/courseoverview:view', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
stats_check_uptodate();
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
$courses = get_records_sql($sql, 0, $numcourses);
|
||||
|
||||
if (empty($courses)) {
|
||||
print_error('statsnodata', "", $CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
|
||||
print_error('statsnodata', "", $CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/index.php');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?php // $Id$
|
||||
$ADMIN->add('reports', new admin_externalpage('reportcourseoverview', get_string('courseoverview', 'admin'), "$CFG->wwwroot/$CFG->admin/report/courseoverview/index.php",'moodle/site:viewreports'));
|
||||
$ADMIN->add('reports', new admin_externalpage('reportcourseoverview', get_string('courseoverview', 'admin'), "$CFG->wwwroot/$CFG->admin/report/courseoverview/index.php",'report/courseoverview:view'));
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 = 2007101502;
|
||||
$plugin->requires = 2007101532;
|
||||
|
||||
?>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/course/report/log/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('reportlog');
|
||||
admin_externalpage_print_header();
|
||||
|
||||
|
||||
$course = get_site();
|
||||
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_mnet_log_selector_form($CFG->mnet_localhost_id, $course);
|
||||
|
||||
echo '<br />';
|
||||
print_heading(get_string('chooselivelogs') .':');
|
||||
|
||||
$heading = link_to_popup_window('/course/report/log/live.php?id='. $course->id,
|
||||
'livelog', get_string('livelogs'),
|
||||
500, 800, '', 'none', true);
|
||||
|
||||
print_heading($heading, 'center', 3);
|
||||
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,3 +1,4 @@
|
||||
<?php // $Id$
|
||||
$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/$CFG->admin/report/log/index.php",'moodle/site:viewreports'));
|
||||
// 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'));
|
||||
?>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
$roleid = 0;
|
||||
|
||||
admin_externalpage_setup('reportstats');
|
||||
admin_externalpage_print_header();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
}
|
||||
|
||||
if ($report > 50) {
|
||||
$roleid = substr($report,1);
|
||||
$report = 5;
|
||||
}
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time, '', 3);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
if (!$user = get_record('user','id',$userid)) {
|
||||
error("That's an invalid user id");
|
||||
}
|
||||
}
|
||||
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
}
|
||||
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
// $strreports = get_string("reports");
|
||||
// $strstats = get_string('stats');
|
||||
//
|
||||
// $menu = report_stats_mode_menu($course, $mode, $time); // add 4th $url parameter if uncommented!
|
||||
//
|
||||
//
|
||||
// $crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
// <a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
|
||||
// $strstats";
|
||||
|
||||
// print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
// $crumb, '', '', true, ' ', $menu);
|
||||
|
||||
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
@@ -1,3 +1,4 @@
|
||||
<?php // $Id$
|
||||
$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/$CFG->admin/report/stats/index.php",'moodle/site:viewreports'));
|
||||
// just a link to course report
|
||||
$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/course/report/stats/index.php", 'coursereport/stats:view'));
|
||||
?>
|
||||
@@ -154,7 +154,7 @@ class block_admin extends block_list {
|
||||
}
|
||||
|
||||
/// View course reports
|
||||
if ($course->id !== SITEID and has_capability('moodle/site:viewreports', $context)) {
|
||||
if ($course->id !== SITEID and has_capability('moodle/site:viewreports', $context)) { // basic capability for listing of reports
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/course/report.php?id='.$this->instance->pageid.'">'.get_string('reports').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/stats.gif" class="icon" alt="" />';
|
||||
}
|
||||
|
||||
+1
-1
@@ -758,7 +758,7 @@ function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
|
||||
echo "(".get_string("gdneed").")";
|
||||
} else {
|
||||
// MDL-10818, do not display broken graph when user has no permission to view graph
|
||||
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id)) ||
|
||||
if (has_capability('coursereport/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.
|
||||
'&user='.$userid.'&type='.$type.'&date='.$date.'" alt="" />';
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/site:viewreports', $context);
|
||||
require_capability('moodle/site:viewreports', $context); // basic capability for listing of reports
|
||||
|
||||
$strreports = get_string('reports');
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$coursereport_log_capabilities = array(
|
||||
|
||||
'coursereport/log:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -14,12 +14,13 @@
|
||||
error("Course is misconfigured");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (! (has_capability('moodle/site:viewreports', $context)
|
||||
or ($course->showreports and $USER->id == $user)) ) {
|
||||
error("Sorry, you aren't allowed to see this.");
|
||||
if ($course->showreports and $USER->id == $user and !isguestuser()) {
|
||||
// no cap required to view own graph
|
||||
} else {
|
||||
require_capability('coursereport/log:view', $context);
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
|
||||
@@ -44,11 +44,10 @@
|
||||
$course->fullname = $course_stub->coursename;
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
require_capability('moodle/site:viewreports', $context);
|
||||
require_capability('coursereport/log:view', $context);
|
||||
|
||||
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
|
||||
|
||||
|
||||
@@ -98,7 +98,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('moodle/site:viewreports', $sitecontext) && $showcourses) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
|
||||
if ($ccc = get_records("course", "", "", "fullname","id,fullname,category")) {
|
||||
foreach ($ccc as $cc) {
|
||||
if ($cc->id == SITEID) {
|
||||
@@ -110,7 +110,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
|
||||
$sql = "select distinct course, coursename from {$CFG->prefix}mnet_log where hostid = '$hostid'";
|
||||
if ($ccc = get_records_sql($sql)) {
|
||||
foreach ($ccc as $cc) {
|
||||
@@ -163,7 +163,7 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $sitecontext) && !$course->category) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && !$course->category) {
|
||||
$activities["site_errors"] = get_string("siteerrors");
|
||||
if ($modid === "site_errors") {
|
||||
$selectedactivity = "site_errors";
|
||||
@@ -217,14 +217,14 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
|
||||
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('moodle/site:viewreports', $sitecontext) && $showcourses) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
|
||||
$cid = empty($course->id)? '1' : $course->id;
|
||||
choose_from_menu_nested($dropdown, "host_course", $hostid.'/'.$cid, "");
|
||||
} else {
|
||||
$courses = array();
|
||||
$courses[$course->id] = $course->fullname . ((empty($course->category)) ? ' ('.get_string('site').') ' : '');
|
||||
choose_from_menu($courses,"id",$course->id,false);
|
||||
if (has_capability('moodle/site:viewreports', $sitecontext)) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext)) {
|
||||
$a = new object();
|
||||
$a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
|
||||
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
|
||||
@@ -331,7 +331,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
|
||||
if ($ccc = get_records("course", "", "", "fullname","id,fullname,category")) {
|
||||
foreach ($ccc as $cc) {
|
||||
if ($cc->category) {
|
||||
@@ -378,7 +378,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $sitecontext) && ($course->id == SITEID)) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && ($course->id == SITEID)) {
|
||||
$activities["site_errors"] = get_string("siteerrors");
|
||||
if ($modid === "site_errors") {
|
||||
$selectedactivity = "site_errors";
|
||||
@@ -432,14 +432,14 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate='today'
|
||||
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('moodle/site:viewreports', $sitecontext) && $showcourses) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext) && $showcourses) {
|
||||
choose_from_menu ($courses, "id", $course->id, "");
|
||||
} else {
|
||||
// echo '<input type="hidden" name="id" value="'.$course->id.'" />';
|
||||
$courses = array();
|
||||
$courses[$course->id] = $course->fullname . (($course->id == SITEID) ? ' ('.get_string('site').') ' : '');
|
||||
choose_from_menu($courses,"id",$course->id,false);
|
||||
if (has_capability('moodle/site:viewreports', $sitecontext)) {
|
||||
if (has_capability('coursereport/log:view', $sitecontext)) {
|
||||
$a = new object();
|
||||
$a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
|
||||
."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (!has_capability('moodle/site:viewreports', $context)) {
|
||||
error('You need do not have the required permission to view this report');
|
||||
}
|
||||
require_capability('coursereport/log:view', $context);
|
||||
|
||||
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/course/report/log/lib.php');
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $context)) {
|
||||
if (has_capability('coursereport/log:view', $context)) {
|
||||
print_heading(get_string('chooselogs') .':');
|
||||
|
||||
print_log_selector_form($course);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 = 2007101500;
|
||||
$plugin->requires = 2007101532;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$coursereport_outline_capabilities = array(
|
||||
|
||||
'coursereport/outline:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
require_capability('coursereport/outline:view', get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
|
||||
add_to_log($course->id, 'course', 'report outline', "report/outline/index.php?id=$course->id", $course->id);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $context)) {
|
||||
if (has_capability('coursereport/outline:view', $context)) {
|
||||
echo '<p>';
|
||||
$activityreport = get_string( 'activityreport' );
|
||||
echo "<a href=\"{$CFG->wwwroot}/course/report/outline/index.php?id={$course->id}\">";
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 = 2007101500;
|
||||
$plugin->requires = 2007101532;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$coursereport_participation_capabilities = array(
|
||||
|
||||
'coursereport/participation:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/site:viewreports', $context);
|
||||
require_capability('coursereport/participation:view', $context);
|
||||
|
||||
add_to_log($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->id);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $context)) {
|
||||
if (has_capability('coursereport/participation:view', $context)) {
|
||||
echo '<p>';
|
||||
$participationreport = get_string('participationreport');
|
||||
echo "<a href=\"{$CFG->wwwroot}/course/report/participation/index.php?id={$course->id}\">";
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 = 2007101500;
|
||||
$plugin->requires = 2007101532;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$coursereport_stats_capabilities = array(
|
||||
|
||||
'coursereport/stats:view' => array(
|
||||
'riskbitmask' => RISK_PERSONAL,
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
),
|
||||
|
||||
'clonepermissionsfrom' => 'moodle/site:viewreports',
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -21,12 +21,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
require_login();
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (!has_capability('moodle/site:viewreports', $context)) {
|
||||
error('You need do not have the required permission to view reports for this course');
|
||||
}
|
||||
require_capability('coursereport/stats:view', $context);
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$courseid = optional_param('course', SITEID, PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
@@ -25,7 +22,7 @@
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time);
|
||||
redirect($CFG->wwwroot.'/course/report/stats/index.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
@@ -41,26 +38,38 @@
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
require_capability('moodle/site:viewreports', $context);
|
||||
require_capability('coursereport/stats:view', $context);
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
if ($course->id == SITEID) {
|
||||
admin_externalpage_setup('reportstats');
|
||||
admin_externalpage_print_header();
|
||||
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
} else {
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$menu = report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php");
|
||||
$menu = report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/course/report/stats/index.php");
|
||||
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $strreports, 'link' => "../../report.php?id=$course->id", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strstats, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $strreports, 'link' => "$CFG->wwwroot/course/report.php?id=$course->id", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strstats, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$course->shortname: $strstats", $course->fullname, $navigation, '', '', true, ' ', $menu);
|
||||
print_header("$course->shortname: $strstats", $course->fullname, $navigation, '', '', true, ' ', $menu);
|
||||
}
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
} else {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
require($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* This file is also required by /admin/reports/stats/index.php.
|
||||
*/
|
||||
|
||||
|
||||
require_once('../../../config.php');
|
||||
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
|
||||
@@ -21,7 +20,7 @@
|
||||
$options = array();
|
||||
$options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
|
||||
$options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
|
||||
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$options[STATS_MODE_RANKED] = get_string('reports');
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $context)) {
|
||||
|
||||
if (has_capability('coursereport/stats:view', $context)) {
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<p>';
|
||||
echo '<a href="'.$CFG->wwwroot.'/course/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
foreach ($courses as $c) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $c->id);
|
||||
|
||||
if (has_capability('moodle/site:viewreports', $context)) {
|
||||
if (has_capability('coursereport/stats:view', $context)) {
|
||||
$courseoptions[$c->id] = $c->shortname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 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 = 2007101500;
|
||||
$plugin->requires = 2007101532;
|
||||
|
||||
?>
|
||||
+1
-1
@@ -157,7 +157,7 @@
|
||||
}
|
||||
|
||||
// MDL-10818, do not display broken graph when user has no permission to view graph
|
||||
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $id)) ||
|
||||
if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_COURSE, $id)) ||
|
||||
($course->showreports and $USER->id == $user->id)) {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.STATS_MODE_DETAILED.'&course='.$course->id.'&time='.$time.'&report='.STATS_REPORT_USER_VIEW.'&userid='.$user->id.'" alt="'.get_string('statisticsgraph').'" /></center>';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$string['log:view'] = 'View course logs';
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$string['outline:view'] = 'View course outline report';
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$string['participation:view'] = 'View course participation report';
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$string['stats:view'] = 'View course statistics report';
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$string['courseoverview:view'] = 'View course overview report';
|
||||
|
||||
?>
|
||||
+2
-2
@@ -1375,13 +1375,13 @@ function stats_get_report_options($courseid,$mode) {
|
||||
case STATS_MODE_DETAILED:
|
||||
$reportoptions[STATS_REPORT_USER_ACTIVITY] = get_string('statsreport'.STATS_REPORT_USER_ACTIVITY);
|
||||
$reportoptions[STATS_REPORT_USER_ALLACTIVITY] = get_string('statsreport'.STATS_REPORT_USER_ALLACTIVITY);
|
||||
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$site = get_site();
|
||||
$reportoptions[STATS_REPORT_USER_LOGINS] = get_string('statsreport'.STATS_REPORT_USER_LOGINS);
|
||||
}
|
||||
break;
|
||||
case STATS_MODE_RANKED:
|
||||
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$reportoptions[STATS_REPORT_ACTIVE_COURSES] = get_string('statsreport'.STATS_REPORT_ACTIVE_COURSES);
|
||||
$reportoptions[STATS_REPORT_ACTIVE_COURSES_WEIGHTED] = get_string('statsreport'.STATS_REPORT_ACTIVE_COURSES_WEIGHTED);
|
||||
$reportoptions[STATS_REPORT_PARTICIPATORY_COURSES] = get_string('statsreport'.STATS_REPORT_PARTICIPATORY_COURSES);
|
||||
|
||||
+2
-2
@@ -2527,7 +2527,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
|
||||
} else {
|
||||
$menu .= get_string('failedloginattemptsall', '', $count);
|
||||
}
|
||||
if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$menu .= ' (<a href="'.$CFG->wwwroot.'/course/report/log/index.php'.
|
||||
'?chooselog=1&id=1&modid=site_errors">'.get_string('logs').'</a>)';
|
||||
}
|
||||
@@ -5383,7 +5383,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
|
||||
}
|
||||
//Accessibility: added Alt text, replaced > < with 'silent' character and 'accesshide' text.
|
||||
|
||||
if ($selectmod and has_capability('moodle/site:viewreports', $context)) {
|
||||
if ($selectmod and has_capability('coursereport/log:view', $context)) {
|
||||
$logstext = get_string('alllogs');
|
||||
$logslink = '<li>'."\n".'<a title="'.$logstext.'" '.
|
||||
$CFG->frametarget.'onclick="this.target=\''.$CFG->framename.'\';"'.' href="'.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2007101532.01; // YYYYMMDD = date of the 1.9 branch (don't change)
|
||||
$version = 2007101532.02; // YYYYMMDD = date of the 1.9 branch (don't change)
|
||||
// X = release number 1.9.[0,1,2,3...]
|
||||
// Y.YY = micro-increments between releases
|
||||
|
||||
|
||||
Reference in New Issue
Block a user