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