ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 256 of file RegistrationCodesTable.php.

260 : array {
261 $actions = [
262 $this->ui_factory->table()->action()->multi(
263 $this->lng->txt('registration_codes_export'),
264 $url_builder->withParameter($action_parameter_token, 'exportCodes'),
265 $row_id_token
266 ),
267 ];
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'),
272 $row_id_token
273 );
274 }
275
276 return $actions;
277 }
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 282 of file RegistrationCodesTable.php.

282 : array
283 {
284 if ((int) $this->actor->getTimeFormat() === ilCalendarSettings::TIME_FORMAT_12) {
285 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
286 } else {
287 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
288 }
289
290 return [
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')),
305 ];
306 }

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 130 of file RegistrationCodesTable.php.

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

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

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