MDL-58837 course: do not confirm deleting empty sections
This commit is contained in:
@@ -49,9 +49,14 @@ if ($deletesection) {
|
||||
$cancelurl = course_get_url($course, $sectioninfo, array('sr' => $sectionreturn));
|
||||
if (course_can_delete_section($course, $sectioninfo)) {
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL) && confirm_sesskey();
|
||||
if (!$confirm && optional_param('sesskey', null, PARAM_RAW) !== null &&
|
||||
empty($sectioninfo->summary) && empty($sectioninfo->sequence) && confirm_sesskey()) {
|
||||
// Do not ask for confirmation if section is empty and sesskey is already provided.
|
||||
$confirm = true;
|
||||
}
|
||||
if ($confirm) {
|
||||
course_delete_section($course, $sectioninfo, true, true);
|
||||
$courseurl = course_get_url($course, 0, array('sr' => $sectionreturn));
|
||||
$courseurl = course_get_url($course, $sectioninfo->section - 1, array('sr' => $sectionreturn));
|
||||
redirect($courseurl);
|
||||
} else {
|
||||
if (get_string_manager()->string_exists('deletesection', 'format_' . $course->format)) {
|
||||
|
||||
@@ -394,7 +394,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
||||
$url = new moodle_url('/course/editsection.php', array(
|
||||
'id' => $section->id,
|
||||
'sr' => $sectionreturn,
|
||||
'delete' => 1));
|
||||
'delete' => 1,
|
||||
'sesskey' => sesskey()));
|
||||
$controls['delete'] = array(
|
||||
'url' => $url,
|
||||
'icon' => 'i/delete',
|
||||
|
||||
Reference in New Issue
Block a user