56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
require_once("../../config.php");
|
|
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
|
|
|
$id = $_GET["id"];
|
|
$course = get_course($id);
|
|
|
|
$replicationconfig = get_config('local_replication');
|
|
$directory = $replicationconfig->directory;
|
|
|
|
$context = context_course::instance($id);
|
|
|
|
if (!has_capability('local/replication:replicate', $context)) {
|
|
die("User not allowed to trigger replication!");
|
|
}
|
|
|
|
$bc = new backup_controller(\backup::TYPE_1COURSE, $id, backup::FORMAT_MOODLE,
|
|
backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id);
|
|
|
|
$tasks = $bc->get_plan()->get_tasks();
|
|
foreach ($tasks as &$task) {
|
|
if ($task instanceof \backup_root_task) {
|
|
$setting = $task->get_setting('users');
|
|
$setting->set_value('0');
|
|
$setting = $task->get_setting('anonymize');
|
|
$setting->set_value('1');
|
|
$setting = $task->get_setting('role_assignments');
|
|
$setting->set_value('0');
|
|
$setting = $task->get_setting('filters');
|
|
$setting->set_value('0');
|
|
$setting = $task->get_setting('comments');
|
|
$setting->set_value('0');
|
|
$setting = $task->get_setting('logs');
|
|
$setting->set_value('0');
|
|
$setting = $task->get_setting('grade_histories');
|
|
$setting->set_value('0');
|
|
}
|
|
}
|
|
|
|
$filename = $directory . '/course_' . $id . "_" . $course->category . "_" . date('U') . '.mbz';
|
|
|
|
$bc->set_status(backup::STATUS_AWAITING);
|
|
$bc->execute_plan();
|
|
|
|
$result = $bc->get_results();
|
|
|
|
if(isset($result['backup_destination']) && $result['backup_destination']) {
|
|
$file = $result['backup_destination'];
|
|
|
|
if(!$file->copy_content_to($filename)) {
|
|
echo("Problems copying final backup to '". $filename . "'");
|
|
}
|
|
}
|
|
|
|
echo('Course is now getting replicated. <a href="javascript:history.back();">Back to Course Administration</a>');
|
|
|