From 25e2820ebd1dc1139ef690439b39d1e994fa1f33 Mon Sep 17 00:00:00 2001 From: ferran Date: Wed, 30 Oct 2024 11:58:45 +0100 Subject: [PATCH] MDL-82767 core_courseformat: deprecate edits in mod.php and view.php Most edit logic embed directly into course/view.php and course/mod.php is now redirected to course/format/update.php. This commit add deprecations messages to the old get params so it can be removed in Moodle 6.0 for good. --- .upgradenotes/MDL-82767-2024103011171091.yml | 9 ++++ course/mod.php | 51 +++++++++++++++++--- course/view.php | 20 ++++++-- 3 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 .upgradenotes/MDL-82767-2024103011171091.yml diff --git a/.upgradenotes/MDL-82767-2024103011171091.yml b/.upgradenotes/MDL-82767-2024103011171091.yml new file mode 100644 index 0000000000000..f430ab1c041fd --- /dev/null +++ b/.upgradenotes/MDL-82767-2024103011171091.yml @@ -0,0 +1,9 @@ +issueNumber: MDL-82767 +notes: + core_courseformat: + - message: >- + Many get actions from course/view.php and course/mod.php are now + deprecated. Use the new course/format/update.php instead to replace all + direct edit urls in your code. The course/format/updates.php uses the + same parameters as the core_courseformat_course_update webservice + type: deprecated diff --git a/course/mod.php b/course/mod.php index c365002524e0d..caa2309ad35a1 100644 --- a/course/mod.php +++ b/course/mod.php @@ -29,20 +29,20 @@ $sectionreturn = optional_param('sr', null, PARAM_INT); $add = optional_param('add', '', PARAM_ALPHANUM); $type = optional_param('type', '', PARAM_ALPHA); -$indent = optional_param('indent', 0, PARAM_INT); +$indent = optional_param('indent', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. $update = optional_param('update', 0, PARAM_INT); -$duplicate = optional_param('duplicate', 0, PARAM_INT); -$hide = optional_param('hide', 0, PARAM_INT); -$stealth = optional_param('stealth', 0, PARAM_INT); -$show = optional_param('show', 0, PARAM_INT); +$duplicate = optional_param('duplicate', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. +$hide = optional_param('hide', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. +$stealth = optional_param('stealth', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. +$show = optional_param('show', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. $copy = optional_param('copy', 0, PARAM_INT); $moveto = optional_param('moveto', 0, PARAM_INT); $movetosection = optional_param('movetosection', 0, PARAM_INT); -$delete = optional_param('delete', 0, PARAM_INT); +$delete = optional_param('delete', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. $course = optional_param('course', 0, PARAM_INT); -$groupmode = optional_param('groupmode', -1, PARAM_INT); +$groupmode = optional_param('groupmode', -1, PARAM_INT); // TODO remove this param as part of MDL-83530. $cancelcopy = optional_param('cancelcopy', 0, PARAM_BOOL); -$confirm = optional_param('confirm', 0, PARAM_BOOL); +$confirm = optional_param('confirm', 0, PARAM_BOOL); // TODO remove this param as part of MDL-83530. // This page should always redirect $url = new moodle_url('/course/mod.php'); @@ -118,6 +118,11 @@ ) ); } else if (!empty($duplicate) and confirm_sesskey()) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The duplicate param is deprecated. Please use action cm_duplicate in course/format/update.php instead.', + DEBUG_DEVELOPER + ); $cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); @@ -130,6 +135,11 @@ redirect(course_get_url($course, $cm->sectionnum, $urloptions)); } else if (!empty($delete)) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The delete param is deprecated. Please use action cm_delete in course/format/update.php instead.', + DEBUG_DEVELOPER + ); $cm = get_coursemodule_from_id('', $delete, 0, true, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); @@ -216,6 +226,11 @@ redirect(course_get_url($course, $section->section, $urloptions)); } else if (!empty($indent) and confirm_sesskey()) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The delete param deprecated. Please use action cm_moveleft and cm_moveright in course/format/update.php instead.', + DEBUG_DEVELOPER + ); $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('', $id, 0, true, MUST_EXIST); @@ -241,6 +256,11 @@ redirect(course_get_url($course, $cm->sectionnum, $urloptions)); } else if (!empty($hide) and confirm_sesskey()) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The hide param deprecated. Please use action cm_hide in course/format/update.php instead.', + DEBUG_DEVELOPER + ); $cm = get_coursemodule_from_id('', $hide, 0, true, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); @@ -255,6 +275,11 @@ redirect(course_get_url($course, $cm->sectionnum, $urloptions)); } else if (!empty($stealth) and confirm_sesskey()) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The stealth param deprecated. Please use action cm_stealth in course/format/update.php instead.', + DEBUG_DEVELOPER + ); list($course, $cm) = get_course_and_cm_from_cmid($stealth); require_login($course, false, $cm); require_capability('moodle/course:activityvisibility', $cm->context); @@ -265,6 +290,11 @@ redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn))); } else if (!empty($show) and confirm_sesskey()) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The show param deprecated. Please use action cm_show in course/format/update.php instead.', + DEBUG_DEVELOPER + ); list($course, $cm) = get_course_and_cm_from_cmid($show); require_login($course, false, $cm); require_capability('moodle/course:activityvisibility', $cm->context); @@ -276,6 +306,11 @@ redirect(course_get_url($course, $section->section, $urloptions)); } else if ($groupmode > -1 and confirm_sesskey()) { + // TODO remove this else if as part of MDL-83530. + debugging( + 'The gruopmode param deprecated. Please use the group mode actions in course/format/update.php instead.', + DEBUG_DEVELOPER + ); $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('', $id, 0, true, MUST_EXIST); diff --git a/course/view.php b/course/view.php index ff29d5ba103f9..1a71f20afe0a0 100644 --- a/course/view.php +++ b/course/view.php @@ -31,15 +31,15 @@ $id = optional_param('id', 0, PARAM_INT); $name = optional_param('name', '', PARAM_TEXT); $edit = optional_param('edit', -1, PARAM_BOOL); -$hide = optional_param('hide', 0, PARAM_INT); -$show = optional_param('show', 0, PARAM_INT); +$hide = optional_param('hide', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. +$show = optional_param('show', 0, PARAM_INT); // TODO remove this param as part of MDL-83530. $duplicatesection = optional_param('duplicatesection', 0, PARAM_INT); $idnumber = optional_param('idnumber', '', PARAM_RAW); $sectionid = optional_param('sectionid', 0, PARAM_INT); $section = optional_param('section', null, PARAM_INT); $expandsection = optional_param('expandsection', -1, PARAM_INT); $move = optional_param('move', 0, PARAM_INT); -$marker = optional_param('marker', -1 , PARAM_INT); +$marker = optional_param('marker', -1 , PARAM_INT); // TODO remove this param as part of MDL-83530. $switchrole = optional_param('switchrole', -1, PARAM_INT); // Deprecated, use course/switchrole.php instead. $return = optional_param('return', 0, PARAM_LOCALURL); @@ -199,8 +199,13 @@ } } + // TODO remove this if as part of MDL-83530. if (has_capability('moodle/course:sectionvisibility', $context)) { if ($hide && confirm_sesskey()) { + debugging( + 'The hide param in course view is deprecated. Please use course/format/update.php instead.', + DEBUG_DEVELOPER + ); set_section_visible($course->id, $hide, '0'); if ($sectionid) { redirect(course_get_url($course, $section, ['navigation' => true])); @@ -210,6 +215,10 @@ } if ($show && confirm_sesskey()) { + debugging( + 'The show param in course view is deprecated. Please use course/format/update.php instead.', + DEBUG_DEVELOPER + ); set_section_visible($course->id, $show, '1'); if ($sectionid) { redirect(course_get_url($course, $section, ['navigation' => true])); @@ -219,7 +228,12 @@ } } + // TODO remove this if as part of MDL-83530. if ($marker >= 0 && confirm_sesskey()) { + debugging( + 'The marker param in course view is deprecated. Please use course/format/update.php instead.', + DEBUG_DEVELOPER + ); course_set_marker($course->id, $marker); if ($sectionid) { redirect(course_get_url($course, $section, ['navigation' => true]));