Files
awo-hamburg-intranet/module/tasks/endpoints/admin/materialize_assignments.php

37 lines
932 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
require_once dirname(dirname(__DIR__)) . '/bootstrap.php';
$auth = TaskCertAuthContext::fromGlobals();
$isCli = PHP_SAPI === 'cli';
if (!$isCli && !TaskCertRequest::isPost()) {
TaskCertResponse::error('Methode nicht erlaubt', 405);
}
if (!$isCli) {
if (!$auth->hasPermission('r-task-cert-admin')) {
TaskCertResponse::error('Keine Berechtigung', 403);
}
TaskCertCsrf::assertValidFromRequest(true);
}
try {
$services = task_cert_services();
$count = $services['assignmentResolverService']->materializeAssignmentsForAllActiveTasks();
CronHeartbeat::record('materialize_assignments', ['materialized' => $count]);
TaskCertResponse::json([
'success' => true,
'materialized' => $count,
]);
} catch (Throwable $throwable) {
TaskCertResponse::json([
'success' => false,
'error' => $throwable->getMessage(),
], 400);
}