2022-01-13 07:12:46 +00:00
|
|
|
<?php
|
|
|
|
require_once("../../config.php");
|
|
|
|
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
|
|
|
|
2022-01-13 10:36:16 +00:00
|
|
|
if (! function_exists('str_ends_with')) {
|
|
|
|
function str_ends_with(string $haystack, string $needle): bool
|
|
|
|
{
|
|
|
|
$needle_len = strlen($needle);
|
|
|
|
return ($needle_len === 0 || 0 === substr_compare($haystack, $needle, - $needle_len));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 07:12:46 +00:00
|
|
|
$id = $_GET["id"];
|
|
|
|
$course = get_course($id);
|
|
|
|
|
|
|
|
$replicationconfig = get_config('local_replication');
|
|
|
|
$directory = $replicationconfig->directory;
|
|
|
|
|
2022-01-13 10:36:16 +00:00
|
|
|
if (!str_ends_with($directory, "/")) $directory = $directory . "/";
|
|
|
|
|
2022-01-13 07:12:46 +00:00
|
|
|
$context = context_course::instance($id);
|
|
|
|
|
|
|
|
if (!has_capability('local/replication:replicate', $context)) {
|
|
|
|
die("User not allowed to trigger replication!");
|
|
|
|
}
|
|
|
|
|
2022-01-13 10:36:16 +00:00
|
|
|
touch($directory . $id . "-" . $course->category . ".mew");
|