19declare(strict_types=1);
47use Psr\Http\Message\RequestInterface;
48use Psr\Http\Message\ServerRequestInterface;
58 private readonly ServerRequestInterface
$request;
61 private readonly \ILIAS\UI\Component\Input\Container\Filter\Standard
$filter;
73 ServerRequestInterface|RequestInterface|
null $request =
null,
84 $this->
lng = $lng ?:
$DIC->language();
86 $this->data_factory =
$data_factory ?: new \ILIAS\Data\Factory();
91 $this->user_timezone = new \DateTimeZone($this->
user->getTimeZone());
99 array $visible_column_ids,
103 ?array $additional_parameters
108 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
110 $ui_filter_data = $this->
mapUiFilterData($this->ui_service->filter()->getData($this->filter));
112 $table_rows = $this->
buildTableRows($this->repo->fetchCertificatesForOverview(
113 $this->user->getLanguage(),
120 foreach ($table_rows as $row) {
121 $row[
'issue_date'] = (
new DateTimeImmutable())
122 ->setTimestamp($row[
'issue_date'])
123 ->setTimezone($this->user_timezone);
124 yield $row_builder->
buildDataRow((
string) $row[
'id'], $row);
134 if (isset($filter_data[
'issue_date']) && $filter_data[
'issue_date'] !==
'') {
136 $from =
new DateTimeImmutable($filter_data[
'issue_date'][0], $this->user_timezone);
137 }
catch (Throwable) {
142 $to =
new DateTimeImmutable($filter_data[
'issue_date'][1], $this->user_timezone);
143 $seconds_to_add = 59 - (
int) $to->format(
's');
144 $to = $to->modify(
"+$seconds_to_add seconds");
145 }
catch (Throwable) {
149 $filter_data[
'issue_date'] = [
154 $filter_data[
'issue_date'] = [
165 $ui_filter_data = $this->mapUiFilterData($this->ui_service->filter()->getData($this->filter));
167 return $this->repo->fetchCertificatesForOverviewCount($ui_filter_data);
173 return $this->ui_service->filter()->standard(
174 'certificates_overview_filter',
175 $this->
ctrl->getLinkTargetByClass(
176 ilObjCertificateSettingsGUI::class,
180 'certificate_id' => $this->ui_factory->input()->field()->text($this->lng->txt(
'certificate_id')),
181 'issue_date' => $this->ui_factory->input()->field()
182 ->duration($this->lng->txt(
'certificate_issue_date'))
183 ->withFormat($this->user->getDateTimeFormat())
185 'object' => $this->ui_factory->input()->field()->text($this->lng->txt(
'obj')),
186 'obj_id' => $this->ui_factory->input()->field()->text($this->lng->txt(
'object_id')),
187 'owner' => $this->ui_factory->input()->field()->text($this->lng->txt(
'owner')),
189 [
true,
true,
true,
true,
true],
197 $ui_table = $this->ui_factory->table();
199 return $ui_table->data(
201 $this->
lng->txt(
'certificates'),
203 'certificate_id' => $ui_table->column()->text($this->lng->txt(
'certificate_id')),
204 'issue_date' => $ui_table->column()->date($this->lng->txt(
'certificate_issue_date'), $this->user->getDateTimeFormat()),
205 'object' => $ui_table->column()->text($this->lng->txt(
'obj')),
206 'obj_id' => $ui_table->column()->text($this->lng->txt(
'object_id')),
207 'owner' => $ui_table->column()->text($this->lng->txt(
'owner'))
211 ->withId(
'certificateOverviewTable')
212 ->withRequest($this->request)
213 ->withActions($this->buildTableActions());
219 private function buildTableActions(): array
221 $uri_download = $this->data_factory->uri(
222 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
223 ilObjCertificateSettingsGUI::class,
234 $url_builder_download,
235 $action_parameter_token_download,
236 $row_id_token_download
238 (
new URLBuilder($uri_download))->acquireParameters(
245 'download' => $this->ui_factory->table()->action()->single(
246 $this->
lng->txt(
'download'),
247 $url_builder_download->withParameter($action_parameter_token_download,
'download'),
248 $row_id_token_download
263 $object_title_cache = [];
265 foreach ($certificates as $certificate) {
266 if (!isset($ref_id_cache[$certificate->getObjId()])) {
269 $ref_ids = $ref_id_cache[$certificate->getObjId()];
271 if (!isset($object_title_cache[$certificate->getObjId()])) {
273 foreach ($ref_ids as
$refId) {
274 if ($this->
access->checkAccess(
'read',
'', $refId)) {
275 $object_title = $this->ui_renderer->render(
276 $this->ui_factory->link()->standard($object_title, ilLink::_getLink(
$refId))
282 $object_title_cache[$certificate->getObjId()] = $object_title;
287 if (!isset($owner_cache[$certificate->getUserId()])) {
292 'id' => $certificate->getId(),
293 'certificate_id' => $certificate->getCertificateId()->asString(),
294 'issue_date' => $certificate->getAcquiredTimestamp(),
295 'object' => $object_title_cache[$certificate->getObjId()],
296 'obj_id' => (string) $certificate->getObjId(),
297 'owner' => $owner_cache[$certificate->getUserId()],
306 return $this->ui_renderer->render([$this->
filter, $this->table]);
readonly Renderer $ui_renderer
readonly ilAccessHandler $access
readonly ilUIService $ui_service
readonly Factory $ui_factory
readonly ilCtrl ilCtrlInterface $ctrl
readonly DateTimeZone $user_timezone
readonly ILIAS Data Factory $data_factory
readonly ServerRequestInterface $request
buildTableRows(array $certificates)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
readonly ILIAS UI Component Input Container Filter Standard $filter
__construct(?Factory $ui_factory=null, ?ilUserCertificateRepository $repo=null, ?ilUIService $ui_service=null, ?ilLanguage $lng=null, ServerRequestInterface|RequestInterface|null $request=null, ?\ILIAS\Data\Factory $data_factory=null, ?ilCtrl $ctrl=null, ?Renderer $ui_renderer=null, ?ilAccessHandler $access=null, ?ilObjUser $user=null)
readonly ilUserCertificateRepository $repo
mapUiFilterData(array $filter_data)
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
Stores all calendar relevant settings.
Class ilCtrl provides processing control methods.
const CMD_DOWNLOAD_CERTIFICATE
const CMD_CERTIFICATES_OVERVIEW
static _lookupLogin(int $a_user_id)
Class ilObject Basic functions for all objects.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
buildDataRow(string $id, array $record)
This describes a Data Table.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.