4 require_once 
"./Services/Object/classes/class.ilObjectGUI.php";
 
   23         function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = 
true)
 
   26                 $this->
ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
 
   27                 $this->lng->loadLanguageModule(
"book");
 
   35                 global 
$tpl, $ilTabs, $ilNavigationHistory;
 
   37                 $next_class = $this->ctrl->getNextClass($this);
 
   38                 $cmd = $this->ctrl->getCmd();
 
   40                 if(!$next_class && 
$cmd == 
'render')
 
   42                         $this->ctrl->setCmdClass(
'ilBookingObjectGUI');
 
   43                         $next_class = $this->ctrl->getNextClass($this);
 
   46                 if(substr(
$cmd, 0, 4) == 
'book')
 
   51                 $ilNavigationHistory->addItem($this->ref_id,
 
   52                                 "./goto.php?target=book_".$this->ref_id, 
"book");
 
   58                         case 'ilpermissiongui':
 
   59                                 $this->tabs_gui->setTabActive(
'perm_settings');
 
   60                                 include_once(
"Services/AccessControl/classes/class.ilPermissionGUI.php");
 
   62                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
 
   65                         case 'ilbookingobjectgui':
 
   66                                 $this->tabs_gui->setTabActive(
'render');
 
   67                                 include_once(
"Modules/BookingManager/classes/class.ilBookingObjectGUI.php");
 
   69                                 $ret =& $this->ctrl->forwardCommand($object_gui);
 
   72                         case 'ilbookingschedulegui':
 
   73                                 $this->tabs_gui->setTabActive(
'schedules');
 
   74                                 include_once(
"Modules/BookingManager/classes/class.ilBookingScheduleGUI.php");
 
   76                                 $ret =& $this->ctrl->forwardCommand($schedule_gui);
 
   79                         case 'ilpublicuserprofilegui':
 
   80                                 $ilTabs->clearTargets();
 
   81                                 include_once(
"Services/User/classes/class.ilPublicUserProfileGUI.php");
 
   83                                 $profile->setBackUrl($this->ctrl->getLinkTarget($this, 
'log'));
 
   84                                 $ret = $this->ctrl->forwardCommand($profile);
 
   85                                 $tpl->setContent(
$ret);
 
   88                         case 'ilinfoscreengui':
 
   92                         case "ilcommonactiondispatchergui":
 
   93                                 include_once(
"Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
 
   95                                 $this->ctrl->forwardCommand($gui);
 
   98                         case "ilobjectcopygui":
 
   99                                 include_once 
"./Services/Object/classes/class.ilObjectCopyGUI.php";
 
  101                                 $cp->setType(
"book");
 
  102                                 $this->ctrl->forwardCommand($cp);
 
  106                                 $cmd = $this->ctrl->getCmd();
 
  119                 unset($forms[self::CFORM_IMPORT]);              
 
  126                 $a_new_object->setOffline(
true);
 
  131                 $this->ctrl->setParameter($this, 
"ref_id", $a_new_object->
getRefId());
 
  132                 $this->ctrl->redirect($this, 
"edit");
 
  138                 include_once 
"Modules/BookingManager/classes/class.ilBookingSchedule.php";
 
  158                 include_once 
"Modules/BookingManager/classes/class.ilBookingObject.php";
 
  161                         $type->setDisabled(
true);
 
  165                 $fixed->
setInfo($this->lng->txt(
"book_schedule_type_fixed_info"));
 
  166                 $type->addOption($fixed);
 
  169                 $none->
setInfo($this->lng->txt(
"book_schedule_type_none_info"));
 
  170                 $type->addOption($none);
 
  173                 $public->
setInfo($this->lng->txt(
"book_public_log_info"));
 
  179                 $a_values[
"online"] = !$this->
object->isOffline();
 
  180                 $a_values[
"public"] = $this->
object->hasPublicLog();
 
  181                 $a_values[
"stype"] = $this->
object->getScheduleType();
 
  186                 $this->
object->setOffline(!$a_form->
getInput(
'online'));
 
  187                 $this->
object->setPublicLog($a_form->
getInput(
'public'));
 
  188                 $this->
object->setScheduleType($a_form->
getInput(
'stype'));
 
  196                 global $ilAccess, $ilHelp;
 
  198                 if (in_array($this->ctrl->getCmd(), array(
"create", 
"save")) && !$this->ctrl->getNextClass())
 
  203                 $ilHelp->setScreenIdComponent(
"book");
 
  205                 $this->tabs_gui->addTab(
"render",
 
  206                                 $this->lng->txt(
"book_booking_types"),
 
  207                                 $this->ctrl->getLinkTarget($this, 
"render"));
 
  209                 $this->tabs_gui->addTab(
"info",
 
  210                                 $this->lng->txt(
"info_short"),
 
  211                                 $this->ctrl->getLinkTarget($this, 
"infoscreen"));
 
  213                 if ($ilAccess->checkAccess(
'write', 
'', $this->object->getRefId()) ||
 
  214                         $this->object->hasPublicLog())
 
  216                         $this->tabs_gui->addTab(
"log",
 
  217                                 $this->lng->txt(
"book_log"),
 
  218                                 $this->ctrl->getLinkTarget($this, 
"log"));
 
  221                 if ($ilAccess->checkAccess(
'write', 
'', $this->object->getRefId()))
 
  225                                 $this->tabs_gui->addTab(
"schedules",
 
  226                                         $this->lng->txt(
"book_schedules"),
 
  227                                         $this->ctrl->getLinkTargetByClass(
"ilbookingschedulegui", 
"render"));
 
  230                         $this->tabs_gui->addTab(
"settings",
 
  231                                 $this->lng->txt(
"settings"),
 
  232                                 $this->ctrl->getLinkTarget($this, 
"edit"));
 
  235                 if($ilAccess->checkAccess(
'edit_permission', 
'', $this->object->getRefId()))
 
  237                         $this->tabs_gui->addTab(
"perm_settings",
 
  238                                 $this->lng->txt(
"perm_settings"),
 
  239                                 $this->ctrl->getLinkTargetByClass(
"ilpermissiongui", 
"perm"));
 
  250                 $this->tabs_gui->clearTargets();
 
  251                 $this->tabs_gui->setBackTarget($this->lng->txt(
'book_back_to_list'), $this->ctrl->getLinkTarget($this, 
'render'));
 
  253                 include_once 
'Modules/BookingManager/classes/class.ilBookingObject.php';
 
  256                 $this->lng->loadLanguageModule(
"dateplaner");
 
  257                 $this->ctrl->setParameter($this, 
'object_id', $obj->getId());
 
  261                         include_once 
'Modules/BookingManager/classes/class.ilBookingSchedule.php';              
 
  264                         $tpl->setContent($this->
renderSlots($schedule, array($obj->getId()), $obj->getTitle()));
 
  268                         include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
 
  270                         $cgui->setHeaderText($this->lng->txt(
"book_confirm_booking_no_schedule"));
 
  272                         $cgui->setFormAction($this->ctrl->getFormAction($this));
 
  273                         $cgui->setCancel($this->lng->txt(
"cancel"), 
"render");
 
  274                         $cgui->setConfirm($this->lng->txt(
"confirm"), 
"confirmedBooking");
 
  276                         $cgui->addItem(
"object_id", $obj->getId(), $obj->getTitle());           
 
  278                         $tpl->setContent($cgui->getHTML());
 
  289                         $mytpl = 
new ilTemplate(
'tpl.booking_reservation_fix.html', 
true, 
true, 
'Modules/BookingManager');
 
  291                         $mytpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this));
 
  292                         $mytpl->setVariable(
'TXT_TITLE', $this->lng->txt(
'book_reservation_title'));
 
  293                         $mytpl->setVariable(
'TXT_INFO', $this->lng->txt(
'book_reservation_fix_info'));
 
  294                         $mytpl->setVariable(
'TXT_OBJECT', 
$title);
 
  295                         $mytpl->setVariable(
'TXT_CMD_BOOK', $this->lng->txt(
'book_confirm_booking'));
 
  296                         $mytpl->setVariable(
'TXT_CMD_CANCEL', $this->lng->txt(
'cancel'));
 
  298                         include_once 
