Skip to content

Commit

Permalink
MDL-27790 Backup: Added warning message to let user know that tempora…
Browse files Browse the repository at this point in the history
…ry course will be created for restoration process
  • Loading branch information
Rajesh Taneja committed Nov 8, 2011
1 parent 4161283 commit 687f512
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backup/util/ui/renderer.php
Expand Up @@ -211,7 +211,7 @@ public function backup_details_unknown(moodle_url $nextstageurl) {
* @return string
*/
public function course_selector(moodle_url $nextstageurl, $wholecourse = true, restore_category_search $categories = null, restore_course_search $courses=null, $currentcourse = null) {
global $CFG;
global $CFG, $PAGE;
require_once($CFG->dirroot.'/course/lib.php');

$nextstageurl->param('sesskey', sesskey());
Expand All @@ -232,9 +232,15 @@ public function course_selector(moodle_url $nextstageurl, $wholecourse = true, r
$html .= $this->output->heading(get_string('restoretonewcourse', 'backup'), 2, array('class'=>'header'));
$html .= $this->backup_detail_input(get_string('restoretonewcourse', 'backup'), 'radio', 'target', backup::TARGET_NEW_COURSE, array('checked'=>'checked'));
$html .= $this->backup_detail_pair(get_string('selectacategory', 'backup'), $this->render($categories));
$html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
$html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'), 'class'=>'newcoursecontinue')));
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
$config = new stdClass;
$config->title = get_string('confirmnewcoursecontinue', 'backup');
$config->question = get_string('confirmnewcoursecontinuequestion', 'backup');
$config->yesLabel = get_string('continue');
$config->noLabel = get_string('cancel');
$PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_newcoursecontinue_buttons', array($config));
}

if ($wholecourse && !empty($currentcourse)) {
Expand Down
20 changes: 20 additions & 0 deletions backup/util/ui/yui/confirmcancel/confirmcancel.js
Expand Up @@ -27,4 +27,24 @@ M.core_backup.watch_cancel_buttons = function(config) {
});
}

M.core_backup.watch_newcoursecontinue_buttons = function(config) {
Y.all('.newcoursecontinue').each(function(){
this._confirmationListener = this._confirmationListener || this.on('click', function(e){
// Prevent the default event (sumbit) from firing
e.preventDefault();
// Create the confirm box
var confirm = new M.core.confirm(config);
// If the user clicks yes
confirm.on('complete-yes', function(e){
// Detach the listener for the confirm box so it doesn't fire again.
this._confirmationListener.detach();
// Simulate the original cancel button click
this.simulate('click');
}, this);
// Show the confirm box
confirm.show();
}, this);
});
}

}, '@VERSION@', {'requires':['base','node','node-event-simulate','moodle-enrol-notification']});
2 changes: 2 additions & 0 deletions lang/en/backup.php
Expand Up @@ -92,6 +92,8 @@
Any information you have entered will be lost.';
$string['confirmcancelyes'] = 'Cancel';
$string['confirmcancelno'] = 'Stay';
$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';
$string['courseid'] = 'Original ID';
$string['coursesettings'] = 'Course settings';
Expand Down

0 comments on commit 687f512

Please sign in to comment.