ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBookingObjectGUI Class Reference

Class ilBookingObjectGUI. More...

+ Inheritance diagram for ilBookingObjectGUI:
+ Collaboration diagram for ilBookingObjectGUI:

Public Member Functions

 activateManagement ($a_val)
 Activate management. More...
 
 isManagementActivated ()
 Is management activated? More...
 
 executeCommand ()
 
 render ()
 Render list of booking objects. More...
 
 applyFilter ()
 
 resetFilter ()
 
 create (ilPropertyFormGUI $a_form=null)
 Render creation form. More...
 
 edit (ilPropertyFormGUI $a_form=null)
 Render edit form. More...
 
 initForm ($a_mode="create", $id=null)
 Build property form. More...
 
 save ()
 Create new object dataset. More...
 
 update ()
 Update object dataset. More...
 
 confirmDelete ()
 Confirm delete. More...
 
 delete ()
 Delete object. More...
 
 deliverInfo ()
 

Protected Member Functions

 getPoolRefId ()
 Get ref id of booking pool. More...
 
 getPoolObjId ()
 Get obj id of booking pool. More...
 
 hasPoolSchedule ()
 Has booking pool a schedule? More...
 
 getPoolOverallLimit ()
 Get booking pool overall limit. More...
 
 showNoScheduleMessage ()
 Show no schedule message. More...
 
 returnToPreferences ()
 Return to preferences. More...
 
 setHelpId ($a_id)
 

Protected Attributes

 $ctrl
 
 $tpl
 
 $lng
 
 $access
 
 $tabs
 
 $help
 
 $obj_data_cache
 
 $user
 
 $pool_has_schedule
 
 $pool_overall_limit
 
 $pool_uses_preferences = false
 
 $management = true
 
 $context_obj_id
 
 $object_id
 

Detailed Description

Member Function Documentation

◆ activateManagement()

ilBookingObjectGUI::activateManagement (   $a_val)

Activate management.

Parameters
bool$a_val

Definition at line 122 of file class.ilBookingObjectGUI.php.

123 {
124 $this->management = $a_val;
125 }

Referenced by ilBookingObjectServiceGUI\__construct().

+ Here is the caller graph for this function:

◆ applyFilter()

ilBookingObjectGUI::applyFilter ( )

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

266 {
267 $table = new ilBookingObjectsTableGUI($this, 'render', $this->getPoolRefId(), $this->getPoolObjId(), $this->hasPoolSchedule(), $this->getPoolOverallLimit(), $this->isManagementActivated());
268 $table->resetOffset();
269 $table->writeFilterToSession();
270 $this->render();
271 }
isManagementActivated()
Is management activated?
hasPoolSchedule()
Has booking pool a schedule?
getPoolOverallLimit()
Get booking pool overall limit.
render()
Render list of booking objects.
getPoolObjId()
Get obj id of booking pool.
getPoolRefId()
Get ref id of booking pool.
List booking objects (for booking type)

References getPoolObjId(), getPoolOverallLimit(), getPoolRefId(), hasPoolSchedule(), isManagementActivated(), and render().

+ Here is the call graph for this function:

◆ confirmDelete()

ilBookingObjectGUI::confirmDelete ( )

Confirm delete.

Definition at line 556 of file class.ilBookingObjectGUI.php.

557 {
558 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
559 return;
560 }
561
562 $ilCtrl = $this->ctrl;
565 $ilTabs = $this->tabs;
566
567 $ilTabs->clearTargets();
568 $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
569
570 $conf = new ilConfirmationGUI();
571 $conf->setFormAction($ilCtrl->getFormAction($this));
572 $conf->setHeaderText($lng->txt('book_confirm_delete'));
573
574 $type = new ilBookingObject($this->object_id);
575 $conf->addItem('object_id', $this->object_id, $type->getTitle());
576 $conf->setConfirm($lng->txt('delete'), 'delete');
577 $conf->setCancel($lng->txt('cancel'), 'render');
578
579 $tpl->setContent($conf->getHTML());
580 }
a bookable ressource
Confirmation screen class.
$type

