28 lines
No EOL
811 B
PHP
28 lines
No EOL
811 B
PHP
<?php
|
|
require_once("../../config.php");
|
|
|
|
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));
|
|
}
|
|
}
|
|
|
|
$id = $_GET["id"];
|
|
$course = get_course($id);
|
|
|
|
$replicationconfig = get_config('local_replication');
|
|
$directory = $replicationconfig->directory;
|
|
|
|
if (!str_ends_with($directory, "/")) $directory = $directory . "/";
|
|
|
|
$context = context_course::instance($id);
|
|
|
|
if (!has_capability('local/replication:replicate', $context)) {
|
|
die("User not allowed to trigger replication!");
|
|
}
|
|
|
|
if (!touch($directory . $id . "-" . $course->category . ".mew")) {
|
|
die("Could not touch $directory$id-{$course->category}.mew");
|
|
} |