'Services/Calendar/classes/class.ilCalendarUserSettings.php';
 
  302                         $morning_aggr = $user_settings->getDayStart();
 
  303                         $evening_aggr = $user_settings->getDayEnd();
 
  305                         for($i = $morning_aggr;$i <= $evening_aggr;$i++)
 
  307                                 switch($user_settings->getTimeFormat())
 
  310                                                 if ($morning_aggr > 0 && $i == $morning_aggr)
 
  312                                                         $hours[$i] = sprintf(
'%02d:00',0).
"-";
 
  314                                                 $hours[$i].= sprintf(
'%02d:00',$i);
 
  315                                                 if ($evening_aggr < 23 && $i == $evening_aggr)
 
  317                                                         $hours[$i].= 
"-".sprintf(
'%02d:00',23);
 
  322                                                 if ($morning_aggr > 0 && $i == $morning_aggr)
 
  324                                                         $hours[$i] = date(
'h a',mktime(0,0,0,1,1,2000)).
"-";
 
  326                                                 $hours[$i].= date(
'h a',mktime($i,0,0,1,1,2000));
 
  327                                                 if ($evening_aggr < 23 && $i == $evening_aggr)
 
  329                                                         $hours[$i].= 
"-".date(
'h a',mktime(23,0,0,1,1,2000));
 
  335                         if(isset(
$_GET[
'seed']))
 
  337                                 $find_first_open = 
