Merge branch 'MDL-30569-master' of git://github.com/ankitagarwal/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 20 Dec 2011 03:08:42 +0000 (11:08 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 20 Dec 2011 03:08:42 +0000 (11:08 +0800)
1  2 
course/view.php

diff --combined course/view.php
      if ($PAGE->user_allowed_editing()) {
          if (($edit == 1) and confirm_sesskey()) {
              $USER->editing = 1;
-             redirect($PAGE->url);
+             // Redirect to site root if Editing is toggled on frontpage
+             if ($course->id == SITEID) {
+                 redirect($CFG->wwwroot .'/?redirect=0');
+             } else {
+                 redirect($PAGE->url);
+             }
          } else if (($edit == 0) and confirm_sesskey()) {
              $USER->editing = 0;
              if(!empty($USER->activitycopy) && $USER->activitycopycourse == $course->id) {
                  $USER->activitycopy       = false;
                  $USER->activitycopycourse = NULL;
              }
-             redirect($PAGE->url);
+             // Redirect to site root if Editing is toggled on frontpage
+             if ($course->id == SITEID) {
+                 redirect($CFG->wwwroot .'/?redirect=0');
+             } else {
+                 redirect($PAGE->url);
+             }
          }
  
 -        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 {