MDL-80295 core_course: mod and modedit compatible with section id
This commit is contained in:
@@ -76,16 +76,22 @@ require_login();
|
||||
//check if we are adding / editing a module that has new forms using formslib
|
||||
if (!empty($add)) {
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$section = required_param('section', PARAM_INT);
|
||||
$sectionid = optional_param('sectionid', null, PARAM_INT);
|
||||
$type = optional_param('type', '', PARAM_ALPHA);
|
||||
$returntomod = optional_param('return', 0, PARAM_BOOL);
|
||||
$beforemod = optional_param('beforemod', 0, PARAM_INT);
|
||||
|
||||
if (empty($sectionid)) {
|
||||
$section = required_param('section', PARAM_INT);
|
||||
$sectioninfo = get_fast_modinfo($id)->get_section_info($section);
|
||||
$sectionid = $sectioninfo?->id;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'add' => $add,
|
||||
'type' => $type,
|
||||
'course' => $id,
|
||||
'section' => $section,
|
||||
'sectionid' => $sectionid,
|
||||
'return' => $returntomod,
|
||||
'beforemod' => $beforemod,
|
||||
];
|
||||
|
||||
@@ -56,11 +56,17 @@ if (!empty($showonly)) {
|
||||
}
|
||||
|
||||
if (!empty($add)) {
|
||||
$section = required_param('section', PARAM_INT);
|
||||
$course = required_param('course', PARAM_INT);
|
||||
|
||||
$sectionid = optional_param('sectionid', null, PARAM_INT);
|
||||
if (empty($sectionid)) {
|
||||
$sectionnum = required_param('section', PARAM_INT);
|
||||
} else {
|
||||
$sectionnum = get_fast_modinfo($course)->get_section_info_by_id($sectionid, MUST_EXIST)->sectionnum;
|
||||
}
|
||||
|
||||
$url->param('add', $add);
|
||||
$url->param('section', $section);
|
||||
$url->param('section', $sectionnum);
|
||||
$url->param('course', $course);
|
||||
$PAGE->set_url($url);
|
||||
|
||||
@@ -70,9 +76,9 @@ if (!empty($add)) {
|
||||
// There is no page for this in the navigation. The closest we'll have is the course section.
|
||||
// If the course section isn't displayed on the navigation this will fall back to the course which
|
||||
// will be the closest match we have.
|
||||
navigation_node::override_active_url(course_get_url($course, $section));
|
||||
navigation_node::override_active_url(course_get_url($course, $sectionnum));
|
||||
|
||||
list($module, $context, $cw, $cm, $data) = prepare_new_moduleinfo_data($course, $add, $section);
|
||||
[$module, $context, $cw, $cm, $data] = prepare_new_moduleinfo_data($course, $add, $sectionnum);
|
||||
$data->return = 0;
|
||||
if (!is_null($sectionreturn)) {
|
||||
$data->sr = $sectionreturn;
|
||||
|
||||
Reference in New Issue
Block a user