ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBookingGatewayGUI Class Reference

This class is used for integration of the booking manager as a service into other repository objects, e.g. More...

+ Collaboration diagram for ilBookingGatewayGUI:

Public Member Functions

 __construct (ilObjectGUI $parent_gui, int $main_host_ref_id=0)
 
 executeCommand ()
 
 initSettingsForm ()
 
 saveSettings ()
 

Protected Member Functions

 initPool ()
 Init pool. More...
 
 showPoolSelector (string $return_to)
 
 selectPool ()
 
 setSubTabs (string $active)
 
 show ()
 
 settings ()
 
 checkBookingPoolsForSchedules (array $ids)
 Check if all pools have schedules. More...
 

Protected Attributes

BookingManager InternalDomainService $domain
 
BookingManager StandardGUIRequest $book_request
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $main_tpl
 
ilObjectGUI $parent_gui
 
ilTabsGUI $tabs
 
int $obj_id
 
int $ref_id
 
ilObjBookingServiceSettings $current_settings
 
int $current_pool_ref_id
 
ilObjBookingPool $pool = null
 
ilToolbarGUI $toolbar
 
int $main_host_ref_id = 0
 
bool $pools_selected = false
 
string $seed
 
string $sseed
 
ilObjUseBookDBRepository $use_book_repo
 
string $return_to = ""
 
ilBookingHelpAdapter $help
 

Detailed Description

This class is used for integration of the booking manager as a service into other repository objects, e.g.

courses. @ilCtrl_Calls ilBookingGatewayGUI: ilPropertyFormGUI, ilBookingObjectServiceGUI, ilBookingReservationsGUI

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 27 of file class.ilBookingGatewayGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookingGatewayGUI::__construct ( ilObjectGUI  $parent_gui,
int  $main_host_ref_id = 0 
)

Definition at line 51 of file class.ilBookingGatewayGUI.php.

54 {
55 global $DIC;
56
57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->main_tpl = $DIC->ui()->mainTemplate();
60 $this->parent_gui = $parent_gui;
61 $this->tabs = $DIC->tabs();
62 $this->book_request = $DIC->bookingManager()
63 ->internal()
64 ->gui()
65 ->standardRequest();
66 $this->domain = $DIC
67 ->bookingManager()
68 ->internal()
69 ->domain();
70
71 $this->lng->loadLanguageModule("book");
72
73 // current parent context (e.g. session in course)
74 $this->obj_id = $parent_gui->getObject()->getId();
75 $this->ref_id = $parent_gui->getObject()->getRefId();
76
77 $this->main_host_ref_id = ($main_host_ref_id === 0)
78 ? $this->ref_id
80
81
82 $this->seed = $this->book_request->getSeed();
83 $this->sseed = $this->book_request->getSSeed();
84
85 $this->toolbar = $DIC->toolbar();
86
87 $this->use_book_repo = new ilObjUseBookDBRepository($DIC->database());
88
89 $req_return_to = $this->book_request->getReturnTo();
90 if (in_array($req_return_to, ["ilbookingobjectservicegui", "ilbookingreservationsgui"])) {
91 $this->return_to = $req_return_to;
92 }
93
94 // get current settings
95 $handler = new BookingManager\getObjectSettingsCommandHandler(
97 $this->use_book_repo
98 );
99 $this->current_settings = $handler->handle()->getSettings();
100
101 $this->initPool();
102
103 if (is_object($this->pool)) {
104 $this->help = new ilBookingHelpAdapter($this->pool, $DIC["ilHelp"]);
105 $DIC["ilHelp"]->setScreenIdComponent("book");
106 }
107 }
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...
$handler
Definition: oai.php:29
global $DIC
Definition: shib_login.php:26