References $ctrl, $lng, $tabs, $tpl, and $type.

◆ create()

ilBookingObjectGUI::create ( ilPropertyFormGUI  $a_form = null)

Render creation form.

Definition at line 284 of file class.ilBookingObjectGUI.php.

285 {
286 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
287 return;
288 }
289
290 $ilCtrl = $this->ctrl;
293 $ilTabs = $this->tabs;
294
295 $ilTabs->clearTargets();
296 $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
297
298 $this->setHelpId('create');
299
300 if (!$a_form) {
301 $a_form = $this->initForm();
302 }
303 $tpl->setContent($a_form->getHTML());
304 }
initForm($a_mode="create", $id=null)
Build property form.

References $ctrl, $lng, $tabs, $tpl, initForm(), and setHelpId().

Referenced by save().

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

◆ delete()

ilBookingObjectGUI::delete ( )

Delete object.

Definition at line 585 of file class.ilBookingObjectGUI.php.

586 {
587 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
588 return;
589 }
590
591 $ilCtrl = $this->ctrl;
593
594 $obj = new ilBookingObject($this->object_id);
595 $obj->delete();
596
597 ilUtil::sendSuccess($lng->txt('book_object_deleted'), true);
598 $ilCtrl->setParameter($this, 'object_id', "");
599 $ilCtrl->redirect($this, 'render');
600 }

References $ctrl, and $lng.

◆ deliverInfo()

ilBookingObjectGUI::deliverInfo ( )

Definition at line 603 of file class.ilBookingObjectGUI.php.

604 {
605 $id = $this->object_id;
606 if (!$id) {
607 return;
608 }
609
610 $obj = new ilBookingObject($id);
611 $file = $obj->getFileFullPath();
612 if ($file) {
613 ilUtil::deliverFile($file, $obj->getFile());
614 }
615 }
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

References $object_id, and ilUtil\deliverFile().

+ Here is the call graph for this function:

◆ edit()

ilBookingObjectGUI::edit ( ilPropertyFormGUI  $a_form = null)

Render edit form.

Definition at line 309 of file class.ilBookingObjectGUI.php.

310 {
311 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
312 return;
313 }
314
316 $ilCtrl = $this->ctrl;
317 $ilTabs = $this->tabs;
319
320 $ilTabs->clearTargets();
321 $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
322
323 $this->setHelpId('edit');
324
325 if (!$a_form) {
326 $a_form = $this->initForm('edit', $this->object_id);
327 }
328 $tpl->setContent($a_form->getHTML());
329 }

References $ctrl, $lng, $tabs, $tpl, initForm(), and setHelpId().

Referenced by update().

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

◆ executeCommand()

ilBookingObjectGUI::executeCommand ( )
Returns
bool
Exceptions
ilCtrlException

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

185 {
186 $ilCtrl = $this->ctrl;
187
188 $next_class = $ilCtrl->getNextClass($this);
189
190 switch ($next_class) {
191
192 case "ilpropertyformgui":
193 // only case is currently adv metadata internal link in info settings, see #24497
194 $form = $this->initForm();
195 $this->ctrl->forwardCommand($form);
196 break;
197
198 case "ilbookingprocessgui":
199 if (!$this->pool_uses_preferences) {
200 $ilCtrl->setReturn($this, "render");
201 } else {
202 $ilCtrl->setReturn($this, "returnToPreferences");
203 }
204 $process_gui = new ilBookingProcessGUI(
205 $this->pool_gui->object,
206 $this->object_id,
207 $this->help,
208 $this->seed,
209 $this->sseed,
210 $this->context_obj_id
211 );
212 $this->ctrl->forwardCommand($process_gui);
213 break;
214
215 default:
216 $cmd = $ilCtrl->getCmd("render");
217 $this->$cmd();
218 break;
219 }
220 return true;
221 }
Booking process ui class.

