ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBookingGatewayGUI Class Reference

This class is used for inegration 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, $main_host_ref_id=0)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 initSettingsForm ()
 Init settings form. More...
 
 saveSettings ()
 Save settings form. More...
 

Protected Member Functions

 initPool ()
 Init pool. More...
 
 showPoolSelector ($return_to)
 Pool selector. More...
 
 selectPool ()
 Select pool. More...
 
 setSubTabs ($active)
 Set sub tabs. More...
 
 show ()
 Show. More...
 
 settings ()
 Settings. More...
 
 checkBookingPoolsForSchedules ($ids)
 Check if all pools have schedules. More...
 

Protected Attributes

 $ctrl
 
 $lng
 
 $main_tpl
 
 $parent_gui
 
 $tabs
 
 $obj_id
 
 $ref_id
 
 $current_settings
 
 $current_pool_ref_id
 
 $pool = null
 
 $toolbar
 
 $main_host_ref_id = 0
 
 $pools_selected = false
 

Detailed Description

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

courses.

ilBookingGatewayGUI: ilPropertyFormGUI, ilBookingObjectServiceGUI, ilBookingReservationsGUI

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

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

References $_GET, $DIC, $main_host_ref_id, $parent_gui, help(), initPool(), and ilUtil\stripSlashes().

87  {
88  global $DIC;
89 
90  $this->ctrl = $DIC->ctrl();
91  $this->lng = $DIC->language();
92  $this->main_tpl = $DIC->ui()->mainTemplate();
93  $this->parent_gui = $parent_gui;
94  $this->tabs = $DIC->tabs();
95 
96  $this->lng->loadLanguageModule("book");
97 
98  // current parent context (e.g. session in course)
99  $this->obj_id = (int) $parent_gui->object->getId();
100  $this->ref_id = (int) $parent_gui->object->getRefId();
101 
102  $this->main_host_ref_id = ($main_host_ref_id == 0)
103  ? $this->ref_id
105 
106 
107  $this->seed = ilUtil::stripSlashes($_GET['seed']);
108  $this->sseed = ilUtil::stripSlashes($_GET['sseed']);
109 
110  $this->toolbar = $DIC->toolbar();
111 
112  $this->use_book_repo = new ilObjUseBookDBRepository($DIC->database());
113 
114  if (in_array($_REQUEST["return_to"], ["ilbookingobjectservicegui", "ilbookingreservationsgui"])) {
115  $this->return_to = $_REQUEST["return_to"];
116  }
117 
118  // get current settings
119  $handler = new BookingManager\getObjectSettingsCommandHandler(
120  new BookingManager\getObjectSettingsCommand($this->obj_id),
121  $this->use_book_repo
122  );
123  $this->current_settings = $handler->handle()->getSettings();
124 
125  $this->initPool();
126 
127  if (is_object($this->pool)) {
128  $this->help = new ilBookingHelpAdapter($this->pool, $DIC["ilHelp"]);
129  $DIC["ilHelp"]->setScreenIdComponent("book");
130  }
131  }
This repo stores infos on repository objects that are using booking managers as a service (resource m...
$_GET["client_id"]
Help adapter for booking manager.
help()
Definition: help.php:2
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ checkBookingPoolsForSchedules()

ilBookingGatewayGUI::checkBookingPoolsForSchedules (   $ids)
protected

Check if all pools have schedules.

Parameters
int[]$ids pool ref ids
Returns
bool

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

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

Referenced by saveSettings().

390  {
391  foreach ($ids as $pool_ref_id) {
393  return false;
394  }
395  }
396  return true;
397  }
static hasExistingSchedules($a_pool_id)
Check if given pool has any defined schedules.
static _lookupObjectId($a_ref_id)
lookup object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilBookingGatewayGUI::executeCommand ( )

Execute command.

Exceptions
ilCtrlException

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

References $ctrl, help(), initSettingsForm(), setSubTabs(), and showPoolSelector().

