ILIAS  trunk Revision v12.0_alpha-399-g579a087ced2
class.ilBookingParticipantGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public const FILTER_ACTION_APPLY = 1;
27 public const FILTER_ACTION_RESET = 2;
28 public const PARTICIPANT_VIEW = 1;
29 protected \ILIAS\BookingManager\Access\AccessManager $access;
30 protected \ILIAS\BookingManager\StandardGUIRequest $book_request;
31
33 protected ilTabsGUI $tabs;
34 protected ilCtrl $ctrl;
35 protected ilLanguage $lng;
37 protected int $ref_id;
38 protected int $pool_id;
39
40 public function __construct(
41 ilObjBookingPoolGUI $a_parent_obj
42 ) {
43 global $DIC;
44
45 $this->tpl = $DIC["tpl"];
46 $this->tabs = $DIC->tabs();
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49 $this->access = $DIC->bookingManager()->internal()->domain()->access();
50 $this->toolbar = $DIC->toolbar();
51 $this->book_request = $DIC->bookingManager()
52 ->internal()
53 ->gui()
54 ->standardRequest();
55
56
57 $this->ref_id = $a_parent_obj->getRefId();
58 $this->pool_id = $a_parent_obj->getObject()->getId();
59
60 $this->lng->loadLanguageModule("book");
61 $this->lng->loadLanguageModule("exc");
62 }
63
64 public function executeCommand(): void
65 {
66 $ilCtrl = $this->ctrl;
67
68 $next_class = $ilCtrl->getNextClass($this);
69
70 switch ($next_class) {
71 case 'ilrepositorysearchgui':
72 $rep_search = new ilRepositorySearchGUI();
74 $rep_search->addUserAccessFilterCallable(function ($a_user_id) {
75 return $this->access->filterManageableParticipants(
76 $this->ref_id,
77 $a_user_id
78 );
79 });
80 $rep_search->setTitle($this->lng->txt("exc_add_participant"));
81 $rep_search->setCallback($this, 'addParticipantObject');
82 $this->ctrl->setReturn($this, 'render');
83 $this->ctrl->forwardCommand($rep_search);
84 break;
85
86 default:
87 $cmd = $ilCtrl->getCmd("render");
88 $this->$cmd();
89 break;
90 }
91 }
92
97 public function render(): void
98 {
99 if ($this->access->canManageParticipants($this->ref_id)) {
101 $this,
102 $this->toolbar,
103 array(
104 'auto_complete_name' => $this->lng->txt('user'),
105 'submit_name' => $this->lng->txt('add'),
106 'add_search' => true,
107 'add_from_container' => $this->ref_id
108 )
109 );
110
111 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
112
113 $this->tpl->setContent($table->getHTML());
114 }
115 }
116
117 public function addUserFromAutoCompleteObject(): bool
118 {
119 if (trim($this->book_request->getUserLogin()) === '') {
120 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_search_string'));
121 $this->render();
122 return false;
123 }
124
125 $users = explode(',', $this->book_request->getUserLogin());
126
127 $user_ids = array();
128 foreach ($users as $user) {
130
131 if (!$user_id) {
132 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('user_not_known'));
133 $this->render();
134 }
135 $user_ids[] = $user_id;
136 }
137
138 return $this->addParticipantObject($user_ids);
139 }
140
146 public function addParticipantObject(
147 array $a_user_ids
148 ): bool {
149 foreach ($a_user_ids as $user_id) {
150 if (ilObject::_lookupType($user_id) === "usr") {
151 $participant_obj = new ilBookingParticipant($user_id, $this->pool_id);
152 if ($participant_obj->getIsNew()) {
153 $this->tpl->setOnScreenMessage('success', $this->lng->txt("book_participant_assigned"), true);
154 } else {
155 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("book_participant_already_assigned"), true);
156 }
157 } else {
158 $this->tpl->setOnScreenMessage('failure', "dummy error message, change me");
159 return false;
160 }
161 }
162
163 $this->ctrl->redirect($this, "render");
164 return true;
165 }
166
167 public function applyParticipantsFilter(): void
168 {
169 $this->applyFilterAction(self::FILTER_ACTION_APPLY);
170 }
171
172 public function resetParticipantsFilter(): void
173 {
174 $this->applyFilterAction(self::FILTER_ACTION_RESET);
175 }
176
177 protected function applyFilterAction(
178 int $a_filter_action
179 ): void {
180 $table = new ilBookingParticipantsTableGUI($this, 'render', $this->ref_id, $this->pool_id);
181 $table->resetOffset();
182 if ($a_filter_action === self::FILTER_ACTION_RESET) {
183 $table->resetFilter();
184 } else {
185 $table->writeFilterToSession();
186 }
187
188 $this->render();
189 }
190
191 public function assignObjects(): void
192 {
193 $this->tabs->clearTargets();
194 $this->tabs->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
195
196 $table = new ilBookingAssignObjectsTableGUI($this, 'assignObjects', $this->ref_id, $this->pool_id);
197
198 $this->tpl->setContent($table->getHTML());
199 }
200}
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...
addParticipantObject(array $a_user_ids)
Add new participant.
ILIAS BookingManager StandardGUIRequest $book_request
__construct(ilObjBookingPoolGUI $a_parent_obj)
render()
Render list of booking participants.
ILIAS BookingManager Access AccessManager $access
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...
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
language handling
@ilCtrl_Calls ilObjBookingPoolGUI: ilPermissionGUI, ilBookingObjectGUI @ilCtrl_Calls ilObjBookingPool...
static _lookupId(string|array $a_user_str)
static _lookupType(int $id, bool $reference=false)
static fillAutoCompleteToolbar(object $parent_object, ?ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt('user'), auto_complete_size = 15, user_type = array(ilCoursePar...
resetOffset(bool $a_in_determination=false)
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...
global $DIC
Definition: shib_login.php:26