References $ctrl, and initForm().

+ Here is the call graph for this function:

◆ getPoolObjId()

ilBookingObjectGUI::getPoolObjId ( )
protected

Get obj id of booking pool.

Returns
int

Definition at line 153 of file class.ilBookingObjectGUI.php.

153 : int
154 {
155 return $this->pool_gui->object->getId();
156 }

Referenced by applyFilter(), initForm(), render(), resetFilter(), and save().

+ Here is the caller graph for this function:

◆ getPoolOverallLimit()

ilBookingObjectGUI::getPoolOverallLimit ( )
protected

Get booking pool overall limit.

Returns
int

Definition at line 173 of file class.ilBookingObjectGUI.php.

174 {
175 return $this->hasPoolSchedule()
176 ? null
177 : $this->pool_gui->object->getOverallLimit();
178 }

References hasPoolSchedule().

Referenced by applyFilter(), render(), and resetFilter().

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

◆ getPoolRefId()

ilBookingObjectGUI::getPoolRefId ( )
protected

Get ref id of booking pool.

Returns
int

Definition at line 143 of file class.ilBookingObjectGUI.php.

143 : int
144 {
145 return $this->pool_gui->ref_id;
146 }

Referenced by applyFilter(), render(), and resetFilter().

+ Here is the caller graph for this function:

◆ hasPoolSchedule()

ilBookingObjectGUI::hasPoolSchedule ( )
protected

Has booking pool a schedule?

Returns
bool

Definition at line 163 of file class.ilBookingObjectGUI.php.

163 : bool
164 {
165 return ($this->pool_gui->object->getScheduleType() == ilObjBookingPool::TYPE_FIX_SCHEDULE);
166 }

References ilObjBookingPool\TYPE_FIX_SCHEDULE.

Referenced by applyFilter(), getPoolOverallLimit(), initForm(), render(), resetFilter(), save(), and update().

+ Here is the caller graph for this function:

◆ initForm()

ilBookingObjectGUI::initForm (   $a_mode = "create",
  $id = null 
)

Build property form.

Parameters
string$a_mode
int$id
Returns
object

Definition at line 342 of file class.ilBookingObjectGUI.php.

