34 lines
935 B
PHP
34 lines
935 B
PHP
|
<?php
|
||
|
require_once("../../config.php");
|
||
|
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.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));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
$context = context_system::instance();
|
||
|
|
||
|
if (!has_capability('local/replication:replicate', $context)) {
|
||
|
die("User not allowed to trigger replication!");
|
||
|
}
|
||
|
|
||
|
$courses = get_courses();
|
||
|
|
||
|
$replicationconfig = get_config('local_replication');
|
||
|
$directory = $replicationconfig->directory;
|
||
|
|
||
|
if (!str_ends_with($directory, "/")) $directory = $directory . "/";
|
||
|
|
||
|
foreach ($courses as $course) {
|
||
|
if (!touch($directory . $course->id . "-" . $course->category . ".mew")) {
|
||
|
die("Could not touch $directory$id-{$course->category}.mew");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
echo("Done.");
|