ILIAS  trunk Revision v12.0_alpha-1613-gae4c99ebb18
ParticipantTableBookForParticipantAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30use ILIAS\UI\Factory as UIFactory;
33use ilLanguage;
34
40{
41 public const string ACTION_ID = 'book_for_participant';
42
43 public const string ACTION_LABEL = 'book_assign_object';
44
45 public function __construct(
46 private readonly UIFactory $ui_factory,
47 private readonly ilLanguage $lng,
48 private readonly AccessManager $access,
49 private readonly ilCtrlInterface $ctrl,
50 private readonly HttpService $http,
51 private readonly int $ref_id,
52 private readonly int $pool_id
53 ) {
54 }
55
56 public function getActionId(): string
57 {
58 return self::ACTION_ID;
59 }
60
61 public function getActionLabel(): string
62 {
63 return self::ACTION_LABEL;
64 }
65
66 public function isAvailable(): bool
67 {
68 return $this->access->canManageParticipants($this->ref_id);
69 }
70
71 public function getTableAction(
72 URLBuilder $url_builder,
73 URLBuilderToken $row_id_token,
74 URLBuilderToken $action_token,
75 URLBuilderToken $action_type_token
76 ): Action {
77 return $this->ui_factory->table()->action()->single(
78 $this->lng->txt('book_assign_object'),
79 $url_builder
80 ->withParameter($action_token, self::ACTION_ID)
81 ->withParameter($action_type_token, 'book'),
82 $row_id_token
83 );
84 }
85
86 public function onExecute(
87 URLBuilder $url_builder,
88 URLBuilderToken $row_id_token,
89 URLBuilderToken $action_token,
90 URLBuilderToken $action_type_token
91 ): mixed {
92 $user_id = $this->http->resolveRowParameter($row_id_token->getName());
93
94 $this->ctrl->setParameterByClass(ilBookingParticipantGUI::class, 'bkusr', (string) $user_id);
95 $this->ctrl->redirectByClass(ilBookingParticipantGUI::class, 'assignObjects');
96
97 return null;
98 }
99
103 public function allowActionForRecord(mixed $record): bool
104 {
105 $obj_count = (int) ($record['obj_count'] ?? 0);
106 return $obj_count < ilBookingObject::getNumberOfObjectsForPool($this->pool_id);
107 }
108}
@phpstan-type ParticipantRecord array{user_id: int, name: string, object_title: array<string>,...
onExecute(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
__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)
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNumberOfObjectsForPool(int $a_pool_id)
Get number of booking objects for given booking pool id.
@ilCtrl_Calls ilBookingParticipantGUI: ilRepositorySearchGUI
language handling
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