ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
ParticipantTableDeleteAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
35use ILIAS\UI\Factory as UIFactory;
36use ILIAS\UI\Renderer as UIRenderer;
39use ilLanguage;
40
46{
48
49 public const string ACTION_ID = 'delete';
50
51 public const string ACTION_LABEL = 'book_remove_participants';
52
53 public function __construct(
54 private readonly UIFactory $ui_factory,
55 private readonly UIRenderer $ui_renderer,
56 private readonly ilLanguage $lng,
57 private readonly AccessManager $access,
58 private readonly ilCtrlInterface $ctrl,
59 private readonly ilGlobalTemplateInterface $tpl,
60 private readonly HttpService $http,
61 private readonly ParticipantRepository $participant_repository,
62 private readonly int $ref_id,
63 private readonly int $pool_id
64 ) {
65 }
66
67 public function getActionId(): string
68 {
69 return self::ACTION_ID;
70 }
71
72 public function getActionLabel(): string
73 {
74 return self::ACTION_LABEL;
75 }
76
77 public function isAvailable(): bool
78 {
79 return $this->access->canManageParticipants($this->ref_id);
80 }
81
82 public function getTableAction(
83 URLBuilder $url_builder,
84 URLBuilderToken $row_id_token,
85 URLBuilderToken $action_token,
86 URLBuilderToken $action_type_token
87 ): Action {
88 return $this->ui_factory->table()->action()->standard(
89 $this->lng->txt($this->getActionLabel()),
90 $url_builder
91 ->withParameter($action_token, $this->getActionId())
92 ->withParameter($action_type_token, self::SHOW_MODAL_ACTION),
93 $row_id_token
94 )->withAsync();
95 }
96
100 public function allowActionForRecord(mixed $record): bool
101 {
102 return true;
103 }
104
105 public function getModal(
106 URLBuilder $url_builder,
107 array $selected_records,
108 bool $all_records_selected
109 ): ?Modal {
110 return $this->ui_factory->modal()->interruptive(
111 $this->lng->txt('confirm'),
112 $this->lng->txt('book_confirm_remove_participant'),
113 $url_builder->buildURI()->__toString()
114 )->withAffectedItems(
115 array_map(
116 fn(array $record): InterruptiveItem => $this->ui_factory->modal()->interruptiveItem()->standard(
117 (string) $record['user_id'],
118 (string) ($record['name'] ?? '')
119 ),
120 $selected_records
121 )
122 )->withActionButtonLabel($this->lng->txt('remove'));
123 }
124
125 public function onSubmit(
126 URLBuilder $url_builder,
127 array $selected_records,
128 bool $all_records_selected
129 ): ?Modal {
130 if (!$this->access->canManageParticipants($this->ref_id)) {
131 $this->showErrorMessage($this->lng->txt('no_permission'));
132 return null;
133 }
134
135 foreach ($selected_records as $record) {
136 $this->participant_repository->delete((int) $record['user_id'], $this->pool_id);
137 }
138
139 if ($selected_records !== []) {
140 $this->showSuccessMessage($this->lng->txt('book_participant_removed'));
141 }
142 $this->ctrl->redirectByClass(ilBookingParticipantGUI::class, 'render');
143
144 return null;
145 }
146
147 protected function resolveRecords(?array $selected_ids = null): array
148 {
149 $all_participants = ilBookingParticipant::getList($this->pool_id);
150
151 if ($selected_ids === null) {
152 return array_values($all_participants);
153 }
154
155 return array_filter(
156 array_map(
157 fn(int $id): ?array => $all_participants["{$this->pool_id}_{$id}"] ?? null,
158 $selected_ids
159 )
160 );
161 }
162}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
@phpstan-type ParticipantRecord array{user_id: int, name: string, object_title: array<string>,...
__construct(private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly ilLanguage $lng, private readonly AccessManager $access, private readonly ilCtrlInterface $ctrl, private readonly ilGlobalTemplateInterface $tpl, private readonly HttpService $http, private readonly ParticipantRepository $participant_repository, 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)
onSubmit(URLBuilder $url_builder, array $selected_records, bool $all_records_selected)
getModal(URLBuilder $url_builder, array $selected_records, bool $all_records_selected)
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
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 describes commonalities between the different modals.
Definition: Modal.php:35
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait TableActionModalTrait
@template RecordType
readonly ilGlobalTemplateInterface $tpl
modal(string $title="", string $cancel_label="")
global $lng
Definition: privfeed.php:26
if(!file_exists('../ilias.ini.php'))