ILIAS  trunk Revision v12.0_alpha-1613-gae4c99ebb18
ILIAS\BookingManager\Bookings\Table\BookingsTable Class Reference
+ Inheritance diagram for ILIAS\BookingManager\Bookings\Table\BookingsTable:
+ Collaboration diagram for ILIAS\BookingManager\Bookings\Table\BookingsTable:

Public Member Functions

 __construct (protected readonly UIFactory $ui_factory, protected readonly UIRenderer $ui_renderer, protected readonly AccessManager $access, protected readonly ilGlobalTemplateInterface $tpl, protected readonly Refinery $refinery, protected readonly Language $lng, protected readonly HttpService $http, protected readonly ilObjUser $user, protected readonly ReservationDBRepository $reservation_repository, protected readonly ilCtrlInterface $ctrl, protected readonly ilUIService $ui_service, protected readonly Settings $settings, protected readonly ilObjBookingPool $booking_pool)
 
 getTableId ()
 
 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...
 
 getFilter ()
 
 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...
 
 getComponents (URLBuilder $url_builder)
 
- Public Member Functions inherited from ILIAS\BookingManager\Common\Table\Table
 getTableId ()
 
 execute (URLBuilder $url_builder)
 
 getComponents (URLBuilder $url_builder)
 
 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...
 

Data Fields

const ROW_ID_PARAMETER = 'booking_id'
 
const ACTION_PARAMETER = 'action'
 
const ACTION_TYPE_PARAMETER = 'action_type'
 

Protected Member Functions

 getUserPresentationName (int $user_id)
 
 getColumns ()
 
 getFilterInputs ()
 
 loadRecords (mixed $filter_data)
 
 sortRecords (Order $order, array $records)
 
 limitRecords (Range $range, array $records)
 
 acquireParameters (URLBuilder $url_builder)
 
 getUsers (?int $user_id=null)
 
 getStatuses ()
 
 getTableActions ()
 
 getUserComponent (int $user_id)
 
 getBookingTimeSlotFilterLabel (array $booking)
 

Protected Attributes

readonly array $booking_items
 
readonly array $bookings
 
readonly array $participants
 
readonly ColumnFactory $column_factory
 
readonly InputFactory $input_factory
 

Private Member Functions

 presetFilterInputs (array $filter_inputs)
 
 getTable (URLBuilder $url_builder)
 
 getExportDropdown ()
 
 resolveBookingPeriodBounds (mixed $period)
 
 parseBookingPeriodValue (mixed $value)
 

Detailed Description

Definition at line 63 of file BookingsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BookingManager\Bookings\Table\BookingsTable::__construct ( protected readonly UIFactory  $ui_factory,
protected readonly UIRenderer  $ui_renderer,
protected readonly AccessManager  $access,
protected readonly ilGlobalTemplateInterface  $tpl,
protected readonly Refinery  $refinery,
protected readonly Language  $lng,
protected readonly HttpService  $http,
protected readonly ilObjUser  $user,
protected readonly ReservationDBRepository  $reservation_repository,
protected readonly ilCtrlInterface  $ctrl,
protected readonly ilUIService  $ui_service,
protected readonly Settings  $settings,
protected readonly ilObjBookingPool  $booking_pool 
)

Definition at line 83 of file BookingsTable.php.

97 {
98 $this->booking_items = array_column(
99 ilBookingObject::getList($this->booking_pool->getId()),
100 null,
101 'booking_object_id'
102 );
103
104 $filter = [];
105 if (
106 !$this->access->canManageAllReservations($this->booking_pool->getRefId())
107 && !$this->access->canReadPublicLog($this->booking_pool->getRefId())
108 ) {
109 $filter['user_id'] = $this->user->getId();
110 }
111 $this->bookings = array_column(
112 ilBookingReservation::getList(array_keys($this->booking_items), 1000, 0, $filter)['data'],
113 null,
114 'booking_reservation_id'
115 );
116
117 $this->participants = array_column(
118 ilBookingParticipant::getList($this->booking_pool->getId()),
119 null,
120 'user_id'
121 );
122
123 foreach (['dateplaner', 'tbl'] as $module) {
124 $this->lng->loadLanguageModule($module);
125 }
126
127 $this->column_factory = $this->ui_factory->table()->column();
128 $this->input_factory = $this->ui_factory->input()->field();
129 }
static getList(int $a_pool_id, ?string $a_title=null)
Get list of booking objects.
static getList(int $a_booking_pool, ?array $a_filter=null, ?int $a_object_id=null)
static getList(array $a_object_ids, int $a_limit=10, int $a_offset=0, array $filter=[])
List all reservations.