175  {
176  $ctrl = $this->ctrl;
177 
178  $next_class = $ctrl->getNextClass($this);
179  $cmd = $ctrl->getCmd("show");
180 
181  switch ($next_class) {
182  case "ilpropertyformgui":
183  $form = $this->initSettingsForm();
184  $ctrl->setReturn($this, 'settings');
185  $ctrl->forwardCommand($form);
186  break;
187 
188  case "ilbookingobjectservicegui":
189  $this->setSubTabs("book_obj");
190  $this->showPoolSelector("ilbookingobjectservicegui");
191  $book_ser_gui = new ilBookingObjectServiceGUI(
192  $this->ref_id,
193  $this->current_pool_ref_id,
194  $this->use_book_repo,
195  $this->seed,
196  $this->sseed,
197  $this->help
198  );
199  $ctrl->forwardCommand($book_ser_gui);
200  break;
201 
202  case "ilbookingreservationsgui":
203  $this->showPoolSelector("ilbookingreservationsgui");
204  $this->setSubTabs("reservations");
205  $res_gui = new ilBookingReservationsGUI($this->pool, $this->help, $this->obj_id);
206  $this->ctrl->forwardCommand($res_gui);
207  break;
208 
209 
210  default:
211  if (in_array($cmd, array("show", "settings", "saveSettings", "selectPool"))) {
212  $this->$cmd();
213  }
214  }
215  }
initSettingsForm()
Init settings form.
help()
Definition: help.php:2
showPoolSelector($return_to)
Pool selector.
setSubTabs($active)
Set sub tabs.
+ Here is the call graph for this function:

◆ initPool()

ilBookingGatewayGUI::initPool ( )
protected

Init pool.

Determin 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 143 of file class.ilBookingGatewayGUI.php.

References $_GET, $_POST, $ctrl, and ilObject\_lookupObjId().

Referenced by __construct().

144  {
145  $ctrl = $this->ctrl;
146 
147  $ctrl->saveParameter($this, "pool_ref_id");
148  $pool_ref_id = ($_POST["pool_ref_id"] > 0)
149  ? (int) $_POST["pool_ref_id"]
150  : (int) $_GET["pool_ref_id"];
151 
152  $book_ref_ids = $this->use_book_repo->getUsedBookingPools(ilObject::_lookupObjId($this->main_host_ref_id));
153 
154  $this->pools_selected = (count($book_ref_ids) > 0);
155 
156  if (!in_array($pool_ref_id, $book_ref_ids)) {
157  if (count($book_ref_ids) > 0) {
158  $pool_ref_id = current($book_ref_ids);
159  } else {
160  $pool_ref_id = 0;
161  }
162  }
163  $this->current_pool_ref_id = $pool_ref_id;
164  if ($this->current_pool_ref_id > 0) {
165  $this->pool = new ilObjBookingPool($this->current_pool_ref_id);
166  $ctrl->setParameter($this, "pool_ref_id", $this->current_pool_ref_id);
167  }
168  }
$_GET["client_id"]
Class ilObjBookingPool.
static _lookupObjId($a_id)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSettingsForm()

ilBookingGatewayGUI::initSettingsForm ( )

Init settings form.

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

References $ctrl, $lng, and ilRepositorySelector2InputGUI\getExplorerGUI().

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

318  {
319  $ctrl = $this->ctrl;
320  $lng = $this->lng;
321 
322  $form = new ilPropertyFormGUI();
323 
324  // booking tools
325  $repo = new ilRepositorySelector2InputGUI($this->lng->txt("objs_book"), "booking_obj_ids", true);
326  $repo->getExplorerGUI()->setSelectableTypes(["book"]);
327  $repo->getExplorerGUI()->setTypeWhiteList(
328  ["book", "root", "cat", "grp", "fold", "crs"]
329  );
330  $form->addItem($repo);
331  $repo->setValue($this->current_settings->getUsedBookingObjectIds());
332 
333  $form->addCommandButton("saveSettings", $lng->txt("save"));
334 
335  $form->setTitle($lng->txt("book_pool_selection"));
336  $form->setFormAction($ctrl->getFormAction($this));
337 
338  return $form;
339  }
This class represents a property form user interface.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettings()

ilBookingGatewayGUI::saveSettings ( )

Save settings form.

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

References $ctrl, $i, $lng, $main_tpl, checkBookingPoolsForSchedules(), initSettingsForm(), and ilUtil\sendFailure().

345  {
346  $ctrl = $this->ctrl;
347  $lng = $this->lng;
349 
350  $form = $this->initSettingsForm();
351  if ($form->checkInput()) {
352  $b_ids = $form->getInput("booking_obj_ids");
353  $b_ids = is_array($b_ids)
354  ? array_map(function ($i) {
355  return (int) $i;
356  }, $b_ids)
357  : [];
358 
359  if (!$this->checkBookingPoolsForSchedules($b_ids)) {
360  ilUtil::sendFailure($lng->txt("book_all_pools_need_schedules"));
361  $form->setValuesByPost();
362  $main_tpl->setContent($form->getHtml());
363  return;
364  }
365 
366  $cmd = new BookingManager\saveObjectSettingsCommand(new ilObjBookingServiceSettings(
367  $this->obj_id,
368  $b_ids
369  ));
370 
371  $repo = $this->use_book_repo;
372  $handler = new BookingManager\saveObjectSettingsCommandHandler($cmd, $repo);
373  $handler->handle();
374 
375  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
376  $ctrl->redirect($this, "");
377  } else {
378  $form->setValuesByPost();
379  $main_tpl->setContent($form->getHtml());
380  }
381  }
Value object for booking service settings of a repository object.
initSettingsForm()
Init settings form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
checkBookingPoolsForSchedules($ids)
Check if all pools have schedules.
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ selectPool()

