MDL-32508 Add error when trying to access an unknown course section
authorAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Thu, 3 May 2012 14:02:10 +0000 (15:02 +0100)
committerDan Poltawski <dan@moodle.com>
Fri, 4 May 2012 05:41:59 +0000 (13:41 +0800)
course/format/renderer.php
lang/en/error.php

index e71f2a5..510de03 100644 (file)
@@ -419,6 +419,12 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
         $context = context_course::instance($course->id);
         $canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
 
+        if (!isset($sections[$displaysection])) {
+            // This section doesn't exist
+            print_error('unknowncoursesection', 'error', null, $course->fullname);
+            return;
+        }
+
         if (!$sections[$displaysection]->visible && !$canviewhidden) {
             if (!$course->hiddensections) {
                 echo $this->start_section_list();
index ad5affc..0d45834 100644 (file)
@@ -475,6 +475,7 @@ $string['unknownblockregion'] = 'The block region \'{$a}\' is not recognised on
 $string['unknowncontext'] = 'This is an unknown context.';
 $string['unknowncourse'] = 'Unknown course named "{$a}"';
 $string['unknowncourseidnumber'] = 'Unknown course ID "{$a}"';
+$string['unknowncoursesection'] = 'Unknown course section in course "{$a}"';
 $string['unknowncourserequest'] = 'Unknown course request';
 $string['unknownfiletype'] = 'Error unknown filtertype';
 $string['unknowngroup'] = 'Unknown group "{$a}"';