References ILIAS\Repository\access(), ilBookingReservation\getList(), ilBookingParticipant\getList(), ilBookingObject\getList(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ acquireParameters()

ILIAS\BookingManager\Bookings\Table\BookingsTable::acquireParameters ( URLBuilder  $url_builder)
protected

Definition at line 376 of file BookingsTable.php.

376 : array
377 {
378 return $url_builder->acquireParameters(
379 [$this->getTableId()],
380 self::ROW_ID_PARAMETER,
381 self::ACTION_PARAMETER,
382 self::ACTION_TYPE_PARAMETER
383 );
384 }
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138

References ILIAS\UI\URLBuilder\acquireParameters().

+ Here is the call graph for this function:

◆ getBookingTimeSlotFilterLabel()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getBookingTimeSlotFilterLabel ( array  $booking)
protected

Reimplemented in ILIAS\BookingManager\Bookings\Table\BookingsWithScheduleTable.

Definition at line 517 of file BookingsTable.php.

517 : string
518 {
519 $date_from = new DateTimeImmutable("@{$booking['date_from']}");
520 $date_to = new DateTimeImmutable('@' . ((int) $booking['date_to'] + 1));
521
522 return "{$date_from->format('H:i')} - {$date_to->format('H:i')}";
523 }

Referenced by ILIAS\BookingManager\Bookings\Table\BookingsTable\loadRecords(), and ILIAS\BookingManager\Bookings\Table\BookingsTable\sortRecords().

+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getColumns ( )
abstractprotected

◆ getComponents()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getComponents ( URLBuilder  $url_builder)
Returns
array<Component>

Implements ILIAS\BookingManager\Common\Table\Table.

Definition at line 369 of file BookingsTable.php.

369 : array
370 {
371 $filter = $this->getFilter();
372 $table = $this->getTable($url_builder)->withFilter($filter);
373 return array_filter([$filter, $table, $this->ui_factory->divider()->horizontal(), $this->getExportDropdown()]);
374 }

◆ getExportDropdown()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getExportDropdown ( )
private

Definition at line 399 of file BookingsTable.php.

399 : StandardDropdown
400 {
401 $parameter = "bkrsv{$this->booking_pool->getRefId()}_xpt";
402 $export_formats = [ilTable2GUI::EXPORT_EXCEL => 'tbl_export_excel' , ilTable2GUI::EXPORT_CSV => 'tbl_export_csv'];
403 $actions = [];
404
405 foreach ($export_formats as $format => $caption_lng_id) {
406 $this->ctrl->setParameterByClass(ilBookingReservationsGUI::class, $parameter, $format);
407 $actions[] = $this->ui_factory->link()->standard(
408 $this->lng->txt($caption_lng_id),
409 $this->ctrl->getLinkTargetByClass(
410 ilBookingReservationsGUI::class,
412 )
413 );
414 $this->ctrl->setParameterByClass(ilBookingReservationsGUI::class, $parameter, null);
415 }
416
417 return $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('export'));
418 }

References ILIAS\Repository\ctrl(), ilBookingReservationsGUI\DEFAULT_CMD, ilTable2GUI\EXPORT_CSV, ilTable2GUI\EXPORT_EXCEL, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getFilter()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getFilter ( )

Definition at line 294 of file BookingsTable.php.

294 : ?Filter
295 {
296 $filter_inputs = $this->getFilterInputs();
297
298 $filter_inputs = $this->presetFilterInputs($filter_inputs);
299
300 if ($filter_inputs === []) {
301 return null;
302 }
303
304 return $this->ui_service->filter()->standard(
305 "{$this->getTableId()}_filter",
306 $this->ctrl->getLinkTargetByClass(ilBookingReservationsGUI::class),
307 $filter_inputs,
308 array_fill(0, count($filter_inputs), true),
309 true,
310 true
311 );
312 }