false;
 
  342                                 $find_first_open = 
true;
 
  346                         include_once 
'Services/Calendar/classes/class.ilCalendarUtil.php';
 
  347                         include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';                   
 
  348                         $week_start = $user_settings->getWeekStart();
 
  350                         if(!$find_first_open)
 
  358                                 $has_open_slot = $this->
buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
 
  364                                         $limit = clone($seed);
 
  368                                         while(!$has_open_slot && $seed->get(
IL_CAL_UNIX) < $limit)
 
  373                                                 $has_open_slot = $this->
buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
 
  378                         include_once 
'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php';
 
  380                         $mytpl->setVariable(
'NAVIGATION', $navigation->getHTML());
 
  386                                 $mytpl->setCurrentBlock(
'weekdays');
 
  389                                 $mytpl->parseCurrentBlock();
 
  392                         include_once 
'Services/Calendar/classes/class.ilCalendarAppointmentColors.php';
 
  393                         include_once 
'Services/Calendar/classes/class.ilCalendarUtil.php';
 
  396                         for($loop = 0; $loop < 7; $loop++)
 
  400                                 $color[$loop+1] = 
'border-bottom: 1px solid '.$col.
'; background-color: '.$col.
'; color: '.$fnt;
 
  404                         foreach($dates as $hour => $days)
 
  407                                 $caption = array_shift($caption);
 
  409                                 for($loop = 1; $loop < 8; $loop++)
 
  411                                         if(!isset($days[$loop]))
 
  413                                                 $mytpl->setCurrentBlock(
'dates');
 
  414                                                 $mytpl->setVariable(
'DUMMY', 
' ');
 
  415                                                 $mytpl->parseCurrentBlock();
 
  419                                                 if(isset($days[$loop][
'captions']))
 
  421                                                         foreach($days[$loop][
'captions'] as $slot_id => $slot_caption)
 
  423                                                                 $mytpl->setCurrentBlock(
'choice');
 
  424                                                                 $mytpl->setVariable(
'TXT_DATE', $slot_caption);
 
  425                                                                 $mytpl->setVariable(
'VALUE_DATE', $slot_id);
 
  426                                                                 $mytpl->setVariable(
'DATE_COLOR', $color[$loop]);
 
  427                                                                 $mytpl->parseCurrentBlock();
 
  430                                                         $mytpl->setCurrentBlock(
'dates');
 
  431                                                         $mytpl->setVariable(
'DUMMY', 
'');
 
  432                                                         $mytpl->parseCurrentBlock();
 
  434                                                 else if(isset($days[$loop][
'in_slot']))
 
  436                                                         $mytpl->setCurrentBlock(
'dates');
 
  437                                                         $mytpl->setVariable(
'DATE_COLOR', $color[$loop]);
 
  438                                                         $mytpl->parseCurrentBlock();
 
  442                                                         $mytpl->setCurrentBlock(
'dates');
 
  443                                                         $mytpl->setVariable(
'DUMMY', 
' ');
 
  444                                                         $mytpl->parseCurrentBlock();
 
  449                                 $mytpl->setCurrentBlock(
'slots');
 
  450                                 $mytpl->setVariable(
'TXT_HOUR', $caption);
 
  453                                         $mytpl->setVariable(
'CSS_ROW', 
'tblrow1');
 
  457                                         $mytpl->setVariable(
'CSS_ROW', 
'tblrow2');
 
  459                                 $mytpl->parseCurrentBlock();
 
  470                 return $mytpl->get();
 
  473         protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates)
 
  477                 include_once 
'Services/Calendar/classes/class.ilCalendarUserSettings.php';                      
 
  480                 $map = array(
'mo', 
'tu', 
'we', 
'th', 
'fr', 
'sa', 
'su');
 
  481                 $definition = $schedule->getDefinition();
 
  483                 $has_open_slot = 
