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:
Matt Porritt
2020-05-15 06:02:02 +00:00
parent 206e179df5
commit 01436f7539
40 changed files with 2868 additions and 73 deletions
@@ -36,6 +36,13 @@ abstract class base_controller extends backup implements loggable {
/** @var bool Whether this backup should release the session. */
protected $releasesession = backup::RELEASESESSION_NO;
/**
* Holds the relevant destination information for course copy operations.
*
* @var \stdClass.
*/
protected $copy;
/**
* Gets the progress reporter, which can be used to report progress within
* the backup or restore process.
@@ -95,4 +102,30 @@ abstract class base_controller extends backup implements loggable {
public function get_releasesession() {
return $this->releasesession;
}
/**
* Store extra data for course copy operations.
*
* For a course copying these is data required to be passed to the restore step.
* We store this data in its own section of the backup controller
*
* @param \stdClass $data The course copy data.
* @throws backup_controller_exception
*/
public function set_copy(\stdClass $data): void {
// Only allow setting of copy data when controller is in copy mode.
if ($this->mode != backup::MODE_COPY) {
throw new backup_controller_exception('cannot_set_copy_vars_wrong_mode');
}
$this->copy = $data;
}
/**
* Get the course copy data.
*
* @return \stdClass
*/
public function get_copy(): \stdClass {
return $this->copy;
}
}