References $DIC, $handler, $main_host_ref_id, $parent_gui, ILIAS\Repository\ctrl(), ilObjectGUI\getObject(), ILIAS\Repository\help(), initPool(), ILIAS\Repository\lng(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkBookingPoolsForSchedules()

ilBookingGatewayGUI::checkBookingPoolsForSchedules ( array  $ids)
protected

Check if all pools have schedules.

Parameters
int[]$idspool ref ids

Definition at line 337 of file class.ilBookingGatewayGUI.php.

337 : bool
338 {
339 foreach ($ids as $pool_ref_id) {
340 $schedule_manager = $this->domain->schedules(ilObject::_lookupObjectId($pool_ref_id));
341 if (!$schedule_manager->hasSchedules()) {
342 return false;
343 }
344 }
345 return true;
346 }
static _lookupObjectId(int $ref_id)

References ilObject\_lookupObjectId().

+ Here is the call graph for this function:

◆ executeCommand()

ilBookingGatewayGUI::executeCommand ( )
Exceptions
ilCtrlException
ilException

Definition at line 146 of file class.ilBookingGatewayGUI.php.

146 : void
147 {
149
150 $next_class = $ctrl->getNextClass($this);
151 $cmd = $ctrl->getCmd("show");
152
153 switch ($next_class) {
154 case "ilpropertyformgui":
155 $form = $this->initSettingsForm();
156 $ctrl->setReturn($this, 'settings');
157 $ctrl->forwardCommand($form);
158 break;
159
160 case "ilbookingobjectservicegui":
161 $this->setSubTabs("book_obj");
162 $this->showPoolSelector("ilbookingobjectservicegui");
163 $book_ser_gui = new ilBookingObjectServiceGUI(
164 $this->ref_id,
165 $this->current_pool_ref_id,
166 $this->use_book_repo,
167 $this->seed,
168 $this->sseed,
169 $this->help
170 );
171 $ctrl->forwardCommand($book_ser_gui);
172 break;
173
174 case "ilbookingreservationsgui":
175 $this->showPoolSelector("ilbookingreservationsgui");
176 $this->setSubTabs("reservations");
177 $res_gui = new ilBookingReservationsGUI($this->pool, $this->help, $this->obj_id);
178 $this->ctrl->forwardCommand($res_gui);
179 break;
180
181
182 default:
183 if (in_array($cmd, array("show", "settings", "saveSettings", "selectPool"))) {
184 $this->$cmd();
185 }
186 }
187 }
showPoolSelector(string $return_to)
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...
getNextClass($a_gui_class=null)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
setReturn(object $a_gui_obj, ?string $a_cmd=null)
@inheritDoc

References $ctrl, ILIAS\Repository\ctrl(), ilCtrl\forwardCommand(), ilCtrl\getCmd(), ilCtrl\getNextClass(), ILIAS\Repository\help(), initSettingsForm(), ilCtrl\setReturn(), setSubTabs(), and showPoolSelector().

+ Here is the call graph for this function:

◆ initPool()

ilBookingGatewayGUI::initPool ( )
protected

Init pool.

Determine the current pool in $this->current_pool_ref_id. Host objects (e.g. courses) may use multiple booking pools. This method determines the current selected pool (stored in request parameter "pool_ref_id") within the host object user interface. If no pool has been selected yet, the first one attached to the host object is choosen. If no pools are attached to the host object at all we get a 0 ID.

Definition at line 117 of file class.ilBookingGatewayGUI.php.

117 : void
118 {
120
121 $ctrl->saveParameter($this, "pool_ref_id");
122 $pool_ref_id = $this->book_request->getPoolRefId();
123
124 $book_ref_ids = $this->use_book_repo->getUsedBookingPools(ilObject::_lookupObjId($this->main_host_ref_id), false);
125
126 $this->pools_selected = (count($book_ref_ids) > 0);
127
128 if (!in_array($pool_ref_id, $book_ref_ids)) {
129 if (count($book_ref_ids) > 0) {
130 $pool_ref_id = current($book_ref_ids);
131 } else {
132 $pool_ref_id = 0;
133 }
134 }
135 $this->current_pool_ref_id = $pool_ref_id;
136 if ($this->current_pool_ref_id > 0) {
137 $this->pool = new ilObjBookingPool($this->current_pool_ref_id);
138 $ctrl->setParameter($this, "pool_ref_id", $this->current_pool_ref_id);
139 }
140 }
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
saveParameter(object $a_gui_obj, $a_parameter)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)

References $ctrl, ilObject\_lookupObjId(), ilCtrl\saveParameter(), and ilCtrl\setParameter().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSettingsForm()

ilBookingGatewayGUI::initSettingsForm ( )

Definition at line 270 of file class.ilBookingGatewayGUI.php.

