ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ParticipantTableDeleteParticipantAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Factory as UIFactory;
29use Psr\Http\Message\ServerRequestInterface;
30
32{
33 public const ACTION_ID = 'delete_pax';
34
35 public function __construct(
36 private readonly Language $lng,
37 private readonly \ilGlobalTemplateInterface $tpl,
38 private readonly UIFactory $ui_factory,
39 private readonly ParticipantRepository $participant_repository,
40 private readonly \ilTestAccess $test_access,
41 private readonly \ilObjTest $test_obj
42 ) {
43 }
44
45 public function getActionId(): string
46 {
47 return self::ACTION_ID;
48 }
49
50 public function isAvailable(): bool
51 {
52 return $this->test_access->checkManageParticipantsAccess();
53 }
54
55 public function getTableAction(
56 URLBuilder $url_builder,
57 URLBuilderToken $row_id_token,
58 URLBuilderToken $action_token,
59 URLBuilderToken $action_type_token
60 ): Action {
61 return $this->ui_factory->table()->action()->standard(
62 $this->lng->txt('remove_participants'),
63 $url_builder
64 ->withParameter($action_token, self::ACTION_ID)
65 ->withParameter($action_type_token, ParticipantTableActions::SHOW_ACTION),
66 $row_id_token
67 )->withAsync();
68 }
69
70 public function getModal(
71 URLBuilder $url_builder,
72 array $selected_participants,
73 bool $all_participants_selected
74 ): ?Modal {
75 return $this->ui_factory->modal()->interruptive(
76 $this->lng->txt('confirm'),
77 $this->lng->txt('remove_selected_participants_confirmation'),
78 $url_builder->buildURI()->__toString()
79 )->withAffectedItems(
80 array_map(
81 fn(Participant $v) => $this->ui_factory->modal()->interruptiveItem()->standard(
82 (string) $v->getUserId(),
83 $this->test_obj->getAnonymity()
84 ? $this->lng->txt('anonymous')
85 : \ilObjUser::_lookupFullname($v->getUserId())
86 ),
87 $selected_participants
88 )
89 )->withActionButtonLabel($this->lng->txt('remove'));
90 }
91
92 public function onSubmit(
93 URLBuilder $url_builder,
94 ServerRequestInterface $request,
95 array $selected_participants,
96 bool $all_participants_selected
97 ): ?Modal {
98 if (!$this->test_access->checkManageParticipantsAccess()) {
99 $this->tpl->setOnScreenMessage(
101 $this->lng->txt('no_permission'),
102 true
103 );
104 return null;
105 }
106
107 $this->participant_repository->removeParticipants($selected_participants);
108
109 $this->tpl->setOnScreenMessage(
111 $this->lng->txt('tst_selected_user_data_deleted'),
112 true
113 );
114 return null;
115 }
116
117 public function allowActionForRecord(Participant $record): bool
118 {
119 return $record->getActiveId() === null;
120 }
121
122 public function getSelectionErrorMessage(): ?string
123 {
124 return $this->lng->txt('delete_participants_no_valid_participants_selected');
125 }
126}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
__construct(private readonly Language $lng, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly ParticipantRepository $participant_repository, private readonly \ilTestAccess $test_access, private readonly \ilObjTest $test_obj)
getTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_participants, bool $all_participants_selected)
getModal(URLBuilder $url_builder, array $selected_participants, bool $all_participants_selected)
User class.
return['delivery_method'=> 'php',]
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
modal(string $title="", string $cancel_label="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Participant.php:21
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))