ilBookingGatewayGUI::selectPool ( )
protected

Select pool.

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

243  {
244  if ($this->return_to != "") {
245  $this->ctrl->redirectByClass($this->return_to);
246  }
247  }

◆ setSubTabs()

ilBookingGatewayGUI::setSubTabs (   $active)
protected

Set sub tabs.

Parameters
$active

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

References $ctrl, $lng, and $tabs.

Referenced by executeCommand(), and settings().

255  {
256  $tabs = $this->tabs;
257  $ctrl = $this->ctrl;
258  $lng = $this->lng;
259 
260  if ($this->pools_selected) {
261  $tabs->addSubTab(
262  "book_obj",
263  $lng->txt("book_objects_list"),
264  $ctrl->getLinkTargetByClass("ilbookingobjectservicegui", "")
265  );
266  $tabs->addSubTab(
267  "reservations",
268  $lng->txt("book_log"),
269  $ctrl->getLinkTargetByClass("ilbookingreservationsgui", "")
270  );
271  }
272  if ($this->ref_id == $this->main_host_ref_id) {
273  $tabs->addSubTab(
274  "settings",
275  $lng->txt("settings"),
276  $ctrl->getLinkTarget($this, "settings")
277  );
278  }
279 
280  $tabs->activateSubTab($active);
281  }
+ Here is the caller graph for this function:

◆ settings()

ilBookingGatewayGUI::settings ( )
protected

Settings.

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

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

307  {
308  $this->setSubTabs("settings");
310  $form = $this->initSettingsForm();
311  $main_tpl->setContent($form->getHTML());
312  }
initSettingsForm()
Init settings form.
setSubTabs($active)
Set sub tabs.
+ Here is the call graph for this function:

◆ show()

ilBookingGatewayGUI::show ( )
protected

Show.

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

References $ctrl, and ilUtil\sendFailure().

288  {
289  $ctrl = $this->ctrl;
290  if ($this->pools_selected) {
291  $ctrl->redirectByClass("ilbookingobjectservicegui");
292  } elseif ($this->ref_id == $this->main_host_ref_id) {
293  $ctrl->redirect($this, "settings");
294  }
295 
296  ilUtil::sendFailure($this->lng->txt("book_no_pools_selected"));
297  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ showPoolSelector()

ilBookingGatewayGUI::showPoolSelector (   $return_to)
protected

Pool selector.

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

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

Referenced by executeCommand().

221  {
222  //
223  $options = [];
224  foreach ($this->use_book_repo->getUsedBookingPools(ilObject::_lookupObjectId($this->main_host_ref_id)) as $ref_id) {
226  }
227 
228  $this->ctrl->setParameter($this, "return_to", $return_to);
229  if (count($options) > 0) {
230  $si = new ilSelectInputGUI("", "pool_ref_id");
231  $si->setOptions($options);
232  $si->setValue($this->current_pool_ref_id);
233  $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
234  $this->toolbar->addInputItem($si, false);
235  $this->toolbar->addFormButton($this->lng->txt("book_select_pool"), "selectPool");
236  }
237  }
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupObjId($a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilBookingGatewayGUI::$ctrl
protected

◆ $current_pool_ref_id

ilBookingGatewayGUI::$current_pool_ref_id
protected

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

◆ $current_settings

ilBookingGatewayGUI::$current_settings
protected

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

◆ $lng

ilBookingGatewayGUI::$lng
protected

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

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

◆ $main_host_ref_id

ilBookingGatewayGUI::$main_host_ref_id = 0
protected

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

Referenced by __construct().

◆ $main_tpl

ilBookingGatewayGUI::$main_tpl
protected

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

Referenced by saveSettings(), and settings().

◆ $obj_id

ilBookingGatewayGUI::$obj_id
protected

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

◆ $parent_gui

ilBookingGatewayGUI::$parent_gui
protected

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

Referenced by __construct().

◆ $pool

ilBookingGatewayGUI::$pool = null
protected

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

◆ $pools_selected

ilBookingGatewayGUI::$pools_selected = false
protected

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

◆ $ref_id

ilBookingGatewayGUI::$ref_id
protected

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

Referenced by showPoolSelector().

◆ $tabs

ilBookingGatewayGUI::$tabs
protected

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

Referenced by setSubTabs().

◆ $toolbar

ilBookingGatewayGUI::$toolbar
protected

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


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