271 {
274
275 $form = new ilPropertyFormGUI();
276
277 // booking tools
278 $repo = new ilRepositorySelector2InputGUI($this->lng->txt("objs_book"), "booking_obj_ids", true);
279 $repo->getExplorerGUI()->setSelectableTypes(["book"]);
280 $repo->getExplorerGUI()->setTypeWhiteList(
281 ["book", "root", "cat", "grp", "fold", "crs"]
282 );
283 $form->addItem($repo);
284 $repo->setValue($this->current_settings->getUsedBookingObjectIds());
285
286 $form->addCommandButton("saveSettings", $lng->txt("save"));
287
288 $form->setTitle($lng->txt("book_pool_selection"));
289 $form->setFormAction($ctrl->getFormAction($this));
290
291 return $form;
292 }
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a property form user interface.

References $lng, ilCtrl\getFormAction(), and ILIAS\Repository\lng().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettings()

ilBookingGatewayGUI::saveSettings ( )

Definition at line 294 of file class.ilBookingGatewayGUI.php.

294 : void
295 {
299
300 $form = $this->initSettingsForm();
301 if ($form->checkInput()) {
302 $b_ids = $form->getInput("booking_obj_ids");
303 $b_ids = is_array($b_ids)
304 ? array_map(static function ($i) {
305 return (int) $i;
306 }, $b_ids)
307 : [];
308
309 if (!$this->checkBookingPoolsForSchedules($b_ids)) {
310 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("book_all_pools_need_schedules"));
311 $form->setValuesByPost();
312 $main_tpl->setContent($form->getHTML());
313 return;
314 }
315
316 $cmd = new BookingManager\saveObjectSettingsCommand(new ilObjBookingServiceSettings(
317 $this->obj_id,
318 $b_ids
319 ));
320
321 $repo = $this->use_book_repo;
322 $handler = new BookingManager\saveObjectSettingsCommandHandler($cmd, $repo);
323 $handler->handle();
324
325 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
326 $ctrl->redirect($this, "");
327 } else {
328 $form->setValuesByPost();
329 $main_tpl->setContent($form->getHTML());
330 }
331 }
checkBookingPoolsForSchedules(array $ids)
Check if all pools have schedules.
ilObjUseBookDBRepository $use_book_repo
ilGlobalTemplateInterface $main_tpl
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.

References $handler, $lng, and ilCtrl\redirect().

+ Here is the call graph for this function:

◆ selectPool()

ilBookingGatewayGUI::selectPool ( )
protected

Definition at line 209 of file class.ilBookingGatewayGUI.php.

209 : void
210 {
211 if ($this->return_to !== "") {
212 $this->ctrl->redirectByClass($this->return_to);
213 }
214 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ setSubTabs()

ilBookingGatewayGUI::setSubTabs ( string  $active)
protected

Definition at line 216 of file class.ilBookingGatewayGUI.php.

218 : void {
222
223 if ($this->pools_selected) {
225 "book_obj",
226 $lng->txt("book_booking_objects"),
227 $ctrl->getLinkTargetByClass("ilbookingobjectservicegui", "")
228 );
230 "reservations",
231 $lng->txt("book_log"),
232 $ctrl->getLinkTargetByClass("ilbookingreservationsgui", "")
233 );
234 }
235 if ($this->ref_id === $this->main_host_ref_id) {
237 "settings",
238 $lng->txt("settings"),
239 $ctrl->getLinkTarget($this, "settings")
240 );
241 }
242
243 $tabs->activateSubTab($active);
244 }
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
activateSubTab(string $a_id)
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")

References $lng, ilTabsGUI\addSubTab(), and ilCtrl\getLinkTargetByClass().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ settings()

ilBookingGatewayGUI::settings ( )
protected

Definition at line 262 of file class.ilBookingGatewayGUI.php.

262 : void
263 {
264 $this->setSubTabs("settings");
266 $form = $this->initSettingsForm();
267 $main_tpl->setContent($form->getHTML());
268 }

◆ show()

ilBookingGatewayGUI::show ( )
protected

Definition at line 246 of file class.ilBookingGatewayGUI.php.

246 : void
247 {
249 if ($this->pools_selected) {
250 $ctrl->redirectByClass("ilbookingobjectservicegui");
251 } elseif ($this->ref_id === $this->main_host_ref_id) {
252 $ctrl->redirect($this, "settings");
253 }
254
255 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("book_no_pools_selected"));
256 }
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc

References ILIAS\Repository\lng(), ilCtrl\redirect(), and ilCtrl\redirectByClass().

+ Here is the call graph for this function:

◆ showPoolSelector()

ilBookingGatewayGUI::showPoolSelector ( string  $return_to)
protected

