ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RegistrationFilterComponent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Registration;
22
23use ilObject;
24use ilDateTime;
25use ilLanguage;
26use ilUIService;
27use ilRbacReview;
30use ILIAS\UI\Factory as UIFactory;
34
36{
37 protected FilterComponent $filter;
38
39 public function __construct(
40 private readonly string $action,
41 private readonly UIFactory $ui_factory,
42 private readonly ilUIService $ui_service,
43 private readonly ilLanguage $lng,
44 private readonly ilRbacReview $rbac_review,
45 private readonly RegistrationCodeRepository $code_repository,
46 ) {
47 $filter_inputs = [];
48 $is_input_initially_rendered = [];
49 $field_factory = $this->ui_factory->input()->field();
50
51 foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
52 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
53 }
54
55 $this->filter = $this->ui_service->filter()->standard(
56 'participant_filter',
57 $this->action,
58 $filter_inputs,
59 $is_input_initially_rendered,
60 true,
61 true
62 );
63 }
64
65 public function getFilterComponent(): FilterComponent
66 {
67 return $this->filter;
68 }
69
70 public function getFilterData(): CodeFilter
71 {
72 return (new CodeFilter())->withData($this->ui_service->filter()->getData($this->filter));
73 }
74
78 public function getFilterFields(Factory $field_factory): array
79 {
80 $filters = [
81 'code' => [
82 $field_factory->text($this->lng->txt('registration_code'))->withMaxLength(
84 ),
85 true
86 ],
87 ];
88 $role_map = [];
89 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
90 if (!\in_array($role_id, [SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID], true)) {
91 $role_map[$role_id] = ilObject::_lookupTitle($role_id);
92 }
93 }
94
95 $options = ['' => $this->lng->txt('registration_roles_all')] + $role_map;
96 $filters['role'] = [$field_factory->select($this->lng->txt('role'), $options), true];
97
98 $options = [
99 '' => $this->lng->txt('registration_codes_access_limitation_all'),
100 'unlimited' => $this->lng->txt('reg_access_limitation_none'),
101 'absolute' => $this->lng->txt('reg_access_limitation_mode_absolute'),
102 'relative' => $this->lng->txt('reg_access_limitation_mode_relative')
103 ];
104 $filters['alimit'] = [$field_factory->select($this->lng->txt('reg_access_limitations'), $options), true];
105
106 $options = ['' => $this->lng->txt('registration_generated_all')];
107 foreach ($this->code_repository->getGenerationDates() as $date) {
108 $options[$date] = ilDatePresentation::formatDate(new ilDateTime($date, IL_CAL_UNIX));
109 }
110 $filters['generated'] = [$field_factory->select($this->lng->txt('registration_generated'), $options), true];
111
112 return $filters;
113 }
114}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
__construct(private readonly string $action, private readonly UIFactory $ui_factory, private readonly ilUIService $ui_service, private readonly ilLanguage $lng, private readonly ilRbacReview $rbac_review, private readonly RegistrationCodeRepository $code_repository,)
const IL_CAL_UNIX
return true
Class for date presentation.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
language handling
Class ilObject Basic functions for all objects.
static _lookupTitle(int $obj_id)
class ilRbacReview Contains Review functions of core Rbac.
Class ilRegistrationCode.
Filter service.
const SYSTEM_ROLE_ID
Definition: constants.php:29
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
This interface must be implemented by all Inputs that support Filter Containers.
Definition: FilterInput.php:36
This describes a standard filter.
Definition: Standard.php:27
This is what a factory for input fields looks like.
Definition: Factory.php:31
select(string $label, array $options, ?string $byline=null)
text(string $label, ?string $byline=null)
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $lng
Definition: privfeed.php:31