ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
BookableItemTableBookForParticipantAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use ILIAS\Refinery\Factory as Refinery;
31use ILIAS\UI\Factory as UIFactory;
34use ilLanguage;
36
38{
39 public const string ACTION_ID = 'book_for_participant';
40 public const string ACTION_LABEL = 'book_assign_participants';
41
42 public function __construct(
43 private readonly UIFactory $ui_factory,
44 private readonly ilLanguage $lng,
45 private readonly ilCtrlInterface $ctrl,
46 private readonly HttpService $http,
47 private readonly Refinery $refinery,
48 private readonly AccessManager $access,
49 private readonly ilObjBookingPool $pool,
50 private readonly int $ref_id,
51 private readonly bool $active_management,
52 ) {
53 }
54
55 public function getActionId(): string
56 {
57 return self::ACTION_ID;
58 }
59
60 public function getActionLabel(): string
61 {
62 return self::ACTION_LABEL;
63 }
64
65 public function isAvailable(): bool
66 {
67 if ($this->pool->getScheduleType() === ilObjBookingPool::TYPE_NO_SCHEDULE_PREFERENCES) {
68 return false;
69 }
70
71 return $this->active_management && $this->access->canManageObjects($this->ref_id);
72 }
73
74 public function getTableAction(
75 URLBuilder $url_builder,
76 URLBuilderToken $row_id_token,
77 URLBuilderToken $action_token,
78 URLBuilderToken $action_type_token
79 ): Action {
80 return $this->ui_factory->table()->action()->single(
81 $this->lng->txt(self::ACTION_LABEL),
82 $url_builder
83 ->withParameter($action_token, self::ACTION_ID)
84 ->withParameter($action_type_token, 'redirect'),
85 $row_id_token
86 );
87 }
88
89 public function onExecute(
90 URLBuilder $url_builder,
91 URLBuilderToken $row_id_token,
92 URLBuilderToken $action_token,
93 URLBuilderToken $action_type_token
94 ): mixed {
95 $row_ids = $this->resolveRowIds($row_id_token->getName());
96 if ($row_ids === []) {
97 return null;
98 }
99
100 $first_parts = explode('_', $row_ids[0]);
101 $primary_object_id = (int) $first_parts[0];
102 if ($primary_object_id <= 0) {
103 return null;
104 }
105
106 $target_class = $this->pool->getScheduleType() === ilObjBookingPool::TYPE_FIX_SCHEDULE
107 ? ilBookingProcessWithScheduleGUI::class
108 : ilBookingProcessWithoutScheduleGUI::class;
109
110 $this->ctrl->setParameterByClass($target_class, 'object_id', (string) $primary_object_id);
111
112 if (isset($first_parts[1], $first_parts[2])) {
113 $this->ctrl->setParameterByClass(
114 $target_class,
115 'slot',
116 $first_parts[1] . '_' . $first_parts[2]
117 );
118 $this->ctrl->setParameterByClass($target_class, 'seed', date('Y-m-d', (int) $first_parts[1]));
119 }
120
121 $this->ctrl->redirectByClass($target_class, 'assignParticipants');
122 return null;
123 }
124
125 public function allowActionForRecord(mixed $record): bool
126 {
127 if (!is_array($record)) {
128 return false;
129 }
130
131 if ($this->pool->getOverallLimit() && (int) $record['available'] <= 0) {
132 return false;
133 }
134
135 return (bool) $record['is_available'];
136 }
137
141 private function resolveRowIds(string $key): array
142 {
143 $value = $this->http->get(
144 $key,
145 $this->refinery->custom()->transformation(
146 static function (mixed $raw): array {
147 if ($raw === null || $raw === '') {
148 return [];
149 }
150
151 if (is_array($raw)) {
152 return array_values(array_map('strval', $raw));
153 }
154
155 return [(string) $raw];
156 }
157 )
158 ) ?? [];
159
160 return array_values(array_filter($value, static fn(string $v): bool => $v !== ''));
161 }
162}
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 ilCtrlInterface $ctrl, private readonly HttpService $http, private readonly Refinery $refinery, private readonly AccessManager $access, private readonly ilObjBookingPool $pool, private readonly int $ref_id, private readonly bool $active_management,)
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
Builds data types.
Definition: Factory.php:36
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...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
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...
static http()
Fetches the global http state from ILIAS.
global $lng
Definition: privfeed.php:26