343 {
345 $ilCtrl = $this->ctrl;
346 $ilObjDataCache = $this->obj_data_cache;
347
348 $form_gui = new ilPropertyFormGUI();
349
350 $title = new ilTextInputGUI($lng->txt("title"), "title");
351 $title->setRequired(true);
352 $title->setSize(40);
353 $title->setMaxLength(120);
354 $form_gui->addItem($title);
355
356 $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
357 $desc->setCols(70);
358 $desc->setRows(15);
359 $form_gui->addItem($desc);
360
361 $file = new ilFileInputGUI($lng->txt("book_additional_info_file"), "file");
362 $file->setALlowDeletion(true);
363 $form_gui->addItem($file);
364
365 $nr = new ilNumberInputGUI($lng->txt("booking_nr_of_items"), "items");
366 $nr->setRequired(true);
367 $nr->setSize(3);
368 $nr->setMaxLength(3);
369 $form_gui->addItem($nr);
370
371 if ($this->hasPoolSchedule()) {
372 $options = array();
373 foreach (ilBookingSchedule::getList($ilObjDataCache->lookupObjId($this->getPoolRefId())) as $schedule) {
374 $options[$schedule["booking_schedule_id"]] = $schedule["title"];
375 }
376 $schedule = new ilSelectInputGUI($lng->txt("book_schedule"), "schedule");
377 $schedule->setRequired(true);
378 $schedule->setOptions($options);
379 $form_gui->addItem($schedule);
380 }
381
382 $post = new ilFormSectionHeaderGUI();
383 $post->setTitle($lng->txt("book_post_booking_information"));
384 $form_gui->addItem($post);
385
386 $pdesc = new ilTextAreaInputGUI($lng->txt("book_post_booking_text"), "post_text");
387 $pdesc->setCols(70);
388 $pdesc->setRows(15);
389 $pdesc->setInfo($lng->txt("book_post_booking_text_info"));
390 $form_gui->addItem($pdesc);
391
392 $pfile = new ilFileInputGUI($lng->txt("book_post_booking_file"), "post_file");
393 $pfile->setALlowDeletion(true);
394 $form_gui->addItem($pfile);
395
396 // #18214 - should also work for new objects
397 $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR, "book", $this->getPoolObjId(), "bobj", $id);
398 $this->record_gui->setPropertyForm($form_gui);
399 $this->record_gui->parse();
400
401 if ($a_mode == "edit") {
402 $form_gui->setTitle($lng->txt("book_edit_object"));
403
404 $item = new ilHiddenInputGUI('object_id');
405 $item->setValue($id);
406 $form_gui->addItem($item);
407
408 $obj = new ilBookingObject($id);
409 $title->setValue($obj->getTitle());
410 $desc->setValue($obj->getDescription());
411 $nr->setValue($obj->getNrOfItems());
412 $pdesc->setValue($obj->getPostText());
413 $file->setValue($obj->getFile());
414 $pfile->setValue($obj->getPostFile());
415
416 if (isset($schedule)) {
417 $schedule->setValue($obj->getScheduleId());
418 }
419
420 $form_gui->addCommandButton("update", $lng->txt("save"));
421 } else {
422 $form_gui->setTitle($lng->txt("book_add_object"));
423 $form_gui->addCommandButton("save", $lng->txt("save"));
424 $form_gui->addCommandButton("render", $lng->txt("cancel"));
425 }
426 $form_gui->setFormAction($ilCtrl->getFormAction($this));
427
428 return $form_gui;
429 }
static getList($a_pool_id)
Get list of booking objects for given pool.
This class represents a file property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References $ctrl, $lng, $obj_data_cache, ilBookingSchedule\getList(), getPoolObjId(), hasPoolSchedule(), and ilAdvancedMDRecordGUI\MODE_EDITOR.

Referenced by create(), edit(), executeCommand(), save(), and update().

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

◆ isManagementActivated()

ilBookingObjectGUI::isManagementActivated ( )

Is management activated?

Returns
bool

Definition at line 132 of file class.ilBookingObjectGUI.php.

References $management.

Referenced by applyFilter(), render(), and resetFilter().

+ Here is the caller graph for this function:

◆ render()

ilBookingObjectGUI::render ( )

Render list of booking objects.

uses ilBookingObjectsTableGUI

Definition at line 244 of file class.ilBookingObjectGUI.php.

245 {
246 $this->showNoScheduleMessage();
247
249 $ilCtrl = $this->ctrl;
251 $ilAccess = $this->access;
252
253 if ($this->isManagementActivated() && $ilAccess->checkAccess('write', '', $this->getPoolRefId())) {
254 $bar = new ilToolbarGUI;
255 $bar->addButton($lng->txt('book_add_object'), $ilCtrl->getLinkTarget($this, 'create'));
256 $bar = $bar->getHTML();
257 }
258
259 $tpl->setPermanentLink('book', $this->getPoolRefId());
260
261 $table = new ilBookingObjectsTableGUI($this, 'render', $this->getPoolRefId(), $this->getPoolObjId(), $this->hasPoolSchedule(), $this->getPoolOverallLimit(), $this->isManagementActivated());
262 $tpl->setContent($bar . $table->getHTML());
263 }
showNoScheduleMessage()
Show no schedule message.

References $access, Vendor\Package\$bar, $ctrl, $lng, $tpl, getPoolObjId(), getPoolOverallLimit(), getPoolRefId(), hasPoolSchedule(), isManagementActivated(), and showNoScheduleMessage().

