mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
Merge branch '46481-28' of git://github.com/samhemelryk/moodle
This commit is contained in:
commit
c31f7c58c1
@ -55,11 +55,22 @@ abstract class backup_moodleform extends base_moodleform {
|
||||
}
|
||||
/**
|
||||
* Initial backup user interface stage moodleform.
|
||||
*
|
||||
* Nothing to override we only need it defined so that moodleform doesn't get confused
|
||||
* between stages.
|
||||
*/
|
||||
class backup_initial_form extends backup_moodleform {}
|
||||
class backup_initial_form extends backup_moodleform {
|
||||
|
||||
/**
|
||||
* We override the initial form to offer a one click backup option.
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'backupheading', get_string('backup'));
|
||||
$mform->addElement('html', html_writer::tag('p', get_string('performoneclickbackup_desc', 'backup')));
|
||||
$mform->addElement('submit', 'oneclickbackup', get_string('performoneclickbackup', 'backup'));
|
||||
|
||||
parent::definition();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Schema backup user interface stage moodleform.
|
||||
*
|
||||
|
@ -62,6 +62,12 @@ abstract class backup_ui_stage extends base_ui_stage {
|
||||
*/
|
||||
class backup_ui_stage_initial extends backup_ui_stage {
|
||||
|
||||
/**
|
||||
* When set to true we skip all stages and jump to immediately processing the backup.
|
||||
* @var bool
|
||||
*/
|
||||
protected $oneclickbackup = false;
|
||||
|
||||
/**
|
||||
* Initial backup stage constructor
|
||||
* @param backup_ui $ui
|
||||
@ -86,6 +92,9 @@ class backup_ui_stage_initial extends backup_ui_stage {
|
||||
|
||||
$data = $form->get_data();
|
||||
if ($data && confirm_sesskey()) {
|
||||
if (isset($data->oneclickbackup)) {
|
||||
$this->oneclickbackup = true;
|
||||
}
|
||||
$tasks = $this->ui->get_tasks();
|
||||
$changes = 0;
|
||||
foreach ($tasks as &$task) {
|
||||
@ -112,6 +121,42 @@ class backup_ui_stage_initial extends backup_ui_stage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next stage for the backup.
|
||||
*
|
||||
* We override this function to implement the one click backup.
|
||||
* When the user performs a one click backup we jump straight to the final stage.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_next_stage() {
|
||||
if ($this->oneclickbackup) {
|
||||
// Its a one click backup.
|
||||
// The default filename is backup.mbz, this normally gets set to something useful in the confirmation stage.
|
||||
// because we skipped that stage we must manually set this to a useful value.
|
||||
$tasks = $this->ui->get_tasks();
|
||||
foreach ($tasks as $task) {
|
||||
if ($task instanceof backup_root_task) {
|
||||
// Find the filename setting.
|
||||
$setting = $task->get_setting('filename');
|
||||
if ($setting) {
|
||||
// Use the helper objects to get a useful name.
|
||||
$filename = backup_plan_dbops::get_default_backup_filename(
|
||||
$this->ui->get_format(),
|
||||
$this->ui->get_type(),
|
||||
$this->ui->get_controller_id(),
|
||||
$this->ui->get_setting_value('users'),
|
||||
$this->ui->get_setting_value('anonymize')
|
||||
);
|
||||
$setting->set_value($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
return backup_ui::STAGE_FINAL;
|
||||
}
|
||||
return parent::get_next_stage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the backup_moodleform instance for this stage
|
||||
*
|
||||
|
@ -84,7 +84,7 @@ abstract class base_ui_stage {
|
||||
* The next stage
|
||||
* @return int
|
||||
*/
|
||||
final public function get_next_stage() {
|
||||
public function get_next_stage() {
|
||||
return floor($this->stage*2);
|
||||
}
|
||||
/**
|
||||
|
@ -60,3 +60,10 @@ Feature: Backup Moodle courses
|
||||
And I press "Next"
|
||||
And I should see "Test assign"
|
||||
And I should not see "Test data"
|
||||
|
||||
@javascript
|
||||
Scenario: Backup a course using the one click backup button
|
||||
When I perform a quick backup of course "Course 2"
|
||||
Then I should see "Restore course"
|
||||
And I should see "Course backup area"
|
||||
And I should see "backup-moodle2-course-"
|
@ -98,6 +98,40 @@ class behat_backup extends behat_base {
|
||||
$this->find_button(get_string('backupstage16action', 'backup'))->press();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a quick (one click) backup of a course.
|
||||
*
|
||||
* Please note that because you can't set settings with this there is no way to know what the filename
|
||||
* that was produced was. It contains a timestamp making it hard to find.
|
||||
*
|
||||
* @Given /^I perform a quick backup of course "(?P<course_fullname_string>(?:[^"]|\\")*)"$/
|
||||
* @param string $backupcourse
|
||||
*/
|
||||
public function i_perform_a_quick_backup_of_course($backupcourse) {
|
||||
// We can not use other steps here as we don't know where the provided data
|
||||
// table elements are used, and we need to catch exceptions contantly.
|
||||
|
||||
// Go to homepage.
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
|
||||
// Click the course link.
|
||||
$this->find_link($backupcourse)->click();
|
||||
|
||||
// Click the backup link.
|
||||
$this->find_link(get_string('backup'))->click();
|
||||
$this->wait();
|
||||
|
||||
// Initial settings.
|
||||
$this->find_button(get_string('performoneclickbackup', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
// Waiting for it to finish.
|
||||
$this->wait(self::EXTENDED_TIMEOUT);
|
||||
|
||||
// Last backup continue button.
|
||||
$this->find_button(get_string('backupstage16action', 'backup'))->press();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the specified origin course into the other course using the provided options.
|
||||
*
|
||||
|
@ -177,6 +177,8 @@ $string['moreresults'] = 'There are too many results, enter a more specific sear
|
||||
$string['nomatchingcourses'] = 'There are no courses to display';
|
||||
$string['norestoreoptions'] = 'There are no categories or existing courses you can restore to.';
|
||||
$string['originalwwwroot'] = 'URL of backup';
|
||||
$string['performoneclickbackup'] = 'Perform quick backup';
|
||||
$string['performoneclickbackup_desc'] = 'Performing a quick backup will create a backup using the currently selected settings below. If you wish to further make choices regarding what sections or activities that you want to include in your backup, please process onto the "Next" step.';
|
||||
$string['previousstage'] = 'Previous';
|
||||
$string['preparingui'] = 'Preparing to display page';
|
||||
$string['preparingdata'] = 'Preparing data';
|
||||
|
Loading…
x
Reference in New Issue
Block a user