false;
 
  489                         if(isset($definition[$map[$date_info[
'isoday']-1]]))
 
  492                                 foreach($definition[$map[$date_info[
'isoday']-1]] as $slot)
 
  494                                         $slot = explode(
'-', $slot);
 
  495                                         $slots[] = array(
'from'=>str_replace(
':', 
'', $slot[0]),
 
  496                                                 'to'=>str_replace(
':', 
'', $slot[1]));
 
  500                         $last = array_pop(array_keys($hours));
 
  501                         $slot_captions = array();
 
  502                         foreach($hours as $hour => $period)
 
  504                                 $dates[$hour][0] = $period;
 
  506                                 $period = explode(
"-", $period);
 
  511                                         if(stristr($period[0], 
"pm"))
 
  513                                                 $period[0] = (int)$period[0]+12;
 
  517                                                 $period[0] = (int)$period[0];
 
  523                                         if(
sizeof($period) == 2)
 
  525                                                 if(stristr($period[1], 
"pm"))
 
  527                                                         $period[1] = (int)$period[1]+12;
 
  531                                                         $period[1] = (int)$period[1];
 
  540                                 if(
sizeof($period) == 1)
 
  542                                         $period_from = (int)substr($period[0], 0, 2).
"00";
 
  543                                         $period_to = (int)substr($period[0], 0, 2).
"59";
 
  547                                         $period_from = (int)substr($period[0], 0, 2).
"00";
 
  548                                         $period_to = (int)substr($period[1], 0, 2).
"59";
 
  551                                 $column = $date_info[
'isoday'];
 
  567                                         foreach($slots as $slot)
 
  569                                                 $slot_from = mktime(substr($slot[
'from'], 0, 2), substr($slot[
'from'], 2, 2), 0, $date_info[
"mon"], $date_info[
"mday"], $date_info[
"year"]);
 
  570                                                 $slot_to = mktime(substr($slot[
'to'], 0, 2), substr($slot[
'to'], 2, 2), 0, $date_info[
"mon"], $date_info[
"mday"], $date_info[
"year"]);
 
  579                                                 if((
int)$slot[
'from'] < $period_to && (int)$slot[
'to'] > $period_from)
 
  582                                                         $from = array_pop(explode(
' ', $from));
 
  584                                                         $to = array_pop(explode(
' ', $to));
 
  587                                                         $id = $slot_from.
'_'.$slot_to;
 
  588                                                         if(!in_array($id, $slot_captions))
 
  590                                                                 $dates[$hour][$column][
'captions'][$id] = $from.
'-'.$to;
 
  591                                                                 $slot_captions[] = $id;
 
  600                                                 $has_open_slot = 
true;
 
  601                                                 $dates[$hour][$column][
'in_slot'] = 
$in;
 
  607                 return $has_open_slot;
 
  615                 include_once 
'Modules/BookingManager/classes/class.ilBookingObject.php';
 
  616                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';           
 
  624                                 $object_id = 
$_POST[
'object_id'];
 
  636                                                 $this->ctrl->redirect($this, 
'render');                                         
 
  643                         if(!isset(
$_POST[
'date']))
 
  650                         if(isset(
$_GET[
'object_id']))
 
  652                                 $object_id = (int)
$_GET[
'object_id'];
 
  655                                         foreach(
$_POST[
'date'] as $date)
 
  657                                                 $fromto = explode(
'_', $date);
 
  725                         include_once 
'Modules/BookingManager/classes/class.ilBookingObject.php';
 
  727                         $pfile = $obj->getPostFile();
 
  728                         $ptext = $obj->getPostText();
 
  729                         if(trim($ptext) || $pfile)
 
  731                                 $this->ctrl->setParameterByClass(
'ilbookingobjectgui', 
'object_id', $obj->getId());                             
 
  732                                 $this->ctrl->redirectByClass(
'ilbookingobjectgui', 
'displayPostInfo');
 
  736                                 $this->ctrl->redirect($this, 
'render');
 
  742                         $this->ctrl->redirect($this, 
'book');
 
  758                 if(!$ilAccess->checkAccess(
'read', 
'', $this->object->getRefId()))
 
  760                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
 
  763                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';
 
  765                 $reservation->setObjectId($a_object_id);
 
  766                 $reservation->setUserId($ilUser->getID());
 
  767                 $reservation->setFrom($a_from);
 
  768                 $reservation->setTo($a_to);
 
  769                 $reservation->save();
 
  773                         $this->lng->loadLanguageModule(
'dateplaner');
 
  774                         include_once 
'Services/Calendar/classes/class.ilCalendarUtil.php';
 
  775                         include_once 
'Services/Calendar/classes/class.ilCalendarCategory.php';
 
  778                         include_once 
'Modules/BookingManager/classes/class.ilBookingObject.php';
 
  781                         include_once 