Referenced by applyFilter(), and resetFilter().

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

◆ resetFilter()

ilBookingObjectGUI::resetFilter ( )

Definition at line 273 of file class.ilBookingObjectGUI.php.

274 {
275 $table = new ilBookingObjectsTableGUI($this, 'render', $this->getPoolRefId(), $this->getPoolObjId(), $this->hasPoolSchedule(), $this->getPoolOverallLimit(), $this->isManagementActivated());
276 $table->resetOffset();
277 $table->resetFilter();
278 $this->render();
279 }

References getPoolObjId(), getPoolOverallLimit(), getPoolRefId(), hasPoolSchedule(), isManagementActivated(), and render().

+ Here is the call graph for this function:

◆ returnToPreferences()

ilBookingObjectGUI::returnToPreferences ( )
protected

Return to preferences.

Definition at line 234 of file class.ilBookingObjectGUI.php.

235 {
236 $this->ctrl->redirectByClass("ilBookingPreferencesGUI");
237 }

◆ save()

ilBookingObjectGUI::save ( )

Create new object dataset.

Definition at line 434 of file class.ilBookingObjectGUI.php.

435 {
436 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
437 return;
438 }
439
440 $ilCtrl = $this->ctrl;
442
443 $form = $this->initForm();
444 if ($form->checkInput()) {
445 $valid = true;
446 if ($this->record_gui &&
447 !$this->record_gui->importEditFormPostValues()) {
448 $valid = false;
449 }
450 if ($valid) {
451 $obj = new ilBookingObject;
452 $obj->setPoolId($this->getPoolObjId());
453 $obj->setTitle($form->getInput("title"));
454 $obj->setDescription($form->getInput("desc"));
455 $obj->setNrOfItems($form->getInput("items"));
456 $obj->setPostText($form->getInput("post_text"));
457
458 if ($this->hasPoolSchedule()) {
459 $obj->setScheduleId($form->getInput("schedule"));
460 }
461
462 $obj->save();
463
464 $file = $form->getItemByPostVar("file");
465 if ($_FILES["file"]["tmp_name"]) {
466 $obj->uploadFile($_FILES["file"]);
467 } elseif ($file->getDeletionFlag()) {
468 $obj->deleteFile();
469 }
470
471 $pfile = $form->getItemByPostVar("post_file");
472 if ($_FILES["post_file"]["tmp_name"]) {
473 $obj->uploadPostFile($_FILES["post_file"]);
474 } elseif ($pfile->getDeletionFlag()) {
475 $obj->deletePostFile();
476 }
477
478 $obj->update();
479
480 if ($this->record_gui) {
481 $this->record_gui->writeEditForm(null, $obj->getId());
482 }
483
484 ilUtil::sendSuccess($lng->txt("book_object_added"), true);
485 $ilCtrl->redirect($this, "render");
486 }
487 }
488
489 $form->setValuesByPost();
490 $this->create($form);
491 }
create(ilPropertyFormGUI $a_form=null)
Render creation form.
setPoolId($a_pool_id)
Set booking pool id.
$valid

References $ctrl, $lng, $valid, create(), getPoolObjId(), hasPoolSchedule(), initForm(), and ilBookingObject\setPoolId().

+ Here is the call graph for this function:

◆ setHelpId()

ilBookingObjectGUI::setHelpId (   $a_id)
protected

Definition at line 331 of file class.ilBookingObjectGUI.php.

332 {
333 $this->help->setHelpId($a_id);
334 }
help()
Definition: help.php:2

References help().

Referenced by create(), and edit().

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

◆ showNoScheduleMessage()

ilBookingObjectGUI::showNoScheduleMessage ( )
protected

Show no schedule message.

Definition at line 226 of file class.ilBookingObjectGUI.php.

227 {
228 $this->pool_gui->showNoScheduleMessage();
229 }

