ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjBookingPoolGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./classes/class.ilObjectGUI.php";
5 
16 {
21  function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
22  {
23  $this->type = "book";
24  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
25  $this->lng->loadLanguageModule("book");
26  }
27 
31  function executeCommand()
32  {
33  global $tpl, $ilTabs, $ilNavigationHistory;
34 
35  $next_class = $this->ctrl->getNextClass($this);
36  $cmd = $this->ctrl->getCmd();
37 
38  if(!$next_class && $cmd == 'render')
39  {
40  $this->ctrl->setCmdClass('ilBookingTypeGUI');
41  $next_class = $this->ctrl->getNextClass($this);
42  }
43 
44  if(substr($cmd, 0, 4) == 'book')
45  {
46  $next_class = '';
47  }
48 
49  $ilNavigationHistory->addItem($this->ref_id,
50  "./goto.php?target=book_".$this->ref_id, "book");
51 
52  $this->prepareOutput();
53 
54  switch($next_class)
55  {
56  case 'ilpermissiongui':
57  $this->tabs_gui->setTabActive('perm_settings');
58  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
59  $perm_gui =& new ilPermissionGUI($this);
60  $ret =& $this->ctrl->forwardCommand($perm_gui);
61  break;
62 
63  case 'ilbookingtypegui':
64  $this->tabs_gui->setTabActive('render');
65  include_once("Modules/BookingManager/classes/class.ilBookingTypeGUI.php");
66  $type_gui =& new ilBookingTypeGUI($this);
67  $ret =& $this->ctrl->forwardCommand($type_gui);
68  break;
69 
70  case 'ilbookingobjectgui':
71  $this->tabs_gui->setTabActive('render');
72  include_once("Modules/BookingManager/classes/class.ilBookingObjectGUI.php");
73  $object_gui =& new ilBookingObjectGUI($this);
74  $ret =& $this->ctrl->forwardCommand($object_gui);
75  break;
76 
77  case 'ilbookingschedulegui':
78  $this->tabs_gui->setTabActive('schedules');
79  include_once("Modules/BookingManager/classes/class.ilBookingScheduleGUI.php");
80  $schedule_gui =& new ilBookingScheduleGUI($this);
81  $ret =& $this->ctrl->forwardCommand($schedule_gui);
82  break;
83 
84  case 'ilpublicuserprofilegui':
85  $this->tabs_gui->setTabActive('schedules');
86  include_once("Services/User/classes/class.ilPublicUserProfileGUI.php");
87  $profile =& new ilPublicUserProfileGUI((int)$_GET["user"]);
88  $ret =& $this->ctrl->forwardCommand($profile);
89  break;
90 
91  case 'ilinfoscreengui':
92  $this->infoScreen();
93  break;
94 
95  default:
96  $cmd = $this->ctrl->getCmd();
97  $cmd .= 'Object';
98  $this->$cmd();
99  break;
100  }
101  return true;
102  }
103 
107  function createObject()
108  {
109  global $tpl;
110 
111  $form = $this->initForm();
112  $tpl->setContent($form->getHTML());
113  }
114 
118  function editObject()
119  {
120  global $tpl;
121 
122  $this->tabs_gui->setTabActive('edit');
123 
124  $form = $this->initForm("edit");
125  $tpl->setContent($form->getHTML());
126  }
127 
132  function initForm($a_mode = "create")
133  {
134  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
135 
136  $form_gui = new ilPropertyFormGUI();
137 
138  $title = new ilTextInputGUI($this->lng->txt("title"), "standard_title");
139  $title->setRequired(true);
140  $title->setSize(40);
141  $title->setMaxLength(120);
142  $form_gui->addItem($title);
143 
144  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
145  $desc->setCols(37);
146  $desc->setRows(2);
147  $form_gui->addItem($desc);
148 
149  if ($a_mode == "edit")
150  {
151  $online = new ilCheckboxInputGUI($this->lng->txt("online"), "online");
152  $form_gui->addItem($online);
153 
154  $public = new ilCheckboxInputGUI($this->lng->txt("book_public_log"), "public");
155  $public->setInfo($this->lng->txt("book_public_log_info"));
156  $form_gui->addItem($public);
157 
158  $slots = new ilNumberInputGUI($this->lng->txt("book_slots_no"), "slots");
159  $slots->setRequired(true);
160  $slots->setSize(4);
161  $slots->setMinValue(1);
162  $slots->setMaxValue(24);
163  $slots->setInfo($this->lng->txt("book_slots_no_info"));
164  $form_gui->addItem($slots);
165 
166  $form_gui->setTitle($this->lng->txt("settings"));
167  $title->setValue($this->object->getTitle());
168  $desc->setValue($this->object->getDescription());
169  $online->setChecked(!$this->object->isOffline());
170  $public->setChecked($this->object->hasPublicLog());
171  $slots->setValue($this->object->getNumberOfSlots());
172  $form_gui->addCommandButton("update", $this->lng->txt("save"));
173  $form_gui->addCommandButton("render", $this->lng->txt("cancel"));
174  }
175  else
176  {
177  $form_gui->setTitle($this->lng->txt("book_create_title"));
178  $form_gui->addCommandButton("save", $this->lng->txt("save"));
179  $form_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
180  }
181  $form_gui->setFormAction($this->ctrl->getFormAction($this));
182 
183  return $form_gui;
184  }
185 
189  function saveObject()
190  {
191  global $rbacadmin, $ilUser, $tpl, $ilCtrl;
192 
193  $form = $this->initForm();
194  if($form->checkInput())
195  {
196  $_POST["new_type"] = "book";
197  $_POST["Fobject"]["title"] = $form->getInput("standard_title");
198  $_POST["Fobject"]["desc"] = $form->getInput("description");
199 
200  // always call parent method first to create an object_data entry & a reference
201  $newObj = parent::saveObject();
202 
203  $newObj->setOffline(true);
204  $newObj->setNumberOfSlots(4);
205  $newObj->update();
206 
207  // always send a message
208  ilUtil::sendSuccess($this->lng->txt("book_pool_added"),true);
209 
210  // BEGIN ChangeEvent: Record object creation
211  global $ilUser;
212  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
214  {
215  ilChangeEvent::_recordWriteEvent($newObj->getId(), $ilUser->getId(), 'create');
216  }
217  // END ChangeEvent: Record object creation
218 
219  $this->ctrl->setParameter($this, "ref_id", $newObj->getRefId());
220  $this->ctrl->redirect($this, "edit");
221  }
222  else
223  {
224  $form->setValuesByPost();
225  $tpl->setContent($form->getHTML());
226  }
227  }
228 
232  function updateObject()
233  {
234  global $rbacadmin, $ilUser, $tpl, $ilCtrl;
235 
236  $form = $this->initForm("edit");
237  if($form->checkInput())
238  {
239  $_POST["Fobject"]["title"] = $form->getInput("standard_title");
240  $_POST["Fobject"]["desc"] = $form->getInput("description");
241 
242  $this->object->setOffline(!$form->getInput('online'));
243  $this->object->setPublicLog($form->getInput('public'));
244  $this->object->setNumberOfSlots($form->getInput('slots'));
245 
247 
248  $ilCtrl->redirect($this, "render");
249  }
250  else
251  {
252  $this->tabs_gui->setTabActive('edit');
253  $form->setValuesByPost();
254  $tpl->setContent($form->getHTML());
255  }
256  }
257 
258  function afterUpdate()
259  {
260 
261  }
262 
266  function setTabs()
267  {
268  global $ilAccess;
269 
270  if (in_array($this->ctrl->getCmd(), array("create", "save")) && !$this->ctrl->getNextClass())
271  {
272  return;
273  }
274 
275  $this->tabs_gui->addTab("render",
276  $this->lng->txt("book_booking_types"),
277  $this->ctrl->getLinkTarget($this, "render"));
278 
279  $this->tabs_gui->addTab("info",
280  $this->lng->txt("info_short"),
281  $this->ctrl->getLinkTarget($this, "infoscreen"));
282 
283  if ($ilAccess->checkAccess('write', '', $this->object->getRefId()) ||
284  $this->object->hasPublicLog())
285  {
286  $this->tabs_gui->addTab("log",
287  $this->lng->txt("book_log"),
288  $this->ctrl->getLinkTarget($this, "log"));
289  }
290 
291  if ($ilAccess->checkAccess('write', '', $this->object->getRefId()))
292  {
293  $this->tabs_gui->addTab("schedules",
294  $this->lng->txt("book_schedules"),
295  $this->ctrl->getLinkTargetByClass("ilbookingschedulegui", "render"));
296 
297  $this->tabs_gui->addTab("edit",
298  $this->lng->txt("settings"),
299  $this->ctrl->getLinkTarget($this, "edit"));
300  }
301 
302  if($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId()))
303  {
304  $this->tabs_gui->addTab("perm_settings",
305  $this->lng->txt("perm_settings"),
306  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
307  }
308  }
309 
313  function bookObject()
314  {
315  $this->tabs_gui->clearTargets();
316  $this->tabs_gui->setBackTarget($this->lng->txt('book_back_to_list'), $this->ctrl->getLinkTarget($this, 'render'));
317 
318  if(isset($_GET['object_id']))
319  {
320  $this->ctrl->setParameter($this, 'object_id', (int)$_GET['object_id']);
321  $this->renderBookingByObject((int)$_GET['object_id']);
322  }
323  else
324  {
325  $this->ctrl->setParameter($this, 'type_id', (int)$_GET['type_id']);
326  $this->renderBookingByType((int)$_GET['type_id']);
327  }
328  }
329 
334  protected function renderBookingByObject($a_object_id)
335  {
336  global $tpl;
337 
338  $this->lng->loadLanguageModule("dateplaner");
339 
340  include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
341  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
342  $obj = new ilBookingObject($a_object_id);
343  $schedule = new ilBookingSchedule($obj->getScheduleId());
344 
345  $tpl->setContent($this->renderList($schedule, array($a_object_id), $obj->getTitle()));
346  }
347 
352  protected function renderBookingByType($a_type_id)
353  {
354  global $tpl;
355 
356  $this->lng->loadLanguageModule("dateplaner");
357 
358  include_once 'Modules/BookingManager/classes/class.ilBookingType.php';
359  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
360  include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
361  $type = new ilBookingType($a_type_id);
362  $schedule = new ilBookingSchedule($type->getScheduleId());
363  $object_ids = array();
364  foreach(ilBookingObject::getList($a_type_id) as $item)
365  {
366  $object_ids[] = $item['booking_object_id'];
367  }
368 
369  $tpl->setContent($this->renderList($schedule, $object_ids, $type->getTitle()));
370  }
371 
372  protected function renderList(ilBookingSchedule $schedule, array $object_ids, $title)
373  {
374  global $ilUser;
375 
376  // fix
377  if(!$schedule->getRaster())
378  {
379  $mytpl = new ilTemplate('tpl.booking_reservation_fix.html', true, true, 'Modules/BookingManager');
380 
381  $mytpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this));
382  $mytpl->setVariable('TXT_TITLE', $this->lng->txt('book_reservation_title'));
383  $mytpl->setVariable('TXT_INFO', $this->lng->txt('book_reservation_fix_info'));
384  $mytpl->setVariable('TXT_OBJECT', $title);
385  $mytpl->setVariable('TXT_CMD_BOOK', $this->lng->txt('book_confirm_booking'));
386  $mytpl->setVariable('TXT_CMD_CANCEL', $this->lng->txt('cancel'));
387 
388  include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
389 
390  $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
391 
392  $morning_aggr = $user_settings->getDayStart();
393  $evening_aggr = $user_settings->getDayEnd();
394  $hours = array();
395  for($i = $morning_aggr;$i <= $evening_aggr;$i++)
396  {
397  switch($user_settings->getTimeFormat())
398  {
400  if ($morning_aggr > 0 && $i == $morning_aggr)
401  {
402  $hours[$i] = sprintf('%02d:00',0)."-";
403  }
404  $hours[$i].= sprintf('%02d:00',$i);
405  if ($evening_aggr < 23 && $i == $evening_aggr)
406  {
407  $hours[$i].= "-".sprintf('%02d:00',23);
408  }
409  break;
410 
412  if ($morning_aggr > 0 && $i == $morning_aggr)
413  {
414  $hours[$i] = date('h a',mktime(0,0,0,1,1,2000))."-";
415  }
416  $hours[$i].= date('h a',mktime($i,0,0,1,1,2000));
417  if ($evening_aggr < 23 && $i == $evening_aggr)
418  {
419  $hours[$i].= "-".date('h a',mktime(23,0,0,1,1,2000));
420  }
421  break;
422  }
423  }
424 
425  if(isset($_GET['seed']))
426  {
427  $find_first_open = false;
428  $seed = new ilDate($_GET['seed'], IL_CAL_DATE);
429  }
430  else
431  {
432  $find_first_open = true;
433  $seed = new ilDate(time(), IL_CAL_UNIX);
434  }
435 
436  include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
437  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
438  $week_start = $user_settings->getWeekStart();
439 
440  if(!$find_first_open)
441  {
442  $dates = array();
443  $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
444  }
445  else
446  {
447  $dates = array();
448  $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
449 
450  // find first open slot
451  if(!$has_open_slot)
452  {
453  // 1 year is limit for search
454  $limit = clone($seed);
455  $limit->increment(ilDate::YEAR, 1);
456  $limit = $limit->get(IL_CAL_UNIX);
457 
458  while(!$has_open_slot && $seed->get(IL_CAL_UNIX) < $limit)
459  {
460  $seed->increment(ilDate::WEEK, 1);
461 
462  $dates = array();
463  $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
464  }
465  }
466  }
467 
468  include_once 'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php';
469  $navigation = new ilCalendarHeaderNavigationGUI($this,$seed,ilDateTime::WEEK,'book');
470  $mytpl->setVariable('NAVIGATION', $navigation->getHTML());
471 
472  foreach(ilCalendarUtil::_buildWeekDayList($seed,$week_start)->get() as $date)
473  {
474  $date_info = $date->get(IL_CAL_FKT_GETDATE,'','UTC');
475 
476  $mytpl->setCurrentBlock('weekdays');
477  $mytpl->setVariable('TXT_WEEKDAY', ilCalendarUtil:: _numericDayToString($date_info['wday']));
478  $mytpl->setVariable('TXT_DATE', $date_info['mday'].' '.ilCalendarUtil:: _numericMonthToString($date_info['mon']));
479  $mytpl->parseCurrentBlock();
480  }
481 
482  include_once 'Services/Calendar/classes/class.ilCalendarAppointmentColors.php';
483  include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
484  $color = array();
486  for($loop = 0; $loop < 7; $loop++)
487  {
488  $col = $all[$loop];
490  $color[$loop+1] = 'border-bottom: 1px solid '.$col.'; background-color: '.$col.'; color: '.$fnt;
491  }
492 
493  $counter = 0;
494  foreach($dates as $hour => $days)
495  {
496  $caption = $days;
497  $caption = array_shift($caption);
498 
499  for($loop = 1; $loop < 8; $loop++)
500  {
501  if(!isset($days[$loop]))
502  {
503  $mytpl->setCurrentBlock('dates');
504  $mytpl->setVariable('DUMMY', '&nbsp;');
505  $mytpl->parseCurrentBlock();
506  }
507  else
508  {
509  if(isset($days[$loop]['captions']))
510  {
511  foreach($days[$loop]['captions'] as $slot_id => $slot_caption)
512  {
513  $mytpl->setCurrentBlock('choice');
514  $mytpl->setVariable('TXT_DATE', $slot_caption);
515  $mytpl->setVariable('VALUE_DATE', $slot_id);
516  $mytpl->setVariable('DATE_COLOR', $color[$loop]);
517  $mytpl->parseCurrentBlock();
518  }
519 
520  $mytpl->setCurrentBlock('dates');
521  $mytpl->setVariable('DUMMY', '');
522  $mytpl->parseCurrentBlock();
523  }
524  else if(isset($days[$loop]['in_slot']))
525  {
526  $mytpl->setCurrentBlock('dates');
527  $mytpl->setVariable('DATE_COLOR', $color[$loop]);
528  $mytpl->parseCurrentBlock();
529  }
530  else
531  {
532  $mytpl->setCurrentBlock('dates');
533  $mytpl->setVariable('DUMMY', '&nbsp;');
534  $mytpl->parseCurrentBlock();
535  }
536  }
537  }
538 
539  $mytpl->setCurrentBlock('slots');
540  $mytpl->setVariable('TXT_HOUR', $caption);
541  if($counter%2)
542  {
543  $mytpl->setVariable('CSS_ROW', 'tblrow1');
544  }
545  else
546  {
547  $mytpl->setVariable('CSS_ROW', 'tblrow2');
548  }
549  $mytpl->parseCurrentBlock();
550 
551  $counter++;
552  }
553  }
554  // flexible
555  else
556  {
557  // :TODO: inactive for now
558  }
559 
560  return $mytpl->get();
561  }
562 
563  protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates)
564  {
565  $map = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su');
566  $definition = $schedule->getDefinition();
567 
568  $has_open_slot = false;
569  foreach(ilCalendarUtil::_buildWeekDayList($seed,$week_start)->get() as $date)
570  {
571  $date_info = $date->get(IL_CAL_FKT_GETDATE,'','UTC');
572 
573  $slots = array();
574  if(isset($definition[$map[$date_info['isoday']-1]]))
575  {
576  $slots = array();
577  foreach($definition[$map[$date_info['isoday']-1]] as $slot)
578  {
579  $slot = explode('-', $slot);
580  $slots[] = array('from'=>str_replace(':', '', $slot[0]),
581  'to'=>str_replace(':', '', $slot[1]));
582  }
583  }
584 
585  $last = array_pop(array_keys($hours));
586  $slot_captions = array();
587  foreach($hours as $hour => $period)
588  {
589  $dates[$hour][0] = $period;
590 
591  $column = $date_info['isoday'];
592  if(!$week_start)
593  {
594  if($column < 7)
595  {
596  $column++;
597  }
598  else
599  {
600  $column = 1;
601  }
602  }
603 
604  if(sizeof($slots))
605  {
606  $in = false;
607  foreach($slots as $slot)
608  {
609  $slot_from = mktime(substr($slot['from'], 0, 2), substr($slot['from'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]);
610  $slot_to = mktime(substr($slot['to'], 0, 2), substr($slot['to'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]);
611 
612  // check deadline
613  if($slot_from < (time()+$schedule->getDeadline()*60*60) || !ilBookingReservation::getAvailableObject($object_ids, $slot_from, $slot_to))
614  {
615  continue;
616  }
617 
618  // is slot active in current hour?
619  if((int)$slot['from'] < (int)$hour."59" && (int)$slot['to'] > (int)$hour."00")
620  {
621  $from = ilDatePresentation::formatDate(new ilDateTime($slot_from, IL_CAL_UNIX));
622  $from = array_pop(explode(' ', $from));
624  $to = array_pop(explode(' ', $to));
625 
626  // show caption (first hour) of slot
627  $id = $slot_from.'_'.$slot_to;
628  if(!in_array($id, $slot_captions))
629  {
630  $dates[$hour][$column]['captions'][$id] = $from.'-'.$to;
631  $slot_captions[] = $id;
632  }
633 
634  $in = true;
635  }
636  }
637  // (any) active slot
638  if($in)
639  {
640  $has_open_slot = true;
641  $dates[$hour][$column]['in_slot'] = $in;
642  }
643  }
644  }
645  }
646 
647  return $has_open_slot;
648  }
649 
654  {
655  global $ilUser;
656 
657  if(!isset($_POST['date']))
658  {
659  ilUtil::sendFailure($this->lng->txt('select_one'));
660  return $this->bookObject();
661  }
662 
663  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
664  $fromto = explode('_', $_POST['date']);
665 
666  if(isset($_GET['object_id']))
667  {
668  $object_id = (int)$_GET['object_id'];
669  }
670  // choose object of type
671  else
672  {
673  include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
674  $ids = array();
675  foreach(ilBookingObject::getList((int)$_GET['type_id']) as $item)
676  {
677  $ids[] = $item['booking_object_id'];
678  }
679  $object_id = ilBookingReservation::getAvailableObject($ids, $fromto[0], $fromto[1]);
680  }
681 
682  if($object_id)
683  {
684  $reservation = new ilBookingReservation();
685  $reservation->setObjectId($object_id);
686  $reservation->setUserId($ilUser->getID());
687  $reservation->setFrom($fromto[0]);
688  $reservation->setTo($fromto[1]);
689  $reservation->save();
690 
691  $this->lng->loadLanguageModule('dateplaner');
692  include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
693  include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
694  $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK,$ilUser->getId(),$this->lng->txt('cal_ch_personal_book'),true);
695 
696  include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
697  $object = new ilBookingObject($object_id);
698 
699  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
700  $entry = new ilCalendarEntry;
701  $entry->setStart(new ilDateTime($fromto[0], IL_CAL_UNIX));
702  $entry->setEnd(new ilDateTime($fromto[1], IL_CAL_UNIX));
703  $entry->setTitle($this->lng->txt('book_cal_entry').' '.$object->getTitle());
704  $entry->setContextId($reservation->getId());
705  $entry->save();
706 
707  include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
708  $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
709  $assignment->addAssignment($def_cat->getCategoryId());
710 
711  ilUtil::sendSuccess($this->lng->txt('book_reservation_confirmed'), true);
712  $this->ctrl->redirect($this, 'render');
713  }
714  else
715  {
716  ilUtil::sendFailure($this->lng->txt('book_reservation_failed'), true);
717  $this->ctrl->redirect($this, 'book');
718  }
719  }
720 
724  function logObject()
725  {
726  global $tpl;
727 
728  $this->tabs_gui->setTabActive('log');
729 
730  include_once 'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
731  $table = new ilBookingReservationsTableGUI($this, 'log', $this->ref_id);
732  $tpl->setContent($table->getHTML());
733  }
734 
739  {
740  global $ilAccess;
741 
742  $this->tabs_gui->setTabActive('log');
743 
744  if(!$_POST['reservation_id'])
745  {
746  ilUtil::sendFailure($this->lng->txt('select_one'));
747  return $this->logObject();
748  }
749 
750  if ($ilAccess->checkAccess('write', '', $this->object->getRefId()))
751  {
752  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
753  ilBookingReservation::changeStatus($_POST['reservation_id'], (int)$_POST['tstatus']);
754  }
755 
756  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
757  return $this->ctrl->redirect($this, 'log');
758  }
759 
764  {
765  include_once 'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
766  $table = new ilBookingReservationsTableGUI($this, 'log', $this->ref_id);
767  $table->resetOffset();
768  $table->writeFilterToSession();
769  $this->logObject();
770  }
771 
776  {
777  include_once 'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
778  $table = new ilBookingReservationsTableGUI($this, 'log', $this->ref_id);
779  $table->resetOffset();
780  $table->resetFilter();
781  $this->logObject();
782  }
783 
784  function _goto($a_target)
785  {
786  global $ilAccess, $ilErr, $lng;
787 
788  if ($ilAccess->checkAccess("read", "", $a_target))
789  {
790  $_GET["cmd"] = "render";
791  $_GET["ref_id"] = $a_target;
792  include("repository.php");
793  exit;
794  }
795  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
796  {
797  $_GET["cmd"] = "frameset";
798  $_GET["target"] = "";
799  $_GET["ref_id"] = ROOT_FOLDER_ID;
800  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
802  include("repository.php");
803  exit;
804  }
805 
806  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
807  }
808 
814  function infoScreenObject()
815  {
816  $this->ctrl->setCmd("showSummary");
817  $this->ctrl->setCmdClass("ilinfoscreengui");
818  $this->infoScreen();
819  }
820 
821  function infoScreen()
822  {
823  global $ilAccess, $ilCtrl;
824 
825  $this->tabs_gui->setTabActive('info');
826 
827  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
828  {
829  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
830  }
831 
832  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
833  $info = new ilInfoScreenGUI($this);
834 
835  $info->enablePrivateNotes();
836 
837  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
838  {
839  $info->enableNews();
840  }
841 
842  // no news editing for files, just notifications
843  $info->enableNewsEditing(false);
844  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
845  {
846  $news_set = new ilSetting("news");
847  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
848 
849  if ($enable_internal_rss)
850  {
851  $info->setBlockProperty("news", "settings", true);
852  $info->setBlockProperty("news", "public_notifications_option", true);
853  }
854  }
855 
856  // forward the command
857  if ($ilCtrl->getNextClass() == "ilinfoscreengui")
858  {
859  $ilCtrl->forwardCommand($info);
860  }
861  else
862  {
863  return $ilCtrl->getHTML($info);
864  }
865  }
866 
867  function rsvCancelObject()
868  {
869  global $ilAccess, $ilUser;
870 
871  $this->tabs_gui->setTabActive('log');
872 
873  $id = (int)$_GET['reservation_id'];
874  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
875  $obj = new ilBookingReservation($id);
876 
877  if (!$ilAccess->checkAccess("write", "", $this->ref_id) && $obj->getUserId() != $ilUser->getId())
878  {
879  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
880  $this->ctrl->redirect($this, 'log');
881  }
882 
884  $obj->update();
885 
886  // remove user calendar entry
887  include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
888  include_once 'Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
889  $apps = ilConsultationHourAppointments::getAppointmentIds($obj->getUserId(), $obj->getId(), NULL, ilCalendarCategory::TYPE_BOOK);
890  if($apps)
891  {
892  include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
893  $entry = new ilCalendarEntry($apps[0]);
894  $entry->delete();
895  }
896 
897  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
898  $this->logObject();
899  }
900 
901  function rsvUncancelObject()
902  {
903  global $ilAccess;
904 
905  $this->tabs_gui->setTabActive('log');
906 
907  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
908  {
909  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
910  $this->ctrl->redirect($this, 'log');
911  }
912 
913  $id = (int)$_GET['reservation_id'];
914  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
915  $obj = new ilBookingReservation($id);
916  $obj->setStatus(NULL);
917  $obj->update();
918 
919  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
920  $this->logObject();
921  }
922 
923  function rsvInUseObject()
924  {
925  global $ilAccess;
926 
927  $this->tabs_gui->setTabActive('log');
928 
929  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
930  {
931  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
932  $this->ctrl->redirect($this, 'log');
933  }
934 
935  $id = (int)$_GET['reservation_id'];
936  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
937  $obj = new ilBookingReservation($id);
938  $obj->setStatus(ilBookingReservation::STATUS_IN_USE);
939  $obj->update();
940 
941  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
942  $this->logObject();
943  }
944 
945  function rsvNotInUseObject()
946  {
947  global $ilAccess;
948 
949  $this->tabs_gui->setTabActive('log');
950 
951  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
952  {
953  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
954  $this->ctrl->redirect($this, 'log');
955  }
956 
957  $id = (int)$_GET['reservation_id'];
958  include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
959  $obj = new ilBookingReservation($id);
960  $obj->setStatus(NULL);
961  $obj->update();
962 
963  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
964  $this->logObject();
965  }
966 
967  function showProfileObject()
968  {
969  global $tpl;
970 
971  $this->tabs_gui->clearTargets();
972  $this->tabs_gui->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'log'));
973 
974  $user_id = (int)$_GET['user_id'];
975 
976  include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
977  $profile = new ilPublicUserProfileGUI($user_id);
978  $tpl->setContent($profile->getHTML());
979  }
980 }
981 
982 ?>