Files
awo-hamburg-intranet/module/tasks/actions/user/my_tasks_action.php

35 lines
968 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
require_once dirname(dirname(__DIR__)) . '/bootstrap.php';
function task_cert_user_my_tasks_action(): array
{
$auth = TaskCertAuthContext::fromGlobals();
if (!$auth->isLoggedIn()) {
return [
'error' => 'Nicht eingeloggt.',
'assignments' => [],
'certificate_summary_by_task' => [],
];
}
$services = task_cert_services();
$assignments = $services['assignmentRepo']->listForUser($auth->contactId());
$taskIds = [];
foreach ($assignments as $assignment) {
$taskId = (int) ($assignment['task_id'] ?? 0);
if ($taskId > 0) {
$taskIds[] = $taskId;
}
}
return [
'error' => null,
'assignments' => $assignments,
'certificate_summary_by_task' => $services['certificateService']->getUserTaskCertificateSummary($auth->contactId(), $taskIds),
'csrf_token' => TaskCertCsrf::token(),
];
}