'Services/Calendar/classes/class.ilCalendarEntry.php';
 
  785                         $entry->setTitle($this->lng->txt(
'book_cal_entry').
' '.
$object->getTitle());
 
  786                         $entry->setContextId($reservation->getId());
 
  789                         include_once 
'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
 
  802                 $this->tabs_gui->setTabActive(
'log');
 
  804                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
 
  807                 $tpl->setContent($table->getHTML());
 
  817                 $this->tabs_gui->setTabActive(
'log');
 
  819                 if(!
$_POST[
'reservation_id'])
 
  825                 if ($ilAccess->checkAccess(
'write', 
'', $this->object->getRefId()))
 
  827                         include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';
 
  832                 return $this->ctrl->redirect($this, 
'log');
 
  840                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
 
  843                 $table->resetOffset();
 
  844                 $table->writeFilterToSession();
 
  853                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservationsTableGUI.php';
 
  856                 $table->resetOffset();
 
  857                 $table->resetFilter();
 
  865                 if ($ilAccess->checkAccess(
"read", 
"", $a_target))
 
  869                 else if ($ilAccess->checkAccess(
"read", 
"", ROOT_FOLDER_ID))
 
  876                 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->FATAL);
 
  886                 $this->ctrl->setCmd(
"showSummary");
 
  887                 $this->ctrl->setCmdClass(
"ilinfoscreengui");
 
  895                 $this->tabs_gui->setTabActive(
'info');
 
  897                 if (!$ilAccess->checkAccess(
"visible", 
"", $this->ref_id))
 
  899                         $this->ilias->raiseError($this->lng->txt(
"msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
 
  902                 include_once(
"./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
 
  905                 $info->enablePrivateNotes();
 
  907                 if ($ilAccess->checkAccess(
"read", 
"", 
$_GET[
"ref_id"]))
 
  913                 $info->enableNewsEditing(
false);
 
  914                 if ($ilAccess->checkAccess(
"write", 
"", 
$_GET[
"ref_id"]))
 
  917                         $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
 
  919                         if ($enable_internal_rss)
 
  921                                 $info->setBlockProperty(
"news", 
"settings", 
true);
 
  922                                 $info->setBlockProperty(
"news", 
"public_notifications_option", 
true);
 
  927                 if ($ilCtrl->getNextClass() == 
"ilinfoscreengui")
 
  929                         $ilCtrl->forwardCommand($info);
 
  933                         return $ilCtrl->getHTML($info);
 
  941                 $this->tabs_gui->setTabActive(
'log');
 
  943                 $id = (int)
$_GET[
'reservation_id'];     
 
  944                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';
 
  947                 if (!$ilAccess->checkAccess(
"write", 
"", $this->ref_id) && $obj->getUserId() != $ilUser->getId())
 
  950                         $this->ctrl->redirect($this, 
'log');
 
  959                         $cal_entry_id = $obj->getCalendarEntry();               
 
  962                                 include_once 
'Services/Calendar/classes/class.ilCalendarEntry.php';
 
  976                 $this->tabs_gui->setTabActive(
'log');
 
  978                 if (!$ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
  981                         $this->ctrl->redirect($this, 
'log');
 
  984                 $id = (int)
$_GET[
'reservation_id'];
 
  985                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';
 
  987                 $obj->setStatus(NULL);
 
  998                 $this->tabs_gui->setTabActive(
'log');
 
 1000                 if (!$ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
 1003                         $this->ctrl->redirect($this, 
'log');
 
 1006                 $id = (int)
$_GET[
'reservation_id'];
 
 1007                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';
 
 1020                 $this->tabs_gui->setTabActive(
'log');
 
 1022                 if (!$ilAccess->checkAccess(
"write", 
"", $this->ref_id))
 
 1025                         $this->ctrl->redirect($this, 
'log');
 
 1028                 $id = (int)
$_GET[
'reservation_id'];
 
 1029                 include_once 
'Modules/BookingManager/classes/class.ilBookingReservation.php';
 
 1031                 $obj->setStatus(NULL);
 
 1042                 $this->tabs_gui->clearTargets();
 
 1044                 $user_id = (int)
$_GET[
'user_id'];
 
 1046                 include_once 
'Services/User/classes/class.ilPublicUserProfileGUI.php';
 
 1048                 $profile->setBackUrl($this->ctrl->getLinkTarget($this, 
'log'));
 
 1049                 $tpl->setContent($ilCtrl->getHTML($profile));
 
 1056                 if (is_object($this->
object))
 
 1058                         $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 
"render"), 
"", 
$_GET[
"ref_id"]);