References ILIAS\Repository\ctrl(), ILIAS\BookingManager\Bookings\Table\BookingsTable\getFilterInputs(), and ILIAS\BookingManager\Bookings\Table\BookingsTable\presetFilterInputs().

+ Here is the call graph for this function:

◆ getFilterInputs()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getFilterInputs ( )
abstractprotected

◆ getRows()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
abstract

This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Reimplemented in ILIAS\BookingManager\Bookings\Table\BookingsWithoutScheduleTable, and ILIAS\BookingManager\Bookings\Table\BookingsWithScheduleTable.

◆ getStatuses()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getStatuses ( )
protected
Returns
array<string, string>

Definition at line 438 of file BookingsTable.php.

438 : array
439 {
440 return [
441 ilBookingReservation::STATUS_IN_USE => $this->lng->txt('book_not_cancelled'),
442 ilBookingReservation::STATUS_CANCELLED => $this->lng->txt('book_reservation_status_5')
443 ];
444 }

References ILIAS\Repository\lng(), ilBookingReservation\STATUS_CANCELLED, and ilBookingReservation\STATUS_IN_USE.

+ Here is the call graph for this function:

◆ getTable()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getTable ( URLBuilder  $url_builder)
private

Definition at line 386 of file BookingsTable.php.

386 : Data
387 {
388 return
389 $this->ui_factory->table()->data(
390 $this,
391 $this->lng->txt('bookings'),
392 $this->getColumns()
393 )
394 ->withActions($this->getTableActions()->getEnabledActions(...$this->acquireParameters($url_builder)))
395 ->withRequest($this->http->getRequest())
396 ->withId($this->getTableId());
397 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\BookingManager\Common\Table\getTableActions(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\UI\Component\Table\Data\withActions().

+ Here is the call graph for this function:

◆ getTableActions()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getTableActions ( )
protected

Definition at line 446 of file BookingsTable.php.

446 : TableActions
447 {
448 return (new BookingTableActionsFactory(
449 $this->ctrl,
450 $this->lng,
451 $this->tpl,
452 $this->ui_factory,
453 $this->ui_renderer,
454 $this->refinery,
455 $this->http,
456 $this->access,
457 $this->reservation_repository,
458 $this->booking_pool,
459 $this->bookings
460 ))->getTableActions();
461 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by ILIAS\BookingManager\Bookings\Table\BookingsWithoutScheduleTable\getRows(), and ILIAS\BookingManager\Bookings\Table\BookingsWithScheduleTable\getRows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableId()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getTableId ( )

Implements ILIAS\BookingManager\Common\Table\Table.

Definition at line 131 of file BookingsTable.php.

131 : string
132 {
133 return static::ID;
134 }

◆ getTotalRowCount()

ILIAS\BookingManager\Bookings\Table\BookingsTable::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.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 361 of file BookingsTable.php.

365 : ?int {
366 return count($this->bookings);
367 }

◆ getUserComponent()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getUserComponent ( int  $user_id)
protected

Definition at line 463 of file BookingsTable.php.

464 {
465 $user_name = $this->getUserPresentationName($user_id);
467 return $this->ui_factory->link()->standard($user_name, '')->withDisabled(true);
468 }
469
470 $this->ctrl->setParameterByClass(PublicProfileGUI::class, 'user_id', $user_id);
471
472 return $this->ui_factory->link()->standard(
473 $user_name,
474 $this->ctrl->getLinkTargetByClass(
475 [ilPublicProfileBaseClassGUI::class, PublicProfileGUI::class],
476 'getHTML'
477 )
478 );
479 }
static hasPublicProfile(int $a_user_id)

References $user_id, ILIAS\Repository\ctrl(), and ilUserUtil\hasPublicProfile().

+ Here is the call graph for this function:

◆ getUserPresentationName()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getUserPresentationName ( int  $user_id)
protected

Definition at line 136 of file BookingsTable.php.

136 : string
137 {
138 return str_replace('&', '&amp;', htmlentities(ilUserUtil::getNamePresentation($user_id)));
139 }
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:

References $user_id, and ilUserUtil\getNamePresentation().

Referenced by ILIAS\BookingManager\Bookings\Table\BookingsTable\sortRecords().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsers()

ILIAS\BookingManager\Bookings\Table\BookingsTable::getUsers ( ?int  $user_id = null)
protected
Returns
string[]

Definition at line 423 of file BookingsTable.php.

423 : array
424 {
425 if (is_int($user_id)) {
426 return [$user_id => $this->getUserPresentationName($user_id)];
427 }
428
429 return array_map(
430 fn(array $participant): string => $this->getUserPresentationName($participant['user_id']),
431 $this->participants
432 );
433 }

References $user_id.

◆ limitRecords()

ILIAS\BookingManager\Bookings\Table\BookingsTable::limitRecords ( Range  $range,
array  $records 
)
protected

Definition at line 289 of file BookingsTable.php.

289 : array
290 {
291 return array_slice($records, $range->getStart(), $range->getLength());
292 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

◆ loadRecords()

ILIAS\BookingManager\Bookings\Table\BookingsTable::loadRecords ( mixed  $filter_data)
protected

Definition at line 155 of file BookingsTable.php.

155 : array
156 {
157 if (!$filter_data instanceof Filter) {
158 return $this->bookings;
159 }
160
162
163 foreach ($this->ui_service->filter()->getData($filter_data) ?? [] as $key => $filter_data_value) {
164 if ($filter_data_value === null || $filter_data_value === '') {
165 continue;
166 }
167
168 $bookings = (match ($key) {
169 'object' => static fn(array $bookings): array => array_filter(
170 $bookings,
171 static fn(array $booking): bool => (int) $booking['object_id'] === (int) $filter_data_value
172 ),
173 'object_title_or_description' => static fn(array $bookings): array => array_filter(
174 $bookings,
175 static function (array $booking) use ($filter_data_value): bool {
176 $filter_data_value = strtolower($filter_data_value);
177 return
178 str_contains(strtolower($booking['title']), $filter_data_value)
179 || str_contains(strtolower($booking['message']), $filter_data_value);
180 }
181 ),
182 'period' => function (array $bookings) use ($filter_data_value): array {
183 $bounds = $this->resolveBookingPeriodBounds($filter_data_value);
184 if ($bounds === null) {
185 return $bookings;
186 }
187
188 [$period_from, $period_to] = $bounds;
189 return array_filter(
190 $bookings,
191 static fn(array $booking): bool =>
192 $booking['date_from'] >= $period_from && $booking['date_to'] <= $period_to
193 );
194 },
195 'time_slot' => fn(array $bookings): array => array_filter(
196 $bookings,
197 fn(array $booking): bool => $this->getBookingTimeSlotFilterLabel($booking) === $filter_data_value
198 ),
199 'past_bookings' => static function (array $bookings) use ($filter_data_value): array {
200 $now = new DateTimeImmutable();
201 return array_filter(
202 $bookings,
203 static fn(array $booking): bool => (int) $filter_data_value === 1
204 ? new DateTimeImmutable("@{$booking['date_to']}") < $now
205 : new DateTimeImmutable("@{$booking['date_to']}") >= $now
206 );
207 },
208 'status' => static fn(array $bookings): array => array_filter(
209 $bookings,
210 static fn(array $booking): bool => match ((int) $filter_data_value) {
212 $booking['status'] === ilBookingReservation::STATUS_IN_USE || $booking['status'] === 0,
214 $booking['status'] === ilBookingReservation::STATUS_CANCELLED,
215 default => true
216 }
217 ),
218 'user' => static fn(array $bookings): array => array_filter(
219 $bookings,
220 static fn(array $booking): bool => (int) $booking['user_id'] === (int) $filter_data_value
221 ),
222 default => static fn(array $bookings): array => $bookings
223 })($bookings);
224 }
225
226 return $bookings;
227 }

References ILIAS\BookingManager\Bookings\Table\BookingsTable\$bookings, ILIAS\BookingManager\Bookings\Table\BookingsTable\getBookingTimeSlotFilterLabel(), ILIAS\BookingManager\Bookings\Table\BookingsTable\resolveBookingPeriodBounds(), ilBookingReservation\STATUS_CANCELLED, and ilBookingReservation\STATUS_IN_USE.

+ Here is the call graph for this function:

◆ parseBookingPeriodValue()

ILIAS\BookingManager\Bookings\Table\BookingsTable::parseBookingPeriodValue ( mixed  $value)
private

Definition at line 500 of file BookingsTable.php.

500 : ?int
501 {
502 if (!$value) {
503 return null;
504 }
505
506 if ($value instanceof DateTimeImmutable) {
507 return $value->getTimestamp();
508 }
509
510 try {
511 return (new DateTimeImmutable((string) $value))->getTimestamp();
512 } catch (Throwable) {
513 return null;
514 }
515 }

◆ presetFilterInputs()

ILIAS\BookingManager\Bookings\Table\BookingsTable::presetFilterInputs ( array  $filter_inputs)
private

Definition at line 314 of file BookingsTable.php.

314 : array
315 {
316 $query_params = $this->http->getRequest()->getQueryParams();
317
318 if (
319 $this->access->canManageAllReservations($this->booking_pool->getRefId())
320 || $this->access->canReadPublicLog($this->booking_pool->getRefId())
321 ) {
322 $user_id = $query_params['user_id'] ?? null;
323 if (is_numeric($user_id)) {
324 $filter_inputs['user'] = $filter_inputs['user']->withValue((int) $user_id);
325 }
326 } elseif ($this->access->canManageOwnReservations($this->booking_pool->getRefId())) {
327 $filter_inputs['user'] = $filter_inputs['user']->withValue($this->user->getId());
328 }
329
330 $object_id = $query_params['object_id'] ?? null;
331 if (is_numeric($object_id)) {
332 $filter_inputs['object'] = $filter_inputs['object']->withValue((int) $object_id);
333 }
334
335 if ($this->settings->getReservationPeriod() > 0) {
336 $filter_inputs['period'] = $filter_inputs['period']->withValue(
337 [
338 new DateTimeImmutable('today 00:00:00'),
339 new DateTimeImmutable("today +{$this->settings->getReservationPeriod()} days 23:59:59")
340 ]
341 );
342 }
343
344 $period_from = $query_params['period_from'] ?? null;
345 $period_to = $query_params['period_to'] ?? null;
346 if (is_numeric($period_from) && is_numeric($period_to)) {
347 $filter_inputs['period'] = $filter_inputs['period']->withValue(
348 [
349 new DateTimeImmutable("@{$period_from}"),
350 new DateTimeImmutable("@{$period_to}")
351 ]
352 );
353
354 }
355
356 (new ilUIFilterServiceSessionGateway())->reset(static::ID . '_filter');
357
358 return $filter_inputs;
359 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $user_id, ILIAS\Repository\access(), ILIAS\FileDelivery\http(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

Referenced by ILIAS\BookingManager\Bookings\Table\BookingsTable\getFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveBookingPeriodBounds()

ILIAS\BookingManager\Bookings\Table\BookingsTable::resolveBookingPeriodBounds ( mixed  $period)
private

Definition at line 481 of file BookingsTable.php.

481 : ?array
482 {
483 if (!$period) {
484 return null;
485 }
486
487 $from = $this->parseBookingPeriodValue($period[0] ?? null);
488 $to = $this->parseBookingPeriodValue($period[1] ?? null);
489
490 if ($from === null && $to === null) {
491 return null;
492 }
493
494 return [
495 $from ?? PHP_INT_MIN,
496 $to ?? PHP_INT_MAX,
497 ];
498 }

Referenced by ILIAS\BookingManager\Bookings\Table\BookingsTable\loadRecords().

+ Here is the caller graph for this function:

◆ sortRecords()

ILIAS\BookingManager\Bookings\Table\BookingsTable::sortRecords ( Order  $order,
array  $records 
)
protected

Definition at line 229 of file BookingsTable.php.

229 : array
230 {
231 $order_data = $order->get();
232 if ($order_data === []) {
233 return $records;
234 }
235
236 $users = [];
237 foreach ($order_data as $key => $value) {
238 $order_direction = $value === Order::DESC ? -1 : 1;
239 $callable = match ($key) {
240 'title' => static fn(array $record_a, array $record_b): int => strcasecmp(
241 $record_a['title'],
242 $record_b['title']
243 ) * $order_direction,
244 'status' => static fn(array $record_a, array $record_b): int =>
245 ($record_a['status'] <=> $record_b['status']) * $order_direction,
246 'date' => static fn(array $record_a, array $record_b): int =>
247 ($record_a['date_from'] <=> $record_b['date_from']) * $order_direction,
248 'week' => static function (array $record_a, array $record_b) use ($order_direction): int {
249 $week_a = (int) (new DateTimeImmutable("@{$record_a['date_from']}"))->format('W');
250 $week_b = (int) (new DateTimeImmutable("@{$record_b['date_from']}"))->format('W');
251 return ($week_a <=> $week_b) * $order_direction;
252 },
253 'weekday' => static function (array $record_a, array $record_b) use ($order_direction): int {
254 $week_a = (int) (new DateTimeImmutable("@{$record_a['date_from']}"))->format('N');
255 $week_b = (int) (new DateTimeImmutable("@{$record_b['date_from']}"))->format('N');
256 return ($week_a <=> $week_b) * $order_direction;
257 },
258 'time_slot' => function (array $record_a, array $record_b) use ($order_direction): int {
259 return strcasecmp(
260 $this->getBookingTimeSlotFilterLabel($record_a),
261 $this->getBookingTimeSlotFilterLabel($record_b)
262 ) * $order_direction;
263 },
264 'unit_count' => static fn(array $record_a, array $record_b): int => 0 * $order_direction,
265 'message' => static fn(array $record_a, array $record_b): int => strcasecmp(
266 (string) ($record_a['message'] ?? ''),
267 (string) ($record_b['message'] ?? '')
268 ) * $order_direction,
269 'user' => function (array $record_a, array $record_b) use (&$users, $order_direction): int {
270 $user_a = $record_a['user_id'];
271 $user_b = $record_b['user_id'];
272 $user_a = $users[$user_a] ??= $this->getUserPresentationName($user_a);
273 $user_b = $users[$user_b] ??= $this->getUserPresentationName($user_b);
274 return strcasecmp($user_a, $user_b) * $order_direction;
275 } ,
276 default => null
277 };
278
279 if ($callable === null) {
280 continue;
281 }
282
283 usort($records, $callable);
284 }
285
286 return $records;
287 }
const DESC
Definition: Order.php:31

References ILIAS\Data\Order\DESC, ILIAS\Data\Order\get(), ILIAS\BookingManager\Bookings\Table\BookingsTable\getBookingTimeSlotFilterLabel(), ILIAS\BookingManager\Bookings\Table\BookingsTable\getUserPresentationName(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

Field Documentation

◆ $booking_items

readonly array ILIAS\BookingManager\Bookings\Table\BookingsTable::$booking_items
protected

Definition at line 73 of file BookingsTable.php.

◆ $bookings

readonly array ILIAS\BookingManager\Bookings\Table\BookingsTable::$bookings
protected

◆ $column_factory

readonly ColumnFactory ILIAS\BookingManager\Bookings\Table\BookingsTable::$column_factory
protected

Definition at line 79 of file BookingsTable.php.

◆ $input_factory

readonly InputFactory ILIAS\BookingManager\Bookings\Table\BookingsTable::$input_factory
protected

Definition at line 81 of file BookingsTable.php.

◆ $participants

readonly array ILIAS\BookingManager\Bookings\Table\BookingsTable::$participants
protected

Definition at line 77 of file BookingsTable.php.

◆ ACTION_PARAMETER

const ILIAS\BookingManager\Bookings\Table\BookingsTable::ACTION_PARAMETER = 'action'

Definition at line 69 of file BookingsTable.php.

◆ ACTION_TYPE_PARAMETER

const ILIAS\BookingManager\Bookings\Table\BookingsTable::ACTION_TYPE_PARAMETER = 'action_type'

Definition at line 71 of file BookingsTable.php.

◆ ROW_ID_PARAMETER

const ILIAS\BookingManager\Bookings\Table\BookingsTable::ROW_ID_PARAMETER = 'booking_id'

Definition at line 67 of file BookingsTable.php.


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