Referenced by render().

+ Here is the caller graph for this function:

◆ update()

ilBookingObjectGUI::update ( )

Update object dataset.

Definition at line 496 of file class.ilBookingObjectGUI.php.

497 {
498 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
499 return;
500 }
501
503 $ilCtrl = $this->ctrl;
504
505 $form = $this->initForm('edit', $this->object_id);
506 if ($form->checkInput()) {
507 $valid = true;
508 if ($this->record_gui &&
509 !$this->record_gui->importEditFormPostValues()) {
510 $valid = false;
511 }
512
513 if ($valid) {
514 $obj = new ilBookingObject($this->object_id);
515 $obj->setTitle($form->getInput("title"));
516 $obj->setDescription($form->getInput("desc"));
517 $obj->setNrOfItems($form->getInput("items"));
518 $obj->setPostText($form->getInput("post_text"));
519
520 $file = $form->getItemByPostVar("file");
521 if ($_FILES["file"]["tmp_name"]) {
522 $obj->uploadFile($_FILES["file"]);
523 } elseif ($file->getDeletionFlag()) {
524 $obj->deleteFile();
525 }
526
527 $pfile = $form->getItemByPostVar("post_file");
528 if ($_FILES["post_file"]["tmp_name"]) {
529 $obj->uploadPostFile($_FILES["post_file"]);
530 } elseif ($pfile->getDeletionFlag()) {
531 $obj->deletePostFile();
532 }
533
534 if ($this->hasPoolSchedule()) {
535 $obj->setScheduleId($form->getInput("schedule"));
536 }
537
538 $obj->update();
539
540 if ($this->record_gui) {
541 $this->record_gui->writeEditForm();
542 }
543
544 ilUtil::sendSuccess($lng->txt("book_object_updated"), true);
545 $ilCtrl->redirect($this, "render");
546 }
547 }
548
549 $form->setValuesByPost();
550 $this->edit($form);
551 }
edit(ilPropertyFormGUI $a_form=null)
Render edit form.

References $ctrl, $lng, $valid, edit(), hasPoolSchedule(), and initForm().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilBookingObjectGUI::$access
protected

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

Referenced by render().

◆ $context_obj_id

ilBookingObjectGUI::$context_obj_id
protected

Definition at line 71 of file class.ilBookingObjectGUI.php.

◆ $ctrl

ilBookingObjectGUI::$ctrl
protected

◆ $help

ilBookingObjectGUI::$help
protected

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

Referenced by ilBookingObjectServiceGUI\__construct().

◆ $lng

ilBookingObjectGUI::$lng
protected

◆ $management

ilBookingObjectGUI::$management = true
protected

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

Referenced by isManagementActivated().

◆ $obj_data_cache

ilBookingObjectGUI::$obj_data_cache
protected

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

Referenced by initForm().

◆ $object_id

ilBookingObjectGUI::$object_id
protected

Definition at line 76 of file class.ilBookingObjectGUI.php.

Referenced by deliverInfo().

◆ $pool_has_schedule

ilBookingObjectGUI::$pool_has_schedule
protected

Definition at line 53 of file class.ilBookingObjectGUI.php.

◆ $pool_overall_limit

ilBookingObjectGUI::$pool_overall_limit
protected

Definition at line 54 of file class.ilBookingObjectGUI.php.

◆ $pool_uses_preferences

ilBookingObjectGUI::$pool_uses_preferences = false
protected

Definition at line 59 of file class.ilBookingObjectGUI.php.

◆ $tabs

ilBookingObjectGUI::$tabs
protected

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

Referenced by confirmDelete(), create(), and edit().

◆ $tpl

ilBookingObjectGUI::$tpl
protected

Definition at line 21 of file class.ilBookingObjectGUI.php.

Referenced by confirmDelete(), create(), edit(), and render().

◆ $user

ilBookingObjectGUI::$user
protected

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


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