ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Registration\RegistrationCodesTable Class Reference
+ Inheritance diagram for ILIAS\Registration\RegistrationCodesTable:
+ Collaboration diagram for ILIAS\Registration\RegistrationCodesTable:

Public Member Functions

 __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)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
 
 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.g. More...
 
 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 records available. More...
 

Private Member Functions

 getRecords (Range $range, Order $order, ?array $filter_data)
 
 getColumns ()
 

Detailed Description

Definition at line 44 of file RegistrationCodesTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Registration\RegistrationCodesTable::__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 
)

Definition at line 46 of file RegistrationCodesTable.php.

56 {
57 }

Member Function Documentation

◆ getActions()

ILIAS\Registration\RegistrationCodesTable::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
Returns
array<string, Action>

Definition at line 255 of file RegistrationCodesTable.php.

259 : array {
260 $actions = [
261 $this->ui_factory->table()->action()->multi(
262 $this->lng->txt('registration_codes_export'),
263 $url_builder->withParameter($action_parameter_token, 'exportCodes'),
264 $row_id_token
265 ),
266 ];
267 if ($this->has_permission_to_delete) {
268 $actions[] = $this->ui_factory->table()->action()->multi(
269 $this->lng->txt('delete'),
270 $url_builder->withParameter($action_parameter_token, 'deleteConfirmation'),
271 $row_id_token
272 );
273 }
274
275 return $actions;
276 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

References ILIAS\Repository\lng(), and ILIAS\UI\URLBuilder\withParameter().

+ Here is the call graph for this function:

◆ getColumns()

ILIAS\Registration\RegistrationCodesTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 281 of file RegistrationCodesTable.php.

281 : array
282 {
283 if ((int) $this->actor->getTimeFormat() === ilCalendarSettings::TIME_FORMAT_12) {
284 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
285 } else {
286 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
287 }
288
289 return [
290 'code' => $this->ui_factory->table()->column()
291 ->text($this->lng->txt('registration_code')),
292 'role' => $this->ui_factory->table()->column()
293 ->text($this->lng->txt('registration_codes_roles')),
294 'role_local' => $this->ui_factory->table()->column()
295 ->text($this->lng->txt('registration_codes_roles_local'))
296 ->withIsSortable(false),
297 'alimit' => $this->ui_factory->table()->column()
298 ->text($this->lng->txt('reg_access_limitations'))
299 ->withIsSortable(false),
300 'generated' => $this->ui_factory->table()->column()
301 ->date($this->lng->txt('registration_generated'), $date_format),
302 'used' => $this->ui_factory->table()->column()
303 ->text($this->lng->txt('registration_used')),
304 ];
305 }

References ILIAS\Repository\lng(), and ilCalendarSettings\TIME_FORMAT_12.

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\Registration\RegistrationCodesTable::getRecords ( Range  $range,
Order  $order,
?array  $filter_data 
)
private
Parameters
array{codestring, role: int, generated: string, access_limitation: string} $filter_data
Returns
list<array{ code: string, code_id: int, generated: DateTimeImmutable, used: string|null, role: string, role_local: string|null, alimit: string|null }>

Definition at line 129 of file RegistrationCodesTable.php.

129 : array
130 {
131 [$order_field, $order_direction] = $order->join(
132 [],
133 fn(array $ret, string $key, string $value): array => [$key, $value]
134 );
135 $filter = (new CodeFilter())->withData($filter_data);
136
137 $codes_data = $this->code_repository->getCodesData(
138 $order_field,
139 $order_direction,
140 $range->getStart(),
141 $range->getLength(),
142 $filter
143 );
144
145 if (\count($codes_data) === 0 && $range->getStart() > 0) {
146 $codes_data = $this->code_repository->getCodesData(
147 $order_field,
148 $order_direction,
149 0,
150 $range->getLength(),
151 $filter
152 );
153 }
154
155 if ((int) $this->actor->getTimeFormat() === ilCalendarSettings::TIME_FORMAT_12) {
156 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
157 } else {
158 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
159 }
160
161 $role_map = [];
162 foreach ($this->rbac_review->getGlobalRoles() as $role_id) {
163 if (!\in_array($role_id, [SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID], true)) {
164 $role_map[$role_id] = ilObject::_lookupTitle($role_id);
165 }
166 }
167
168 $result = [];
169 foreach ($codes_data as $k => $code) {
170 $result[$k]['code'] = $code['code'];
171 $result[$k]['code_id'] = (int) $code['code_id'];
172
173 $result[$k]['generated'] = (new DateTimeImmutable('@' . $code['generated']))->setTimezone(
174 new DateTimeZone($this->actor->getTimeZone())
175 );
176 if ($code['used']) {
177 $result[$k]['used'] = $date_format->applyTo(
178 (new DateTimeImmutable('@' . $code['used']))->setTimezone(
179 new DateTimeZone($this->actor->getTimeZone())
180 )
181 );
182 } else {
183 $result[$k]['used'] = null;
184 }
185
186 if ($code['role']) {
187 $result[$k]['role'] = $role_map[$code['role']] ?? $this->lng->txt('deleted');
188 } else {
189 $result[$k]['role'] = '';
190 }
191
192 if (\is_string($code['role_local'])) {
193 $local = [];
194 foreach (explode(';', $code['role_local']) as $role_id) {
195 $role = ilObject::_lookupTitle((int) $role_id);
196 if ($role) {
197 $local[] = $role;
198 }
199 }
200 if (\count($local)) {
201 sort($local);
202 $result[$k]['role_local'] = implode('<br />', $local);
203 }
204 } else {
205 $result[$k]['role_local'] = '';
206 }
207
208 if ($code['alimit']) {
209 switch ($code['alimit']) {
210 case 'unlimited':
211 $result[$k]['alimit'] = $this->lng->txt('reg_access_limitation_none');
212 break;
213
214 case 'absolute':
215 $result[$k]['alimit'] = $this->lng->txt('reg_access_limitation_mode_absolute_target')
216 . ': '
217 . (
218 $code['alimitdt'] === null
219 ? '-'
220 : $this->actor->getDateFormat()->applyTo(
221 (new DateTimeImmutable($code['alimitdt']))->setTimezone(
222 new DateTimeZone($this->actor->getTimeZone())
223 )
224 )
225 );
226 break;
227
228 case 'relative':
229 $limit_caption = [];
230 $limit = unserialize($code['alimitdt'], ['allowed_classes' => false]);
231 if ((int) $limit['d']) {
232 $limit_caption[] = (int) $limit['d'] . ' ' . $this->lng->txt('days');
233 }
234 if ((int) $limit['m']) {
235 $limit_caption[] = (int) $limit['m'] . ' ' . $this->lng->txt('months');
236 }
237 if ((int) $limit['y']) {
238 $limit_caption[] = (int) $limit['y'] . ' ' . $this->lng->txt('years');
239 }
240 if (\count($limit_caption)) {
241 $result[$k]['alimit'] = $this->lng->txt('reg_access_limitation_mode_relative_target') .
242 ': ' . implode(', ', $limit_caption);
243 }
244 break;
245 }
246 }
247 }
248
249 return $result;
250 }
join($init, callable $fn)
Definition: Order.php:75
static _lookupTitle(int $obj_id)
const SYSTEM_ROLE_ID
Definition: constants.php:29
const ANONYMOUS_ROLE_ID
Definition: constants.php:28

References ILIAS\UI\Implementation\Component\Table\$range, ilObject\_lookupTitle(), ANONYMOUS_ROLE_ID, ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), ILIAS\Repository\int(), ILIAS\Data\Order\join(), ILIAS\Repository\lng(), ILIAS\UI\examples\Symbol\Glyph\Sort\sort(), SYSTEM_ROLE_ID, and ilCalendarSettings\TIME_FORMAT_12.

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Registration\RegistrationCodesTable::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
Parameters
array{codestring, role: int, generated: string, access_limitation: string} $filter_data

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 62 of file RegistrationCodesTable.php.

70 : Generator {
71 $records = $this->getRecords($range, $order, $filter_data);
72 foreach ($records as $record) {
73 yield $row_builder->buildDataRow((string) $record['code_id'], $record);
74 }
75 }
getRecords(Range $range, Order $order, ?array $filter_data)
buildDataRow(string $id, array $record)

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Registration\RegistrationCodesTable::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
Parameters
array{codestring, role: int, generated: string, access_limitation: string} $filter_data

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 107 of file RegistrationCodesTable.php.

111 : ?int {
112 return $this->code_repository->getTotalCodeCount(
113 (new CodeFilter())->withData($filter_data)
114 );
115 }

The documentation for this class was generated from the following file: