diff --git a/backup/backup.php b/backup/backup.php index 3df327aa24a..c1b1f648f50 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -34,6 +34,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_plan_builder.class.php'); $courseid = required_param('id', PARAM_INT); $sectionid = optional_param('section', null, PARAM_INT); $cmid = optional_param('cm', null, PARAM_INT); +$cancel = optional_param('cancel', '', PARAM_ALPHA); /** * Part of the forms in stages after initial, is POST never GET */ @@ -104,7 +105,10 @@ $PAGE->set_title($heading); $PAGE->set_heading($heading); $renderer = $PAGE->get_renderer('core','backup'); -echo $OUTPUT->header(); +if (empty($cancel)) { + // Do not print the header if user cancelled the process, as we are going to redirect the user. + echo $OUTPUT->header(); +} // Prepare a progress bar which can display optionally during long-running // operations while setting up the UI. diff --git a/backup/util/ui/base_moodleform.class.php b/backup/util/ui/base_moodleform.class.php index 32ac8fbfa01..520825890e2 100644 --- a/backup/util/ui/base_moodleform.class.php +++ b/backup/util/ui/base_moodleform.class.php @@ -391,7 +391,7 @@ abstract class base_moodleform extends moodleform { $config->title = get_string('confirmcancel', 'backup'); } $config->question = get_string('confirmcancelquestion', 'backup'); - $config->yesLabel = get_string('confirmcancelyes', 'backup'); + $config->yesLabel = $config->title; $config->noLabel = get_string('confirmcancelno', 'backup'); $config->closeButtonTitle = get_string('close', 'editor'); $PAGE->requires->yui_module( diff --git a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js index cdbd2063472..713ac2c2dc8 100644 --- a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js +++ b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-debug.js @@ -68,8 +68,17 @@ M.core_backup.confirmcancel = { // Detach the listeners for the confirm box so they don't fire again. new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach(); + // The currentTarget is a div surrounding the form elements. Simulating a click on the div is + // not going to submit a form so we need to find the form element to click. + var element = e.currentTarget.one('input, select, button'); + // Simulate the original cancel button click. - e.currentTarget.simulate('click'); + if (element) { + element.simulate('click'); + } else { + // Backwards compatibility only. + e.currentTarget.simulate('click'); + } }, this); diff --git a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js index db30391c0d4..20654afd15e 100644 --- a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js +++ b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel-min.js @@ -1 +1 @@ -YUI.add("moodle-backup-confirmcancel",function(e,t){M.core_backup=M.core_backup||{},M.core_backup.confirmcancel={listeners:[],config:{},watch_cancel_buttons:function(t){this.config=t,this.listeners.push(e.one(e.config.doc.body).delegate("click",this.confirm_cancel,".confirmcancel",this))},confirm_cancel:function(t){t.preventDefault();var n=new M.core.confirm(this.config);n.on("complete-yes",function(){(new e.EventHandle(M.core_backup.confirmcancel.listeners)).detach(),t.currentTarget.simulate("click")},this),n.show()}}},"@VERSION@",{requires:["node","node-event-simulate","moodle-core-notification-confirm"]}); +YUI.add("moodle-backup-confirmcancel",function(e,t){M.core_backup=M.core_backup||{},M.core_backup.confirmcancel={listeners:[],config:{},watch_cancel_buttons:function(t){this.config=t,this.listeners.push(e.one(e.config.doc.body).delegate("click",this.confirm_cancel,".confirmcancel",this))},confirm_cancel:function(t){t.preventDefault();var n=new M.core.confirm(this.config);n.on("complete-yes",function(){(new e.EventHandle(M.core_backup.confirmcancel.listeners)).detach();var n=t.currentTarget.one("input, select, button");n?n.simulate("click"):t.currentTarget.simulate("click")},this),n.show()}}},"@VERSION@",{requires:["node","node-event-simulate","moodle-core-notification-confirm"]}); diff --git a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js index cdbd2063472..713ac2c2dc8 100644 --- a/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js +++ b/backup/util/ui/yui/build/moodle-backup-confirmcancel/moodle-backup-confirmcancel.js @@ -68,8 +68,17 @@ M.core_backup.confirmcancel = { // Detach the listeners for the confirm box so they don't fire again. new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach(); + // The currentTarget is a div surrounding the form elements. Simulating a click on the div is + // not going to submit a form so we need to find the form element to click. + var element = e.currentTarget.one('input, select, button'); + // Simulate the original cancel button click. - e.currentTarget.simulate('click'); + if (element) { + element.simulate('click'); + } else { + // Backwards compatibility only. + e.currentTarget.simulate('click'); + } }, this); diff --git a/backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js b/backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js index 488fe3aae5b..6d300562ec3 100644 --- a/backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js +++ b/backup/util/ui/yui/src/confirmcancel/js/confirmcancel.js @@ -66,8 +66,17 @@ M.core_backup.confirmcancel = { // Detach the listeners for the confirm box so they don't fire again. new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach(); + // The currentTarget is a div surrounding the form elements. Simulating a click on the div is + // not going to submit a form so we need to find the form element to click. + var element = e.currentTarget.one('input, select, button'); + // Simulate the original cancel button click. - e.currentTarget.simulate('click'); + if (element) { + element.simulate('click'); + } else { + // Backwards compatibility only. + e.currentTarget.simulate('click'); + } }, this); diff --git a/lang/en/backup.php b/lang/en/backup.php index abaf88e7859..39feee500ea 100644 --- a/lang/en/backup.php +++ b/lang/en/backup.php @@ -124,8 +124,8 @@ $string['confirmcancelrestore'] = 'Cancel restore'; $string['confirmcancelimport'] = 'Cancel import'; $string['confirmcancelquestion'] = 'Are you sure you wish to cancel? Any information you have entered will be lost.'; -$string['confirmcancelyes'] = 'Cancel'; -$string['confirmcancelno'] = 'Stay'; +$string['confirmcancelyes'] = 'Cancel backup'; +$string['confirmcancelno'] = 'Do not cancel'; $string['confirmnewcoursecontinue'] = 'New course warning'; $string['confirmnewcoursecontinuequestion'] = 'A temporary (hidden) course will be created by the course restoration process. To abort restoration click cancel. Do not close the browser while restoring.'; $string['coursecategory'] = 'Category the course will be restored into';