19 declare(strict_types=1);
52 private readonly
string $action,
55 private readonly
bool $has_permission_to_delete =
false,
63 DataRowBuilder $row_builder,
64 array $visible_column_ids,
68 ?array $additional_parameters,
70 $records = $this->
getRecords($range, $order, $filter_data);
71 foreach ($records as $record) {
72 yield $row_builder->buildDataRow((
string) $record[
'code_id'], $record);
78 $query_params_namespace = [
'registration',
'codes'];
79 $table_uri = $this->data_factory->uri(ILIAS_HTTP_PATH .
'/' . $this->action);
82 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
83 $query_params_namespace,
88 return $this->ui_factory->table()
99 ->withRequest($this->http_request)
100 ->withActions($this->
getActions($url_builder, $action_parameter_token, $row_id_token));
108 return $this->code_repository->getTotalCodeCount(
127 [$order_field, $order_direction] = $order->
join(
129 fn(array $ret,
string $key,
string $value): array => [$key, $value]
131 $filter = (
new CodeFilter())->withData($filter_data);
133 $codes_data = $this->code_repository->getCodesData(
141 if (\count($codes_data) === 0 && $range->
getStart() > 0) {
142 $codes_data = $this->code_repository->getCodesData(
152 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
154 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
158 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
165 foreach ($codes_data as $k => $code) {
166 $result[$k][
'code'] = $code[
'code'];
167 $result[$k][
'code_id'] = (
int) $code[
'code_id'];
169 $result[$k][
'generated'] = (
new DateTimeImmutable(
'@' . $code[
'generated']))->setTimezone(
173 $result[$k][
'used'] = $date_format->applyTo(
179 $result[$k][
'used'] =
null;
183 $result[$k][
'role'] = $role_map[$code[
'role']] ?? $this->
lng->txt(
'deleted');
185 $result[$k][
'role'] =
'';
188 if (\is_string($code[
'role_local'])) {
190 foreach (explode(
';', $code[
'role_local']) as $role_id) {
196 if (\count($local)) {
198 $result[$k][
'role_local'] = implode(
'<br />', $local);
201 $result[$k][
'role_local'] =
'';
204 if ($code[
'alimit']) {
205 switch ($code[
'alimit']) {
207 $result[$k][
'alimit'] = $this->
lng->txt(
'reg_access_limitation_none');
211 $result[$k][
'alimit'] = $this->
lng->txt(
'reg_access_limitation_mode_absolute_target') .
213 $date_format->applyTo(
222 $limit = unserialize($code[
'alimitdt'], [
'allowed_classes' =>
false]);
223 if ((
int) $limit[
'd']) {
224 $limit_caption[] = (
int) $limit[
'd'] .
' ' . $this->
lng->txt(
'days');
226 if ((
int) $limit[
'm']) {
227 $limit_caption[] = (
int) $limit[
'm'] .
' ' . $this->
lng->txt(
'months');
229 if ((
int) $limit[
'y']) {
230 $limit_caption[] = (
int) $limit[
'y'] .
' ' . $this->
lng->txt(
'years');
232 if (\count($limit_caption)) {
233 $result[$k][
'alimit'] = $this->
lng->txt(
'reg_access_limitation_mode_relative_target') .
234 ': ' . implode(
', ', $limit_caption);
253 $this->ui_factory->table()->action()->multi(
254 $this->
lng->txt(
'registration_codes_export'),
255 $url_builder->
withParameter($action_parameter_token,
'exportCodes'),
259 if ($this->has_permission_to_delete) {
260 $actions[] = $this->ui_factory->table()->action()->multi(
261 $this->
lng->txt(
'delete'),
262 $url_builder->
withParameter($action_parameter_token,
'deleteConfirmation'),
276 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
278 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
282 'code' => $this->ui_factory->table()->column()
283 ->text($this->
lng->txt(
'registration_code')),
284 'role' => $this->ui_factory->table()->column()
285 ->text($this->
lng->txt(
'registration_codes_roles')),
286 'role_local' => $this->ui_factory->table()->column()
287 ->text($this->
lng->txt(
'registration_codes_roles_local'))
288 ->withIsSortable(
false),
289 'alimit' => $this->ui_factory->table()->column()
290 ->text($this->
lng->txt(
'reg_access_limitations'))
291 ->withIsSortable(
false),
292 'generated' => $this->ui_factory->table()->column()
293 ->date($this->
lng->txt(
'registration_generated'), $date_format),
294 'used' => $this->ui_factory->table()->column()
295 ->text($this->
lng->txt(
'registration_used')),
join($init, callable $fn)
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
sort()
description: > Example for rendering a Sort Glyph.
Both the subject and the direction need to be specified when expressing an order. ...
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
getRecords(Range $range, Order $order, ?array $filter_data)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters,)
A simple class to express a naive range of whole positive numbers.
__construct(private readonly ServerRequestInterface $http_request, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly DataFactory $data_factory, private readonly ilRbacReview $rbac_review, private readonly string $action, private readonly ilObjUser $actor, private readonly RegistrationCodeRepository $code_repository, private readonly bool $has_permission_to_delete=false,)