Permalink
Browse files

MDL-40515: report_log: List activities in optgroups

Prevents users from generating reports on invalid values

Change-Id: If358fa06c8dadd33bb2875ea54ab4bce97b16aff
  • Loading branch information...
1 parent ca1c4ba commit 4e87aec55331e4f6768e8a50a66620c50339b438 @aolley aolley committed Jul 5, 2013
Showing with 22 additions and 4 deletions.
  1. +22 −4 report/log/locallib.php
View
@@ -222,12 +222,14 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0,
$modinfo = get_fast_modinfo($course);
if (!empty($modinfo->cms)) {
$section = 0;
+ $thissection = array();
foreach ($modinfo->cms as $cm) {
if (!$cm->uservisible || !$cm->has_view()) {
continue;
}
if ($cm->sectionnum > 0 and $section <> $cm->sectionnum) {
- $activities["section/$cm->sectionnum"] = '--- '.get_section_name($course, $cm->sectionnum).' ---';
+ $activities[] = $thissection;
+ $thissection = array();
}
$section = $cm->sectionnum;
$modname = strip_tags($cm->get_formatted_name());
@@ -237,12 +239,19 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0,
if (!$cm->visible) {
$modname = "(".$modname.")";
}
- $activities["$cm->id"] = $modname;
+ $key = get_section_name($course, $cm->sectionnum);
+ if (!isset($thissection[$key])) {
+ $thissection[$key] = array();
+ }
+ $thissection[$key][$cm->id] = $modname;
if ($cm->id == $modid) {
$selectedactivity = "$cm->id";
}
}
+ if (!empty($thissection)) {
+ $activities[] = $thissection;
+ }
}
if (has_capability('report/log:view', $sitecontext) && !$course->category) {
@@ -475,12 +484,14 @@ function report_log_print_selector_form($course, $selecteduser=0, $selecteddate=
$modinfo = get_fast_modinfo($course);
if (!empty($modinfo->cms)) {
$section = 0;
+ $thissection = array();
foreach ($modinfo->cms as $cm) {
if (!$cm->uservisible || !$cm->has_view()) {
continue;
}
if ($cm->sectionnum > 0 and $section <> $cm->sectionnum) {
- $activities["section/$cm->sectionnum"] = '--- '.get_section_name($course, $cm->sectionnum).' ---';
+ $activities[] = $thissection;
+ $thissection = array();
}
$section = $cm->sectionnum;
$modname = strip_tags($cm->get_formatted_name());
@@ -490,12 +501,19 @@ function report_log_print_selector_form($course, $selecteduser=0, $selecteddate=
if (!$cm->visible) {
$modname = "(".$modname.")";
}
- $activities["$cm->id"] = $modname;
+ $key = get_section_name($course, $cm->sectionnum);
+ if (!isset($thissection[$key])) {
+ $thissection[$key] = array();
+ }
+ $thissection[$key][$cm->id] = $modname;
if ($cm->id == $modid) {
$selectedactivity = "$cm->id";
}
}
+ if (!empty($thissection)) {
+ $activities[] = $thissection;
+ }
}
if (has_capability('report/log:view', $sitecontext) && ($course->id == SITEID)) {

0 comments on commit 4e87aec

Please sign in to comment.