MDL-29030 fix remaining report linking hacks
Please note all plugin references from core should use callbacks, it is not ok to use capabilities or links to plugins because they may not be present in customised installs.
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ $strmnetlog = get_string('mnetlog', 'mnet');
|
||||
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
|
||||
|
||||
$logurl = $CFG->wwwroot.
|
||||
'/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id.
|
||||
'%2F1&user='.'0'.
|
||||
'&date=0'.
|
||||
'&modid=&modaction=0&logformat=showashtml';
|
||||
|
||||
+17
-16
@@ -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
|
||||
@@ -70,29 +69,31 @@ if ($user->deleted) {
|
||||
die;
|
||||
}
|
||||
|
||||
//TODO: all this is a hack - we can not link to plugins like this - all this must be abstracted to plugin callbacks!
|
||||
|
||||
// prepare list of allowed modes
|
||||
$myreports = ($course->showreports and $USER->id == $user->id);
|
||||
$anyreport = has_capability('moodle/user:viewuseractivitiesreport', $personalcontext);
|
||||
|
||||
$modes = array();
|
||||
|
||||
if ($myreports or $anyreport or has_capability('coursereport/outline:view', $coursecontext)) {
|
||||
if ($myreports or $anyreport or has_capability('report/outline:view', $coursecontext)) {
|
||||
$modes[] = 'outline';
|
||||
}
|
||||
|
||||
if ($myreports or $anyreport or has_capability('coursereport/outline:view', $coursecontext)) {
|
||||
if ($myreports or $anyreport or has_capability('report/outline:view', $coursecontext)) {
|
||||
$modes[] = 'complete';
|
||||
}
|
||||
|
||||
if ($myreports or $anyreport or has_capability('coursereport/log:viewtoday', $coursecontext)) {
|
||||
if ($myreports or $anyreport or has_capability('report/log:viewtoday', $coursecontext)) {
|
||||
$modes[] = 'todaylogs';
|
||||
}
|
||||
|
||||
if ($myreports or $anyreport or has_capability('coursereport/log:view', $coursecontext)) {
|
||||
if ($myreports or $anyreport or has_capability('report/log:view', $coursecontext)) {
|
||||
$modes[] = 'alllogs';
|
||||
}
|
||||
|
||||
if ($myreports or $anyreport or has_capability('coursereport/stats:view', $coursecontext)) {
|
||||
if ($myreports or $anyreport or has_capability('report/stats:view', $coursecontext)) {
|
||||
$modes[] = 'stats';
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ if (has_capability('moodle/grade:viewall', $coursecontext)) {
|
||||
|
||||
// Course completion tab
|
||||
if (!empty($CFG->enablecompletion) && ($course->id == SITEID || !empty($course->enablecompletion)) && // completion enabled
|
||||
($myreports || $anyreport || ($course->id == SITEID || has_capability('coursereport/completion:view', $coursecontext)))) { // permissions to view the report
|
||||
($myreports || $anyreport || ($course->id == SITEID || has_capability('report/completion:view', $coursecontext)))) { // permissions to view the report
|
||||
|
||||
// Decide if singular or plural
|
||||
if ($course->id == SITEID) {
|
||||
@@ -237,8 +238,8 @@ switch ($mode) {
|
||||
}
|
||||
|
||||
// MDL-10818, do not display broken graph when user has no permission to view graph
|
||||
if ($myreports or has_capability('coursereport/stats:view', $coursecontext)) {
|
||||
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>';
|
||||
if ($myreports or has_capability('report/stats:view', $coursecontext)) {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/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>';
|
||||
}
|
||||
|
||||
// What the heck is this about? -- MD
|
||||
@@ -413,9 +414,9 @@ switch ($mode) {
|
||||
if (!$rs->valid()) {
|
||||
|
||||
if ($course->id != 1) {
|
||||
$error = get_string('nocompletions', 'coursereport_completion');
|
||||
$error = get_string('nocompletions', 'report_completion');
|
||||
} else {
|
||||
$error = get_string('nocompletioncoursesenroled', 'coursereport_completion');
|
||||
$error = get_string('nocompletioncoursesenroled', 'report_completion');
|
||||
}
|
||||
|
||||
echo $OUTPUT->notification($error);
|
||||
@@ -456,7 +457,7 @@ switch ($mode) {
|
||||
// If there are courses with this status
|
||||
if (!empty($infos)) {
|
||||
|
||||
echo '<h1 align="center">'.get_string($type, 'coursereport_completion').'</h1>';
|
||||
echo '<h1 align="center">'.get_string($type, 'report_completion').'</h1>';
|
||||
echo '<table class="generalbox boxaligncenter">';
|
||||
echo '<tr class="ccheader">';
|
||||
echo '<th class="c0 header" scope="col">'.get_string('course').'</th>';
|
||||
@@ -465,7 +466,7 @@ switch ($mode) {
|
||||
echo '<th class="c3 header" scope="col" width="15%">'.get_string('info').'</th>';
|
||||
|
||||
if ($type === 'complete') {
|
||||
echo '<th class="c4 header" scope="col">'.get_string('completiondate', 'coursereport_completion').'</th>';
|
||||
echo '<th class="c4 header" scope="col">'.get_string('completiondate', 'report_completion').'</th>';
|
||||
}
|
||||
|
||||
echo '</tr>';
|
||||
@@ -529,7 +530,7 @@ switch ($mode) {
|
||||
if (!empty($activities)) {
|
||||
|
||||
$row = array();
|
||||
$row['title'] = get_string('activitiescomplete', 'coursereport_completion');
|
||||
$row['title'] = get_string('activitiescomplete', 'report_completion');
|
||||
$row['status'] = $activities_complete.' of '.count($activities);
|
||||
$rows[] = $row;
|
||||
}
|
||||
@@ -565,7 +566,7 @@ switch ($mode) {
|
||||
break;
|
||||
|
||||
case 'No':
|
||||
echo get_string('incomplete', 'coursereport_completion');
|
||||
echo get_string('incomplete', 'report_completion');
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -575,7 +576,7 @@ switch ($mode) {
|
||||
// Display link on first row
|
||||
echo '</td><td class="c3">';
|
||||
if ($first_row) {
|
||||
echo '<a href="'.$CFG->wwwroot.'/blocks/completionstatus/details.php?course='.$c_course->id.'&user='.$user->id.'">'.get_string('detailedview', 'coursereport_completion').'</a>';
|
||||
echo '<a href="'.$CFG->wwwroot.'/blocks/completionstatus/details.php?course='.$c_course->id.'&user='.$user->id.'">'.get_string('detailedview', 'report_completion').'</a>';
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
|
||||
+1
-1
@@ -1174,7 +1174,7 @@ $string['notice'] = 'Notice';
|
||||
$string['noticenewerbackup'] = 'This backup file has been created with Moodle {$a->backuprelease} ({$a->backupversion}) and it\'s newer than your currently installed Moodle {$a->serverrelease} ({$a->serverversion}). This could cause some inconsistencies because backwards compatibility of backup files cannot be guaranteed.';
|
||||
$string['notifications'] = 'Notifications';
|
||||
$string['notifyloginfailuresmessage'] = '{$a->time}, IP: {$a->ip}, User: {$a->info}';
|
||||
$string['notifyloginfailuresmessageend'] = 'You can view these logs at {$a}/course/report/log/index.php?id=1&chooselog=1&modid=site_errors.';
|
||||
$string['notifyloginfailuresmessageend'] = 'You can view these logs at {$a}/report/log/index.php?id=1&chooselog=1&modid=site_errors.';
|
||||
$string['notifyloginfailuresmessagestart'] = 'Here is a list of failed login attempts at {$a} since you were last notified';
|
||||
$string['notifyloginfailuressubject'] = '{$a} :: Failed logins notification';
|
||||
$string['notincluded'] = 'Not included';
|
||||
|
||||
+14
-10
@@ -1972,13 +1972,15 @@ class global_navigation extends navigation_node {
|
||||
$usernode->add(get_string('notes', 'notes'), $url);
|
||||
}
|
||||
|
||||
//TODO: all this is a hack - we can not link to plugins like this - all this must be abstracted to plugin callbacks!
|
||||
|
||||
// Add a reports tab and then add reports the the user has permission to see.
|
||||
$anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
|
||||
|
||||
$outlinetreport = ($anyreport || has_capability('coursereport/outline:view', $coursecontext));
|
||||
$logtodayreport = ($anyreport || has_capability('coursereport/log:viewtoday', $coursecontext));
|
||||
$logreport = ($anyreport || has_capability('coursereport/log:view', $coursecontext));
|
||||
$statsreport = ($anyreport || has_capability('coursereport/stats:view', $coursecontext));
|
||||
$outlinetreport = ($anyreport || has_capability('report/outline:view', $coursecontext));
|
||||
$logtodayreport = ($anyreport || has_capability('report/log:viewtoday', $coursecontext));
|
||||
$logreport = ($anyreport || has_capability('report/log:view', $coursecontext));
|
||||
$statsreport = ($anyreport || has_capability('report/stats:view', $coursecontext));
|
||||
|
||||
$somereport = $outlinetreport || $logtodayreport || $logreport || $statsreport;
|
||||
|
||||
@@ -2090,10 +2092,10 @@ class global_navigation extends navigation_node {
|
||||
$usercoursenode->add(get_string('entercourse'), new moodle_url('/course/view.php', array('id'=>$usercourse->id)), self::TYPE_SETTING, null, null, new pix_icon('i/course', ''));
|
||||
}
|
||||
|
||||
$outlinetreport = ($anyreport || has_capability('coursereport/outline:view', $usercoursecontext));
|
||||
$logtodayreport = ($anyreport || has_capability('coursereport/log:viewtoday', $usercoursecontext));
|
||||
$logreport = ($anyreport || has_capability('coursereport/log:view', $usercoursecontext));
|
||||
$statsreport = ($anyreport || has_capability('coursereport/stats:view', $usercoursecontext));
|
||||
$outlinetreport = ($anyreport || has_capability('report/outline:view', $usercoursecontext));
|
||||
$logtodayreport = ($anyreport || has_capability('report/log:viewtoday', $usercoursecontext));
|
||||
$logreport = ($anyreport || has_capability('report/log:view', $usercoursecontext));
|
||||
$statsreport = ($anyreport || has_capability('report/stats:view', $usercoursecontext));
|
||||
if ($outlinetreport || $logtodayreport || $logreport || $statsreport) {
|
||||
$reporttab = $usercoursenode->add(get_string('activityreports'));
|
||||
$reportargs = array('user'=>$user->id, 'id'=>$usercourse->id);
|
||||
@@ -3455,8 +3457,10 @@ class settings_navigation extends navigation_node {
|
||||
$modulenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, 'filtermanage');
|
||||
}
|
||||
|
||||
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_COURSE, $this->page->cm->course))) {
|
||||
$url = new moodle_url('/course/report/log/index.php', array('chooselog'=>'1','id'=>$this->page->cm->course,'modid'=>$this->page->cm->id));
|
||||
//TODO: all this is a hack - we can not link to plugins like this - this must be abstracted to plugin callbacks!
|
||||
|
||||
if (has_capability('report/log:view', get_context_instance(CONTEXT_COURSE, $this->page->cm->course))) {
|
||||
$url = new moodle_url('/report/log/index.php', array('chooselog'=>'1','id'=>$this->page->cm->course,'modid'=>$this->page->cm->id));
|
||||
$modulenode->add(get_string('logs'), $url, self::TYPE_SETTING, null, 'logreport');
|
||||
}
|
||||
|
||||
|
||||
@@ -507,8 +507,8 @@ class core_renderer extends renderer_base {
|
||||
} else {
|
||||
$loggedinas .= get_string('failedloginattemptsall', '', $count);
|
||||
}
|
||||
if (has_capability('coursereport/log:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$loggedinas .= ' (<a href="'.$CFG->wwwroot.'/course/report/log/index.php'.
|
||||
if (has_capability('report/log:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$loggedinas .= ' (<a href="'.$CFG->wwwroot.'/report/log/index.php'.
|
||||
'?chooselog=1&id=1&modid=site_errors">'.get_string('logs').'</a>)';
|
||||
}
|
||||
$loggedinas .= '</div>';
|
||||
|
||||
+2
-2
@@ -1350,13 +1350,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('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('report/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('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('report/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);
|
||||
|
||||
@@ -51,7 +51,7 @@ function report_participation_page_type_list($pagetype, $parentcontext, $current
|
||||
$array = array(
|
||||
'*' => get_string('page-x', 'pagetype'),
|
||||
'course-report-*' => get_string('page-course-report-x', 'pagetype'),
|
||||
'course-report-participation-index' => get_string('pluginpagetype', 'coursereport_participation')
|
||||
'course-report-participation-index' => get_string('pluginpagetype', 'report_participation')
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ function report_progress_page_type_list($pagetype, $parentcontext, $currentconte
|
||||
$array = array(
|
||||
'*' => get_string('page-x', 'pagetype'),
|
||||
'course-report-*' => get_string('page-course-report-x', 'pagetype'),
|
||||
'course-report-progress-index' => get_string('pluginpagetype', 'coursereport_progress')
|
||||
'course-report-progress-index' => get_string('pluginpagetype', 'report_progress')
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
Reference in New Issue
Block a user