Merge branch 'MDL-30569-master' of git://github.com/ankitagarwal/moodle
[moodle.git] / course / view.php
index a930df3..7317094 100644 (file)
             }
         }
 
-        if ($hide && confirm_sesskey()) {
-            set_section_visible($course->id, $hide, '0');
-        }
+        if (has_capability('moodle/course:update', $context)) {
+            if ($hide && confirm_sesskey()) {
+                set_section_visible($course->id, $hide, '0');
+            }
 
-        if ($show && confirm_sesskey()) {
-            set_section_visible($course->id, $show, '1');
-        }
+            if ($show && confirm_sesskey()) {
+                set_section_visible($course->id, $show, '1');
+            }
 
-        if (!empty($section)) {
-            if (!empty($move) and confirm_sesskey()) {
-                if (!move_section($course, $section, $move)) {
-                    echo $OUTPUT->notification('An error occurred while moving a section');
+            if (!empty($section)) {
+                if (!empty($move) and confirm_sesskey()) {
+                    if (!move_section($course, $section, $move)) {
+                        echo $OUTPUT->notification('An error occurred while moving a section');
+                    }
+                    // Clear the navigation cache at this point so that the affects
+                    // are seen immediately on the navigation.
+                    $PAGE->navigation->clear_cache();
                 }
-                // Clear the navigation cache at this point so that the affects
-                // are seen immediately on the navigation.
-                $PAGE->navigation->clear_cache();
             }
         }
     } else {