ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 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. 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 50 of file class.ilBookingGatewayGUI.php.

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

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

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

References ilObject\_lookupObjectId(), and ilBookingSchedule\hasExistingSchedules().

Referenced by saveSettings().

332  : bool
333  {
334  foreach ($ids as $pool_ref_id) {
336  return false;
337  }
338  }
339  return true;
340  }
static hasExistingSchedules(int $a_pool_id)
Check if given pool has any defined schedules.
static _lookupObjectId(int $ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilBookingGatewayGUI::executeCommand ( )
Exceptions
ilCtrlException
ilException

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

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

141  : void
142  {
143  $ctrl = $this->ctrl;
144 
145  $next_class = $ctrl->getNextClass($this);
146  $cmd = $ctrl->getCmd("show");
147 
148  switch ($next_class) {
149  case "ilpropertyformgui":
150  $form = $this->initSettingsForm();
151  $ctrl->setReturn($this, 'settings');
152  $ctrl->forwardCommand($form);
153  break;
154 
155  case "ilbookingobjectservicegui":
156  $this->setSubTabs("book_obj");
157  $this->showPoolSelector("ilbookingobjectservicegui");
158  $book_ser_gui = new ilBookingObjectServiceGUI(
159  $this->ref_id,
160  $this->current_pool_ref_id,
161  $this->use_book_repo,
162  $this->seed,
163  $this->sseed,
164  $this->help
165  );
166  $ctrl->forwardCommand($book_ser_gui);
167  break;
168 
169  case "ilbookingreservationsgui":
170  $this->showPoolSelector("ilbookingreservationsgui");
171  $this->setSubTabs("reservations");
172  $res_gui = new ilBookingReservationsGUI($this->pool, $this->help, $this->obj_id);
173  $this->ctrl->forwardCommand($res_gui);
174  break;
175 
176 
177  default:
178  if (in_array($cmd, array("show", "settings", "saveSettings", "selectPool"))) {
179  $this->$cmd();
180  }
181  }
182  }
getCmd(string $fallback_command=null)
showPoolSelector(string $return_to)
forwardCommand(object $a_gui_object)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getNextClass($a_gui_class=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setReturn(object $a_gui_obj, string $a_cmd=null)
+ 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 112 of file class.ilBookingGatewayGUI.php.

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

Referenced by __construct().

112  : void
113  {
114  $ctrl = $this->ctrl;
115 
116  $ctrl->saveParameter($this, "pool_ref_id");
117  $pool_ref_id = $this->book_request->getPoolRefId();
118 
119  $book_ref_ids = $this->use_book_repo->getUsedBookingPools(ilObject::_lookupObjId($this->main_host_ref_id), false);
120 
121  $this->pools_selected = (count($book_ref_ids) > 0);
122 
123  if (!in_array($pool_ref_id, $book_ref_ids)) {
124  if (count($book_ref_ids) > 0) {
125  $pool_ref_id = current($book_ref_ids);
126  } else {
127  $pool_ref_id = 0;
128  }
129  }
130  $this->current_pool_ref_id = $pool_ref_id;
131  if ($this->current_pool_ref_id > 0) {
132  $this->pool = new ilObjBookingPool($this->current_pool_ref_id);
133  $ctrl->setParameter($this, "pool_ref_id", $this->current_pool_ref_id);
134  }
135  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
saveParameter(object $a_gui_obj, $a_parameter)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSettingsForm()

ilBookingGatewayGUI::initSettingsForm ( )

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

References $ctrl, $lng, ilRepositorySelector2InputGUI\getExplorerGUI(), ilCtrl\getFormAction(), ILIAS\Repository\lng(), and ilLanguage\txt().

Referenced by executeCommand(), saveSettings(), and settings().

266  {
267  $ctrl = $this->ctrl;
268  $lng = $this->lng;
269 
270  $form = new ilPropertyFormGUI();
271 
272  // booking tools
273  $repo = new ilRepositorySelector2InputGUI($this->lng->txt("objs_book"), "booking_obj_ids", true);
274  $repo->getExplorerGUI()->setSelectableTypes(["book"]);
275  $repo->getExplorerGUI()->setTypeWhiteList(
276  ["book", "root", "cat", "grp", "fold", "crs"]
277  );
278  $form->addItem($repo);
279  $repo->setValue($this->current_settings->getUsedBookingObjectIds());
280 
281  $form->addCommandButton("saveSettings", $lng->txt("save"));
282 
283  $form->setTitle($lng->txt("book_pool_selection"));
284  $form->setFormAction($ctrl->getFormAction($this));
285 
286  return $form;
287  }
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettings()

ilBookingGatewayGUI::saveSettings ( )

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

References $ctrl, $i, $lng, $main_tpl, $use_book_repo, checkBookingPoolsForSchedules(), initSettingsForm(), ilCtrl\redirect(), and ilLanguage\txt().

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

◆ selectPool()

ilBookingGatewayGUI::selectPool ( )
protected

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

References ILIAS\Repository\ctrl().

204  : void
205  {
206  if ($this->return_to !== "") {
207  $this->ctrl->redirectByClass($this->return_to);
208  }
209  }
+ Here is the call graph for this function:

◆ setSubTabs()

ilBookingGatewayGUI::setSubTabs ( string  $active)
protected

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

References $ctrl, $lng, $tabs, ilTabsGUI\activateSubTab(), ilTabsGUI\addSubTab(), ilCtrl\getLinkTarget(), ilCtrl\getLinkTargetByClass(), and ilLanguage\txt().

Referenced by executeCommand(), and settings().

213  : void {
214  $tabs = $this->tabs;
215  $ctrl = $this->ctrl;
216  $lng = $this->lng;
217 
218  if ($this->pools_selected) {
219  $tabs->addSubTab(
220  "book_obj",
221  $lng->txt("book_booking_objects"),
222  $ctrl->getLinkTargetByClass("ilbookingobjectservicegui", "")
223  );
224  $tabs->addSubTab(
225  "reservations",
226  $lng->txt("book_log"),
227  $ctrl->getLinkTargetByClass("ilbookingreservationsgui", "")
228  );
229  }
230  if ($this->ref_id === $this->main_host_ref_id) {
231  $tabs->addSubTab(
232  "settings",
233  $lng->txt("settings"),
234  $ctrl->getLinkTarget($this, "settings")
235  );
236  }
237 
238  $tabs->activateSubTab($active);
239  }
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
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...
activateSubTab(string $a_id)
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ settings()

ilBookingGatewayGUI::settings ( )
protected

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

References $main_tpl, initSettingsForm(), and setSubTabs().

257  : void
258  {
259  $this->setSubTabs("settings");
261  $form = $this->initSettingsForm();
262  $main_tpl->setContent($form->getHTML());
263  }
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $main_tpl
+ Here is the call graph for this function:

◆ show()

ilBookingGatewayGUI::show ( )
protected

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

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

241  : void
242  {
243  $ctrl = $this->ctrl;
244  if ($this->pools_selected) {
245  $ctrl->redirectByClass("ilbookingobjectservicegui");
246  } elseif ($this->ref_id === $this->main_host_ref_id) {
247  $ctrl->redirect($this, "settings");
248  }
249 
250  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("book_no_pools_selected"));
251  }
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
+ Here is the call graph for this function:

◆ showPoolSelector()

ilBookingGatewayGUI::showPoolSelector ( string  $return_to)
protected

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

References $ref_id, ilObject\_lookupObjectId(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by executeCommand().

186  : void {
187  //
188  $options = [];
189  foreach ($this->use_book_repo->getUsedBookingPools(ilObject::_lookupObjectId($this->main_host_ref_id), false) as $ref_id) {
191  }
192 
193  $this->ctrl->setParameter($this, "return_to", $return_to);
194  if (count($options) > 0) {
195  $si = new ilSelectInputGUI("", "pool_ref_id");
196  $si->setOptions($options);
197  $si->setValue($this->current_pool_ref_id);
198  $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
199  $this->toolbar->addInputItem($si, false);
200  $this->toolbar->addFormButton($this->lng->txt("book_select_pool"), "selectPool");
201  }
202  }
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _lookupObjectId(int $ref_id)
+ 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 29 of file class.ilBookingGatewayGUI.php.

◆ $ctrl

ilCtrl ilBookingGatewayGUI::$ctrl
protected

◆ $current_pool_ref_id

int ilBookingGatewayGUI::$current_pool_ref_id
protected

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

◆ $current_settings

ilObjBookingServiceSettings ilBookingGatewayGUI::$current_settings
protected

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

◆ $help

ilBookingHelpAdapter ilBookingGatewayGUI::$help
protected

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

◆ $lng

ilLanguage ilBookingGatewayGUI::$lng
protected

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

Referenced by initSettingsForm(), saveSettings(), and setSubTabs().

◆ $main_host_ref_id

int ilBookingGatewayGUI::$main_host_ref_id = 0
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilBookingGatewayGUI::$main_tpl
protected

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

Referenced by saveSettings(), and settings().

◆ $obj_id

int ilBookingGatewayGUI::$obj_id
protected

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

◆ $parent_gui

ilObjectGUI ilBookingGatewayGUI::$parent_gui
protected

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

Referenced by __construct().

◆ $pool

ilObjBookingPool ilBookingGatewayGUI::$pool = null
protected

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

◆ $pools_selected

bool ilBookingGatewayGUI::$pools_selected = false
protected

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

◆ $ref_id

int ilBookingGatewayGUI::$ref_id
protected

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

Referenced by showPoolSelector().

◆ $return_to

string ilBookingGatewayGUI::$return_to = ""
protected

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

◆ $seed

string ilBookingGatewayGUI::$seed
protected

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

◆ $sseed

string ilBookingGatewayGUI::$sseed
protected

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

◆ $tabs

ilTabsGUI ilBookingGatewayGUI::$tabs
protected

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

Referenced by setSubTabs().

◆ $toolbar

ilToolbarGUI ilBookingGatewayGUI::$toolbar
protected

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

◆ $use_book_repo

ilObjUseBookDBRepository ilBookingGatewayGUI::$use_book_repo
protected

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

Referenced by saveSettings().


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