19 declare(strict_types=1);
61 private readonly \ILIAS\UI\Component\Input\Container\Filter\Standard
$filter;
81 $this->ui_factory = $ui_factory ?: $DIC->ui()->factory();
83 $this->ui_service = $ui_service ?: $DIC->uiService();
84 $this->
lng = $lng ?: $DIC->language();
85 $this->request = $request ?: $DIC->http()->request();
86 $this->data_factory = $data_factory ?: new \ILIAS\Data\Factory();
87 $this->
ctrl = $ctrl ?: $DIC->ctrl();
88 $this->ui_renderer = $ui_renderer ?: $DIC->ui()->renderer();
89 $this->
access = $access ?: $DIC->access();
90 $this->
user = $user ?: $DIC->user();
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]);
112 $table_rows = $this->
buildTableRows($this->repo->fetchCertificatesForOverview(
113 $this->user->getLanguage(),
120 foreach ($table_rows as $row) {
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);
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");
149 $filter_data[
'issue_date'] = [
154 $filter_data[
'issue_date'] = [
167 return $this->repo->fetchCertificatesForOverviewCount($ui_filter_data);
174 $date_format = $this->data_factory->dateFormat()->withTime12($this->
user->getDateFormat());
176 $date_format = $this->data_factory->dateFormat()->withTime24($this->
user->getDateFormat());
179 return $this->ui_service->filter()->standard(
180 'certificates_overview_filter',
181 $this->
ctrl->getLinkTargetByClass(
182 ilObjCertificateSettingsGUI::class,
186 'certificate_id' => $this->ui_factory->input()->field()->text($this->
lng->txt(
'certificate_id')),
187 'issue_date' => $this->ui_factory->input()->field()
188 ->duration($this->
lng->txt(
'certificate_issue_date'))
189 ->withFormat($date_format)
191 'object' => $this->ui_factory->input()->field()->text($this->
lng->txt(
'obj')),
192 'obj_id' => $this->ui_factory->input()->field()->text($this->
lng->txt(
'object_id')),
193 'owner' => $this->ui_factory->input()->field()->text($this->
lng->txt(
'owner')),
195 [
true,
true,
true,
true,
true],
203 $ui_table = $this->ui_factory->table();
206 $date_format = $this->data_factory->dateFormat()->withTime12($this->
user->getDateFormat());
208 $date_format = $this->data_factory->dateFormat()->withTime24($this->
user->getDateFormat());
210 return $ui_table->data(
212 $this->
lng->txt(
'certificates'),
214 'certificate_id' => $ui_table->column()->text($this->
lng->txt(
'certificate_id')),
215 'issue_date' => $ui_table->column()->date($this->
lng->txt(
'certificate_issue_date'), $date_format),
216 'object' => $ui_table->column()->text($this->
lng->txt(
'obj')),
217 'obj_id' => $ui_table->column()->text($this->
lng->txt(
'object_id')),
218 'owner' => $ui_table->column()->text($this->
lng->txt(
'owner'))
222 ->withId(
'certificateOverviewTable')
223 ->withRequest($this->request)
224 ->withActions($this->buildTableActions());
230 private function buildTableActions(): array
232 $uri_download = $this->data_factory->uri(
233 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
234 ilObjCertificateSettingsGUI::class,
245 $url_builder_download,
246 $action_parameter_token_download,
247 $row_id_token_download
249 (
new URLBuilder($uri_download))->acquireParameters(
256 'download' => $this->ui_factory->table()->action()->single(
257 $this->
lng->txt(
'download'),
258 $url_builder_download->withParameter($action_parameter_token_download,
'download'),
259 $row_id_token_download
274 $object_title_cache = [];
276 foreach ($certificates as $certificate) {
277 if (!isset($ref_id_cache[$certificate->getObjId()])) {
280 $ref_ids = $ref_id_cache[$certificate->getObjId()];
282 if (!isset($object_title_cache[$certificate->getObjId()])) {
284 foreach ($ref_ids as
$refId) {
285 if ($this->
access->checkAccess(
'read',
'', $refId)) {
286 $object_title = $this->ui_renderer->render(
287 $this->ui_factory->link()->standard($object_title, ilLink::_getLink($refId))
293 $object_title_cache[$certificate->getObjId()] = $object_title;
298 if (!isset($owner_cache[$certificate->getUserId()])) {
303 'id' => $certificate->getId(),
304 'certificate_id' => $certificate->getCertificateId()->asString(),
305 'issue_date' => $certificate->getAcquiredTimestamp(),
306 'object' => $object_title_cache[$certificate->getObjId()],
307 'obj_id' => (string) $certificate->getObjId(),
308 'owner' => $owner_cache[$certificate->getUserId()],
317 return $this->ui_renderer->render([$this->
filter, $this->table]);
const CMD_CERTIFICATES_OVERVIEW
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...
join($init, callable $fn)
readonly ilUserCertificateRepository $repo
readonly DateTimeZone $user_timezone
Interface Observer Contains several chained tasks and infos about them.
static _getAllReferences(int $id)
get all reference ids for object ID
readonly Renderer $ui_renderer
const CMD_DOWNLOAD_CERTIFICATE
Both the subject and the direction need to be specified when expressing an order. ...
buildDataRow(string $id, array $record)
readonly ILIAS UI Component Input Container Filter Standard $filter
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $obj_id)
This is how the factory for UI elements looks.
mapUiFilterData(array $filter_data)
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...
readonly ILIAS Data Factory $data_factory
__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 Factory $ui_factory
readonly ServerRequestInterface $request
readonly ilAccessHandler $access
readonly ilUIService $ui_service
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
A simple class to express a naive range of whole positive numbers.
readonly ilCtrl ilCtrlInterface $ctrl
static _lookupLogin(int $a_user_id)