* @param int $section Section number (not id!!!)
* @param int $move (-1 or 1)
* @return boolean true if section moved successfully
+ * @todo MDL-33379 remove this function in 2.5
*/
function move_section($course, $section, $move) {
+ debugging('This function will be removed before 2.5 is released please use move_section_to', DEBUG_DEVELOPER);
+
/// Moves a whole course section up and down within the course
global $USER, $DB;
return true;
}
- if ($destination > $course->numsections) {
+ if (($destination > $course->numsections) || ($destination < 1)) {
return false;
}
if (!empty($section)) {
if (!empty($move) and confirm_sesskey()) {
- if (move_section($course, $section, $move)) {
+ $destsection = $section + $move;
+ if (move_section_to($course, $section, $destsection)) {
+ // Rebuild course cache, after moving section
+ rebuild_course_cache($course->id, true);
if ($course->id == SITEID) {
redirect($CFG->wwwroot . '/?redirect=0');
} else {