19declare(strict_types=1);
40use Psr\Http\Message\ServerRequestInterface;
47 private readonly ServerRequestInterface $http_request,
49 private readonly UIFactory $ui_factory,
50 private readonly DataFactory $data_factory,
52 private readonly
string $action,
55 private readonly
bool $has_permission_to_delete =
false,
64 array $visible_column_ids,
67 mixed $additional_viewcontrol_data,
69 mixed $additional_parameters
72 foreach ($records as $record) {
73 yield $row_builder->
buildDataRow((
string) $record[
'code_id'], $record);
77 public function getTableComponent(RegistrationFilterComponent $filter): DataTable
79 $query_params_namespace = [
'registration',
'codes'];
80 $table_uri = $this->data_factory->uri(ILIAS_HTTP_PATH .
'/' . $this->action);
83 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
84 $query_params_namespace,
89 return $this->ui_factory->table()
98 ->withFilter($filter->getFilterData()->getData())
100 ->withRange(
new Range(0, 100))
101 ->withRequest($this->http_request)
102 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token));
109 mixed $additional_viewcontrol_data,
111 mixed $additional_parameters
113 return $this->code_repository->getTotalCodeCount(
132 [$order_field, $order_direction] = $order->
join(
134 fn(array $ret,
string $key,
string $value): array => [$key, $value]
136 $filter = (
new CodeFilter())->withData($filter_data);
138 $codes_data = $this->code_repository->getCodesData(
147 $codes_data = $this->code_repository->getCodesData(
157 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
159 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
163 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
170 foreach ($codes_data as $k => $code) {
171 $result[$k][
'code'] = $code[
'code'];
172 $result[$k][
'code_id'] = (
int) $code[
'code_id'];
174 $result[$k][
'generated'] = (
new DateTimeImmutable(
'@' . $code[
'generated']))->setTimezone(
175 new DateTimeZone($this->actor->getTimeZone())
178 $result[$k][
'used'] = $date_format->applyTo(
179 (
new DateTimeImmutable(
'@' . $code[
'used']))->setTimezone(
180 new DateTimeZone($this->actor->getTimeZone())
184 $result[$k][
'used'] =
null;
188 $result[$k][
'role'] = $role_map[$code[
'role']] ?? $this->
lng->txt(
'deleted');
190 $result[$k][
'role'] =
'';
193 if (\is_string($code[
'role_local'])) {
195 foreach (explode(
';', $code[
'role_local']) as $role_id) {
201 if (\count($local)) {
203 $result[$k][
'role_local'] = implode(
'<br />', $local);
206 $result[$k][
'role_local'] =
'';
209 if ($code[
'alimit']) {
210 switch ($code[
'alimit']) {
212 $result[$k][
'alimit'] = $this->
lng->txt(
'reg_access_limitation_none');
216 $result[$k][
'alimit'] = $this->
lng->txt(
'reg_access_limitation_mode_absolute_target')
219 $code[
'alimitdt'] ===
null
221 : $this->actor->getDateFormat()->applyTo(
222 (
new DateTimeImmutable($code[
'alimitdt']))->setTimezone(
223 new DateTimeZone($this->actor->getTimeZone())
231 $limit = unserialize($code[
'alimitdt'], [
'allowed_classes' =>
false]);
232 if ((
int) $limit[
'd']) {
233 $limit_caption[] = (
int) $limit[
'd'] .
' ' . $this->
lng->txt(
'days');
235 if ((
int) $limit[
'm']) {
236 $limit_caption[] = (
int) $limit[
'm'] .
' ' . $this->
lng->txt(
'months');
238 if ((
int) $limit[
'y']) {
239 $limit_caption[] = (
int) $limit[
'y'] .
' ' . $this->
lng->txt(
'years');
241 if (\count($limit_caption)) {
242 $result[$k][
'alimit'] = $this->
lng->txt(
'reg_access_limitation_mode_relative_target') .
243 ': ' . implode(
', ', $limit_caption);
262 $this->ui_factory->table()->action()->multi(
263 $this->
lng->txt(
'registration_codes_export'),
264 $url_builder->withParameter($action_parameter_token,
'exportCodes'),
268 if ($this->has_permission_to_delete) {
269 $actions[] = $this->ui_factory->table()->action()->multi(
270 $this->
lng->txt(
'delete'),
271 $url_builder->
withParameter($action_parameter_token,
'deleteConfirmation'),
285 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
287 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
291 'code' => $this->ui_factory->table()->column()
292 ->text($this->
lng->txt(
'registration_code')),
293 'role' => $this->ui_factory->table()->column()
294 ->text($this->
lng->txt(
'registration_codes_roles')),
295 'role_local' => $this->ui_factory->table()->column()
296 ->text($this->
lng->txt(
'registration_codes_roles_local'))
297 ->withIsSortable(
false),
298 'alimit' => $this->ui_factory->table()->column()
299 ->text($this->
lng->txt(
'reg_access_limitations'))
300 ->withIsSortable(
false),
301 'generated' => $this->ui_factory->table()->column()
302 ->date($this->
lng->txt(
'registration_generated'), $date_format),
303 'used' => $this->ui_factory->table()->column()
304 ->text($this->
lng->txt(
'registration_used')),
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
join($init, callable $fn)
A simple class to express a naive range of whole positive numbers.
getRecords(Range $range, Order $order, ?array $filter_data)
__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,)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Stores all calendar relevant settings.
Class ilObject Basic functions for all objects.
static _lookupTitle(int $obj_id)
class ilRbacReview Contains Review functions of core Rbac.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A Column describes the form of presentation for a certain aspect of data, i.e.
buildDataRow(string $id, array $record)
This describes a Data Table.