MDL-64843 Backup: Course copy user interface
This patch adds better core support for copying courses. There is now a simplified and dedicated UI for copying courses. This can be accessed from the course context menu or course management screens. All backups are done asynchronously and there can be multiple copies of a course in flight at once.
This commit is contained in:
@@ -116,7 +116,7 @@ class restore_controller extends base_controller {
|
||||
$this->logger = backup_factory::get_logger_chain($this->interactive, $this->execution, $this->restoreid);
|
||||
|
||||
// Set execution based on backup mode.
|
||||
if ($mode == backup::MODE_ASYNC) {
|
||||
if ($mode == backup::MODE_ASYNC || $mode == backup::MODE_COPY) {
|
||||
$this->execution = backup::EXECUTION_DELAYED;
|
||||
} else {
|
||||
$this->execution = backup::EXECUTION_INMEDIATE;
|
||||
@@ -529,6 +529,30 @@ class restore_controller extends base_controller {
|
||||
$this->progress->end_progress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the necessary copy preparation actions.
|
||||
* This method should only be called once the backup of a copy operation is completed.
|
||||
*
|
||||
* @throws restore_controller_exception
|
||||
*/
|
||||
public function prepare_copy(): void {
|
||||
// Check that we are in the correct mode.
|
||||
if ($this->mode != backup::MODE_COPY) {
|
||||
throw new restore_controller_exception('cannot_prepare_copy_wrong_mode');
|
||||
}
|
||||
|
||||
$this->progress->start_progress('Prepare Copy');
|
||||
|
||||
// If no exceptions were thrown, then we are in the proper format.
|
||||
$this->format = backup::FORMAT_MOODLE;
|
||||
|
||||
// Load plan, apply security and set status based on interactivity.
|
||||
$this->load_plan();
|
||||
|
||||
$this->set_status(backup::STATUS_NEED_PRECHECK);
|
||||
$this->progress->end_progress();
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
||||
protected function calculate_restoreid() {
|
||||
|
||||
Reference in New Issue
Block a user