Merge branch 'MDL-26319' of git://github.com/nebgor/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-04-10 23:51:26 +02:00
commit fa81a03257
4 changed files with 21 additions and 18 deletions

View File

@ -130,19 +130,7 @@ class backup_ui extends base_ui {
}
return $backupid;
}
/**
* Cancels the current backup and redirects the user back to the relevant place
*/
public function cancel_backup() {
global $PAGE;
// Determine the approriate URL to redirect the user to
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
$relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
} else {
$relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
}
redirect($relevanturl);
}
/**
* Gets an array of progress bar items that can be displayed through the backup renderer.
* @return array Array of items for the progress bar

View File

@ -81,7 +81,7 @@ class backup_ui_stage_initial extends backup_ui_stage {
$form = $this->initialise_stage_form();
if ($form->is_cancelled()) {
$this->ui->cancel_backup();
$this->ui->cancel_process();
}
$data = $form->get_data();
@ -180,7 +180,7 @@ class backup_ui_stage_schema extends backup_ui_stage {
$form = $this->initialise_stage_form();
// Check it wasn't cancelled
if ($form->is_cancelled()) {
$this->ui->cancel_backup();
$this->ui->cancel_process();
}
// Check it has been submit
@ -288,7 +288,7 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
$form = $this->initialise_stage_form();
// Check it hasn't been cancelled
if ($form->is_cancelled()) {
$this->ui->cancel_backup();
$this->ui->cancel_process();
}
$data = $form->get_data();

View File

@ -226,6 +226,21 @@ abstract class base_ui {
public static function load_controller($uniqueid=false) {
throw new coding_exception('load_controller() method needs to be overridden in each subclass of base_ui');
}
/**
* Cancels the current backup/restore and redirects the user back to the relevant place
*/
public function cancel_process() {
global $PAGE;
// Determine the appropriate URL to redirect the user to
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
$relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
} else {
$relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
}
redirect($relevanturl);
}
/**
* Gets an array of progress bar items that can be displayed through the backup renderer.
* @return array Array of items for the progress bar

View File

@ -392,7 +392,7 @@ class restore_ui_stage_schema extends restore_ui_stage {
$form = $this->initialise_stage_form();
// Check it wasn't cancelled
if ($form->is_cancelled()) {
$this->ui->cancel_backup();
$this->ui->cancel_process();
}
// Check it has been submit
@ -500,7 +500,7 @@ class restore_ui_stage_review extends restore_ui_stage {
$form = $this->initialise_stage_form();
// Check it hasn't been cancelled
if ($form->is_cancelled()) {
$this->ui->cancel_backup();
$this->ui->cancel_process();
}
$data = $form->get_data();