ILIAS  trunk Revision v12.0_alpha-1613-gae4c99ebb18
ParticipantTableEditBookingAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
31use ILIAS\UI\Factory as UIFactory;
34use ilLanguage;
36
42{
43 public const string ACTION_ID = 'edit_booking';
44
45 public const string ACTION_LABEL = 'book_deassign';
46
47 public function __construct(
48 private readonly UIFactory $ui_factory,
49 private readonly ilLanguage $lng,
50 private readonly AccessManager $access,
51 private readonly ilCtrlInterface $ctrl,
52 private readonly HttpService $http,
53 private readonly int $ref_id,
54 private readonly int $pool_id
55 ) {
56 }
57
58 public function getActionId(): string
59 {
60 return self::ACTION_ID;
61 }
62
63 public function getActionLabel(): string
64 {
65 return self::ACTION_LABEL;
66 }
67
68 public function isAvailable(): bool
69 {
70 return $this->access->canManageParticipants($this->ref_id);
71 }
72
73 public function getTableAction(
74 URLBuilder $url_builder,
75 URLBuilderToken $row_id_token,
76 URLBuilderToken $action_token,
77 URLBuilderToken $action_type_token
78 ): Action {
79 return $this->ui_factory->table()->action()->single(
80 $this->lng->txt('book_deassign'),
81 $url_builder
82 ->withParameter($action_token, self::ACTION_ID)
83 ->withParameter($action_type_token, 'edit'),
84 $row_id_token
85 );
86 }
87
88 public function onExecute(
89 URLBuilder $url_builder,
90 URLBuilderToken $row_id_token,
91 URLBuilderToken $action_token,
92 URLBuilderToken $action_type_token
93 ): mixed {
94 $this->ctrl->setParameterByClass(
96 'user_id',
97 (int) $this->http->resolveRowParameter($row_id_token->getName())
98 );
99 $this->ctrl->redirectByClass(ilBookingReservationsGUI::class, 'log');
100
101 return null;
102 }
103
107 public function allowActionForRecord(mixed $record): bool
108 {
109 $obj_count = (int) ($record['obj_count'] ?? 0);
110 return $obj_count > 0;
111 }
112
113 private function getObjectCountForUser(int $user_id): int
114 {
116 $this->pool_id,
117 ['user_id' => $user_id]
118 )["{$this->pool_id}_{$user_id}"] ?? null;
119 return (int) ($user_data['obj_count'] ?? 0);
120 }
121
125 private function getObjectIdsForUser(int $user_id): array
126 {
128 $this->pool_id,
129 ['user_id' => $user_id]
130 )["{$this->pool_id}_{$user_id}"] ?? null;
131 return $user_data['object_ids'] ?? [];
132 }
133}
@phpstan-type ParticipantRecord array{user_id: int, name: string, object_title: array<string>,...
__construct(private readonly UIFactory $ui_factory, private readonly ilLanguage $lng, private readonly AccessManager $access, private readonly ilCtrlInterface $ctrl, private readonly HttpService $http, private readonly int $ref_id, private readonly int $pool_id)
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
onExecute(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
@ilCtrl_Calls ilBookingParticipantGUI: ilRepositorySearchGUI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getList(int $a_booking_pool, ?array $a_filter=null, ?int $a_object_id=null)
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.
global $lng
Definition: privfeed.php:26