Definition at line 189 of file class.ilBookingGatewayGUI.php.

191 : void {
192 //
193 $options = [];
194 foreach ($this->use_book_repo->getUsedBookingPools(ilObject::_lookupObjectId($this->main_host_ref_id), false) as $ref_id) {
196 }
197
198 $this->ctrl->setParameter($this, "return_to", $return_to);
199 if (count($options) > 0) {
200 $si = new ilSelectInputGUI("", "pool_ref_id");
201 $si->setOptions($options);
202 $si->setValue($this->current_pool_ref_id);
203 $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
204 $this->toolbar->addInputItem($si, false);
205 $this->toolbar->addFormButton($this->lng->txt("book_select_pool"), "selectPool");
206 }
207 }
static _lookupTitle(int $obj_id)
This class represents a selection list property in a property form.

References $ref_id, ilObject\_lookupObjId(), and ilObject\_lookupTitle().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $book_request

BookingManager StandardGUIRequest ilBookingGatewayGUI::$book_request
protected

Definition at line 30 of file class.ilBookingGatewayGUI.php.

◆ $ctrl

ilCtrl ilBookingGatewayGUI::$ctrl
protected

Definition at line 31 of file class.ilBookingGatewayGUI.php.

Referenced by executeCommand(), and initPool().

◆ $current_pool_ref_id

int ilBookingGatewayGUI::$current_pool_ref_id
protected

Definition at line 39 of file class.ilBookingGatewayGUI.php.

◆ $current_settings

ilObjBookingServiceSettings ilBookingGatewayGUI::$current_settings
protected

Definition at line 38 of file class.ilBookingGatewayGUI.php.

◆ $domain

BookingManager InternalDomainService ilBookingGatewayGUI::$domain
protected

Definition at line 29 of file class.ilBookingGatewayGUI.php.

◆ $help

ilBookingHelpAdapter ilBookingGatewayGUI::$help
protected

Definition at line 49 of file class.ilBookingGatewayGUI.php.

◆ $lng

ilLanguage ilBookingGatewayGUI::$lng
protected

Definition at line 32 of file class.ilBookingGatewayGUI.php.

◆ $main_host_ref_id

int ilBookingGatewayGUI::$main_host_ref_id = 0
protected

Definition at line 42 of file class.ilBookingGatewayGUI.php.

Referenced by __construct().

◆ $main_tpl

ilGlobalTemplateInterface ilBookingGatewayGUI::$main_tpl
protected

Definition at line 33 of file class.ilBookingGatewayGUI.php.

◆ $obj_id

int ilBookingGatewayGUI::$obj_id
protected

Definition at line 36 of file class.ilBookingGatewayGUI.php.

◆ $parent_gui

ilObjectGUI ilBookingGatewayGUI::$parent_gui
protected

Definition at line 34 of file class.ilBookingGatewayGUI.php.

Referenced by __construct().

◆ $pool

ilObjBookingPool ilBookingGatewayGUI::$pool = null
protected

Definition at line 40 of file class.ilBookingGatewayGUI.php.

◆ $pools_selected

bool ilBookingGatewayGUI::$pools_selected = false
protected

Definition at line 44 of file class.ilBookingGatewayGUI.php.

◆ $ref_id

int ilBookingGatewayGUI::$ref_id
protected

Definition at line 37 of file class.ilBookingGatewayGUI.php.

Referenced by showPoolSelector().

◆ $return_to

string ilBookingGatewayGUI::$return_to = ""
protected

Definition at line 48 of file class.ilBookingGatewayGUI.php.

◆ $seed

string ilBookingGatewayGUI::$seed
protected

Definition at line 45 of file class.ilBookingGatewayGUI.php.

◆ $sseed

string ilBookingGatewayGUI::$sseed
protected

Definition at line 46 of file class.ilBookingGatewayGUI.php.

◆ $tabs

ilTabsGUI ilBookingGatewayGUI::$tabs
protected

Definition at line 35 of file class.ilBookingGatewayGUI.php.

◆ $toolbar

ilToolbarGUI ilBookingGatewayGUI::$toolbar
protected

Definition at line 41 of file class.ilBookingGatewayGUI.php.

◆ $use_book_repo

ilObjUseBookDBRepository ilBookingGatewayGUI::$use_book_repo
protected

Definition at line 47 of file class.ilBookingGatewayGUI.php.


The documentation for this class was generated from the following file: