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,
102 mixed $additional_viewcontrol_data,
104 mixed $additional_parameters
109 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
111 $ui_filter_data = $this->
mapUiFilterData($this->ui_service->filter()->getData($this->filter));
113 $table_rows = $this->
buildTableRows($this->repo->fetchCertificatesForOverview(
114 $this->user->getLanguage(),
121 foreach ($table_rows as $row) {
122 $row[
'issue_date'] = (
new DateTimeImmutable())
123 ->setTimestamp($row[
'issue_date'])
124 ->setTimezone($this->user_timezone);
125 yield $row_builder->
buildDataRow((
string) $row[
'id'], $row);
135 if (isset($filter_data[
'issue_date']) && $filter_data[
'issue_date'] !==
'') {
137 $from =
new DateTimeImmutable($filter_data[
'issue_date'][0], $this->user_timezone);
138 }
catch (Throwable) {
143 $to =
new DateTimeImmutable($filter_data[
'issue_date'][1], $this->user_timezone);
144 $seconds_to_add = 59 - (
int) $to->format(
's');
145 $to = $to->modify(
"+$seconds_to_add seconds");
146 }
catch (Throwable) {
150 $filter_data[
'issue_date'] = [
155 $filter_data[
'issue_date'] = [
165 mixed $additional_viewcontrol_data,
167 mixed $additional_parameters
169 $ui_filter_data = $this->mapUiFilterData($this->ui_service->
filter()->getData($this->
filter));
171 return $this->repo->fetchCertificatesForOverviewCount($ui_filter_data);
177 return $this->ui_service->filter()->standard(
178 'certificates_overview_filter',
179 $this->
ctrl->getLinkTargetByClass(
180 ilObjCertificateSettingsGUI::class,
184 'certificate_id' => $this->ui_factory->input()->field()->text($this->lng->txt(
'certificate_id')),
185 'issue_date' => $this->ui_factory->input()->field()
186 ->duration($this->lng->txt(
'certificate_issue_date'))
187 ->withFormat($this->user->getDateTimeFormat())
189 'object' => $this->ui_factory->input()->field()->text($this->lng->txt(
'obj')),
190 'obj_id' => $this->ui_factory->input()->field()->text($this->lng->txt(
'object_id')),
191 'owner' => $this->ui_factory->input()->field()->text($this->lng->txt(
'owner')),
193 [
true,
true,
true,
true,
true],
201 $ui_table = $this->ui_factory->table();
203 return $ui_table->data(
205 $this->
lng->txt(
'certificates'),
207 'certificate_id' => $ui_table->column()->text($this->lng->txt(
'certificate_id')),
208 'issue_date' => $ui_table->column()->date($this->lng->txt(
'certificate_issue_date'), $this->user->getDateTimeFormat()),
209 'object' => $ui_table->column()->text($this->lng->txt(
'obj')),
210 'obj_id' => $ui_table->column()->text($this->lng->txt(
'object_id')),
211 'owner' => $ui_table->column()->text($this->lng->txt(
'owner'))
215 ->withId(
'certificateOverviewTable')
216 ->withRequest($this->request)
217 ->withActions($this->buildTableActions());
223 private function buildTableActions(): array
225 $uri_download = $this->data_factory->uri(
226 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
227 ilObjCertificateSettingsGUI::class,
238 $url_builder_download,
239 $action_parameter_token_download,
240 $row_id_token_download
242 (
new URLBuilder($uri_download))->acquireParameters(
249 'download' => $this->ui_factory->table()->action()->single(
250 $this->
lng->txt(
'download'),
251 $url_builder_download->withParameter($action_parameter_token_download,
'download'),
252 $row_id_token_download
267 $object_title_cache = [];
269 foreach ($certificates as $certificate) {
270 if (!isset($ref_id_cache[$certificate->getObjId()])) {
273 $ref_ids = $ref_id_cache[$certificate->getObjId()];
275 if (!isset($object_title_cache[$certificate->getObjId()])) {
277 foreach ($ref_ids as
$refId) {
278 if ($this->
access->checkAccess(
'read',
'', $refId)) {
279 $object_title = $this->ui_renderer->render(
280 $this->ui_factory->link()->standard($object_title, ilLink::_getLink(
$refId))
286 $object_title_cache[$certificate->getObjId()] = $object_title;
291 if (!isset($owner_cache[$certificate->getUserId()])) {
296 'id' => $certificate->getId(),
297 'certificate_id' => $certificate->getCertificateId()->asString(),
298 'issue_date' => $certificate->getAcquiredTimestamp(),
299 'object' => $object_title_cache[$certificate->getObjId()],
300 'obj_id' => (string) $certificate->getObjId(),
301 'owner' => $owner_cache[$certificate->getUserId()],
310 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)
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)
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.