/**
  * Constructor
  *
  * @access public
  * @param ilDate seed date
  * @param int type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH)
  * @param int user_id
  * 
  */
 public function __construct(ilDate $seed, $a_type, $a_user_id = 0)
 {
     global $ilUser, $ilDB;
     $this->db = $ilDB;
     $this->type = $a_type;
     $this->initPeriod($seed);
     if (!$a_user_id || $a_user_id == $ilUser->getId()) {
         $this->user = $ilUser;
     } else {
         $this->user = new ilObjUser($a_user_id);
     }
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
     $this->weekstart = $this->user_settings->getWeekStart();
     $this->timezone = $this->user->getTimeZone();
     // category / event filters
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     // portfolio does custom filter handling (booking group ids)
     if (ilCalendarCategories::_getInstance()->getMode() != ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
         // consultation hour calendar views do not mind calendar category visibility
         if (ilCalendarCategories::_getInstance()->getMode() != ilCalendarCategories::MODE_CONSULTATION) {
             // this is the "default" filter which handles currently hidden categories for the user
             include_once './Services/Calendar/classes/class.ilCalendarScheduleFilterHidden.php';
             $this->addFilter(new ilCalendarScheduleFilterHidden($this->user->getId()));
         } else {
             // handle booking visibility (target object, booked out)
             include_once './Services/Calendar/classes/class.ilCalendarScheduleFilterBookings.php';
             $this->addFilter(new ilCalendarScheduleFilterBookings($this->user->getId()));
         }
     }
 }
 public function __construct($a_title, $a_postvar)
 {
     global $lng, $tpl, $ilUser;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('dateplaner');
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $tpl->addJavascript("./Services/Calendar/js/recurrence_input.js");
     parent::__construct($a_title, $a_postvar);
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * @return
  */
 public function __construct(ilDate $seed, $a_par_obj)
 {
     global $ilUser, $lng;
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $this->tpl = new ilTemplate('tpl.minical.html', true, true, 'Services/Calendar');
     $this->lng = $lng;
     $this->lng->loadLanguageModule('dateplaner');
     $this->seed = $seed;
     $this->setParentObject($a_par_obj);
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * 
  */
 public function __construct()
 {
     global $ilUser, $tpl, $lng, $ilCtrl;
     $this->tpl = $tpl;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('dateplaner');
     $this->lng->loadLanguageModule('jscalendar');
     $this->ctrl = $ilCtrl;
     $this->user = $ilUser;
     $this->settings = ilCalendarSettings::_getInstance();
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
 }
Пример #5
0
 /**
  * Constructor
  *
  * @access public
  * @param
  * 
  */
 public function __construct(ilDate $seed_date)
 {
     global $ilCtrl, $lng, $ilUser, $ilTabs, $tpl;
     $this->seed = $seed_date;
     $this->tpl = $tpl;
     $this->lng = $lng;
     $this->ctrl = $ilCtrl;
     $this->tabs_gui = $ilTabs;
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $this->app_colors = new ilCalendarAppointmentColors($ilUser->getId());
     $this->timezone = $ilUser->getTimeZone();
 }
 /**
  * Constructor.
  *
  * @param                   ilDate seed date
  * @param                   int    type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH)
  * @param                   int    user_id
  * @param ilRoomSharingRoom $room
  */
 public function __construct(ilDate $seed, $a_type, $a_user_id = 0, ilRoomSharingRoom $room)
 {
     global $ilUser, $ilDB;
     $this->room_obj = $room;
     $this->db = $ilDB;
     $this->type = $a_type;
     $this->initPeriod($seed);
     if (!$a_user_id || $a_user_id == $ilUser->getId()) {
         $this->user = $ilUser;
     } else {
         $this->user = new ilObjUser($a_user_id);
     }
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
     $this->weekstart = $this->user_settings->getWeekStart();
     $this->timezone = $this->user->getTimeZone();
     $this->ilRoomSharingDatabase = new ilRoomsharingDatabase($room->getPoolId());
 }
 /**
  * Constructor
  *
  * @access public
  * @param ilDate seed date
  * @param int type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH)
  * @param int user_id
  * 
  */
 public function __construct(ilDate $seed, $a_type, $a_user_id = 0, $filter_bookings = false)
 {
     global $ilUser, $ilDB;
     $this->db = $ilDB;
     $this->type = $a_type;
     $this->initPeriod($seed);
     if (!$a_user_id || $a_user_id == $ilUser->getId()) {
         $this->user = $ilUser;
     } else {
         $this->user = new ilObjUser($a_user_id);
     }
     $this->filter_bookings = $filter_bookings;
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
     $this->weekstart = $this->user_settings->getWeekStart();
     $this->timezone = $this->user->getTimeZone();
     $this->hidden_cat = ilCalendarHidden::_getInstanceByUserId($this->user->getId());
 }
Пример #8
0
 /**
  * Constructor
  *
  * @param	boolean		skip initialisation (is called by derived PDCalendarBlockGUI class)
  */
 function ilCalendarBlockGUI($a_skip_init = false)
 {
     global $ilCtrl, $lng, $ilUser, $tpl, $ilHelp;
     parent::ilBlockGUI();
     $this->ctrl = $ilCtrl;
     $lng->loadLanguageModule("dateplaner");
     $ilHelp->addHelpSection("cal_block");
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $ilCtrl->saveParameter($this, 'bkid');
     if (!$a_skip_init) {
         $this->initCategories();
         $this->setBlockId($ilCtrl->getContextObjId());
     }
     $this->setLimit(5);
     // @todo: needed?
     // alex: original detail level 1 did not work anymore
     $this->setAvailableDetailLevels(1);
     $this->setEnableNumInfo(false);
     if (!isset($_GET["bkid"])) {
         $title = $lng->txt("calendar");
     } else {
         $title = $lng->txt("cal_consultation_hours_for") . " " . ilObjUser::_lookupFullname($_GET["bkid"]);
     }
     $this->setTitle($title);
     //$this->setData($data);
     $this->allow_moving = false;
     //$this->handleView();
     include_once 'Services/Calendar/classes/class.ilDate.php';
     include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
     $seed_str = "";
     if ((!isset($_GET["seed"]) || $_GET["seed"] == "") && isset($_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"])) {
         $seed_str = $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"];
     } else {
         if (isset($_GET["seed"])) {
             $seed_str = $_GET["seed"];
         }
     }
     if (isset($_GET["seed"]) && $_GET["seed"] != "") {
         $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"] = $_GET["seed"];
     }
     if ($seed_str == "") {
         $this->seed = new ilDate(time(), IL_CAL_UNIX);
         // @todo: check this
     } else {
         $this->seed = new ilDate($seed_str, IL_CAL_DATE);
         // @todo: check this
     }
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $tpl->addCSS("./Services/Calendar/css/calendar.css");
     // @todo: this must work differently...
     $tpl->addCSS("./Services/Calendar/templates/default/delos.css");
     $mode = $ilUser->getPref("il_pd_cal_mode");
     $this->display_mode = $mode ? $mode : "mmon";
 }
Пример #9
0
 public function __construct($a_calendar_ids = array())
 {
     $this->calendars = $a_calendar_ids;
     $this->writer = new ilICalWriter();
     $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($GLOBALS['ilUser']->getId());
 }
 /**
  * Save general settings
  */
 public function saveGeneralSettings()
 {
     global $tpl, $lng, $ilCtrl, $ilUser;
     $this->initGeneralSettingsForm();
     if ($this->form->checkInput()) {
         if ($this->workWithUserSetting("skin_style")) {
             //set user skin and style
             if ($_POST["skin_style"] != "") {
                 $sknst = explode(":", $_POST["skin_style"]);
                 if ($ilUser->getPref("style") != $sknst[1] || $ilUser->getPref("skin") != $sknst[0]) {
                     $ilUser->setPref("skin", $sknst[0]);
                     $ilUser->setPref("style", $sknst[1]);
                 }
             }
         }
         // language
         if ($this->workWithUserSetting("language")) {
             $ilUser->setLanguage($_POST["language"]);
         }
         // hits per page
         if ($this->workWithUserSetting("hits_per_page")) {
             if ($_POST["hits_per_page"] != "") {
                 $ilUser->setPref("hits_per_page", $_POST["hits_per_page"]);
             }
         }
         // set show users online
         if ($this->workWithUserSetting("show_users_online")) {
             $ilUser->setPref("show_users_online", $_POST["show_users_online"]);
         }
         // store last visited?
         global $ilNavigationHistory;
         $ilUser->setPref("store_last_visited", (int) $_POST["store_last_visited"]);
         if ((int) $_POST["store_last_visited"] > 0) {
             $ilNavigationHistory->deleteDBEntries();
             if ((int) $_POST["store_last_visited"] == 2) {
                 $ilNavigationHistory->deleteSessionEntries();
             }
         }
         // set hide own online_status
         if ($this->workWithUserSetting("hide_own_online_status")) {
             if ($_POST["hide_own_online_status"] == 1) {
                 $ilUser->setPref("hide_own_online_status", "y");
             } else {
                 $ilUser->setPref("hide_own_online_status", "n");
             }
         }
         // set show users online
         if ($this->workWithUserSetting("screen_reader_optimization")) {
             $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]);
         }
         // session reminder
         include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
         if (ilSessionReminder::isGloballyActivated()) {
             $ilUser->setPref('session_reminder_enabled', (int) $this->form->getInput('session_reminder_enabled'));
             $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time'));
         }
         // starting point
         include_once "Services/User/classes/class.ilUserUtil.php";
         if (ilUserUtil::hasPersonalStartingPoint()) {
             ilUserUtil::setPersonalStartingPoint($this->form->getInput('usr_start'), $this->form->getInput('usr_start_ref_id'));
         }
         // selector for unicode characters
         global $ilSetting;
         if ($ilSetting->get('char_selector_availability') > 0) {
             require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
             $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_USER);
             $char_selector->getFormValues($this->form);
             $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability());
             $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition());
         }
         $ilUser->update();
         // calendar settings
         include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
         $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
         $user_settings->setTimeZone($this->form->getInput("timezone"));
         $user_settings->setDateFormat((int) $this->form->getInput("date_format"));
         $user_settings->setTimeFormat((int) $this->form->getInput("time_format"));
         $user_settings->save();
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->redirect($this, "showGeneralSettings");
     }
     $this->form->setValuesByPost();
     $this->showGeneralSettings(true);
 }
 protected function renderSlots(ilBookingSchedule $schedule, array $object_ids, $title)
 {
     global $ilUser;
     // fix
     if (!$schedule->getRaster()) {
         $mytpl = new ilTemplate('tpl.booking_reservation_fix.html', true, true, 'Modules/BookingManager');
         $mytpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this));
         $mytpl->setVariable('TXT_TITLE', $this->lng->txt('book_reservation_title'));
         $mytpl->setVariable('TXT_INFO', $this->lng->txt('book_reservation_fix_info'));
         $mytpl->setVariable('TXT_OBJECT', $title);
         $mytpl->setVariable('TXT_CMD_BOOK', $this->lng->txt('book_confirm_booking'));
         $mytpl->setVariable('TXT_CMD_CANCEL', $this->lng->txt('cancel'));
         include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
         $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
         $morning_aggr = $user_settings->getDayStart();
         $evening_aggr = $user_settings->getDayEnd();
         $hours = array();
         for ($i = $morning_aggr; $i <= $evening_aggr; $i++) {
             switch ($user_settings->getTimeFormat()) {
                 case ilCalendarSettings::TIME_FORMAT_24:
                     if ($morning_aggr > 0 && $i == $morning_aggr) {
                         $hours[$i] = sprintf('%02d:00', 0) . "-";
                     }
                     $hours[$i] .= sprintf('%02d:00', $i);
                     if ($evening_aggr < 23 && $i == $evening_aggr) {
                         $hours[$i] .= "-" . sprintf('%02d:00', 23);
                     }
                     break;
                 case ilCalendarSettings::TIME_FORMAT_12:
                     if ($morning_aggr > 0 && $i == $morning_aggr) {
                         $hours[$i] = date('h a', mktime(0, 0, 0, 1, 1, 2000)) . "-";
                     }
                     $hours[$i] .= date('h a', mktime($i, 0, 0, 1, 1, 2000));
                     if ($evening_aggr < 23 && $i == $evening_aggr) {
                         $hours[$i] .= "-" . date('h a', mktime(23, 0, 0, 1, 1, 2000));
                     }
                     break;
             }
         }
         if (isset($_GET['seed'])) {
             $find_first_open = false;
             $seed = new ilDate($_GET['seed'], IL_CAL_DATE);
         } else {
             $find_first_open = true;
             $seed = new ilDate(time(), IL_CAL_UNIX);
         }
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
         $week_start = $user_settings->getWeekStart();
         if (!$find_first_open) {
             $dates = array();
             $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
         } else {
             $dates = array();
             $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
             // find first open slot
             if (!$has_open_slot) {
                 // 1 year is limit for search
                 $limit = clone $seed;
                 $limit->increment(ilDate::YEAR, 1);
                 $limit = $limit->get(IL_CAL_UNIX);
                 while (!$has_open_slot && $seed->get(IL_CAL_UNIX) < $limit) {
                     $seed->increment(ilDate::WEEK, 1);
                     $dates = array();
                     $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates);
                 }
             }
         }
         include_once 'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php';
         $navigation = new ilCalendarHeaderNavigationGUI($this, $seed, ilDateTime::WEEK, 'book');
         $mytpl->setVariable('NAVIGATION', $navigation->getHTML());
         foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) {
             $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
             $mytpl->setCurrentBlock('weekdays');
             $mytpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($date_info['wday']));
             $mytpl->setVariable('TXT_DATE', $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon']));
             $mytpl->parseCurrentBlock();
         }
         include_once 'Services/Calendar/classes/class.ilCalendarAppointmentColors.php';
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         $color = array();
         $all = ilCalendarAppointmentColors::_getColorsByType('crs');
         for ($loop = 0; $loop < 7; $loop++) {
             $col = $all[$loop];
             $fnt = ilCalendarUtil::calculateFontColor($col);
             $color[$loop + 1] = 'border-bottom: 1px solid ' . $col . '; background-color: ' . $col . '; color: ' . $fnt;
         }
         $counter = 0;
         foreach ($dates as $hour => $days) {
             $caption = $days;
             $caption = array_shift($caption);
             for ($loop = 1; $loop < 8; $loop++) {
                 if (!isset($days[$loop])) {
                     $mytpl->setCurrentBlock('dates');
                     $mytpl->setVariable('DUMMY', '&nbsp;');
                     $mytpl->parseCurrentBlock();
                 } else {
                     if (isset($days[$loop]['captions'])) {
                         foreach ($days[$loop]['captions'] as $slot_id => $slot_caption) {
                             $mytpl->setCurrentBlock('choice');
                             $mytpl->setVariable('TXT_DATE', $slot_caption);
                             $mytpl->setVariable('VALUE_DATE', $slot_id);
                             $mytpl->setVariable('DATE_COLOR', $color[$loop]);
                             $mytpl->parseCurrentBlock();
                         }
                         $mytpl->setCurrentBlock('dates');
                         $mytpl->setVariable('DUMMY', '');
                         $mytpl->parseCurrentBlock();
                     } else {
                         if (isset($days[$loop]['in_slot'])) {
                             $mytpl->setCurrentBlock('dates');
                             $mytpl->setVariable('DATE_COLOR', $color[$loop]);
                             $mytpl->parseCurrentBlock();
                         } else {
                             $mytpl->setCurrentBlock('dates');
                             $mytpl->setVariable('DUMMY', '&nbsp;');
                             $mytpl->parseCurrentBlock();
                         }
                     }
                 }
             }
             $mytpl->setCurrentBlock('slots');
             $mytpl->setVariable('TXT_HOUR', $caption);
             if ($counter % 2) {
                 $mytpl->setVariable('CSS_ROW', 'tblrow1');
             } else {
                 $mytpl->setVariable('CSS_ROW', 'tblrow2');
             }
             $mytpl->parseCurrentBlock();
             $counter++;
         }
     } else {
         // :TODO: inactive for now
     }
     return $mytpl->get();
 }
 public function toICal($a_user_id)
 {
     $ical = 'RRULE:';
     $ical .= 'FREQ=' . $this->getFrequenceType();
     if ($this->getInterval()) {
         $ical .= ';INTERVAL=' . $this->getInterval();
     }
     if ($this->getFrequenceUntilCount()) {
         $ical .= ';COUNT=' . $this->getFrequenceUntilCount();
     } elseif ($this->getFrequenceUntilDate()) {
         $ical .= ';UNTIL=' . $this->getFrequenceUntilDate()->get(IL_CAL_FKT_DATE, 'Ymd');
     }
     if ($this->getBYMONTH()) {
         $ical .= ';BYMONTH=' . $this->getBYMONTH();
     }
     if ($this->getBYWEEKNO()) {
         $ical .= ';BYWEEKNO=' . $this->getBYWEEKNO();
     }
     if ($this->getBYYEARDAY()) {
         $ical .= ';BYYEARDAY=' . $this->getBYYEARDAY();
     }
     if ($this->getBYMONTHDAY()) {
         $ical .= ';BYMONTHDAY=' . $this->getBYMONTHDAY();
     }
     if ($this->getBYDAY()) {
         $ical .= ';BYDAY=' . $this->getBYDAY();
     }
     if ($this->getBYSETPOS()) {
         $ical .= ';BYSETPOS=' . $this->getBYSETPOS();
     }
     // Required in outlook
     if ($this->getBYDAY()) {
         include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
         include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
         $us = ilCalendarUserSettings::_getInstanceByUserId($a_user_id);
         if ($us->getWeekStart() == ilCalendarSettings::WEEK_START_MONDAY) {
             $ical .= ';WKST=MO';
         } else {
             $ical .= ';WKST=SU';
         }
     }
     return $ical;
 }
Пример #13
0
 protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates)
 {
     global $ilUser;
     include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
     $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $map = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su');
     $definition = $schedule->getDefinition();
     $has_open_slot = false;
     foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) {
         $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
         $slots = array();
         if (isset($definition[$map[$date_info['isoday'] - 1]])) {
             $slots = array();
             foreach ($definition[$map[$date_info['isoday'] - 1]] as $slot) {
                 $slot = explode('-', $slot);
                 $slots[] = array('from' => str_replace(':', '', $slot[0]), 'to' => str_replace(':', '', $slot[1]));
             }
         }
         $last = array_pop(array_keys($hours));
         $slot_captions = array();
         foreach ($hours as $hour => $period) {
             $dates[$hour][0] = $period;
             $period = explode("-", $period);
             // #13738
             if ($user_settings->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_12) {
                 if (stristr($period[0], "pm")) {
                     $period[0] = (int) $period[0] + 12;
                 } else {
                     $period[0] = (int) $period[0];
                     if ($period[0] == 12) {
                         $period[0] = 0;
                     }
                 }
                 if (sizeof($period) == 2) {
                     if (stristr($period[1], "pm")) {
                         $period[1] = (int) $period[1] + 12;
                     } else {
                         $period[1] = (int) $period[1];
                         if ($period[1] == 12) {
                             $period[1] = 0;
                         }
                     }
                 }
             }
             if (sizeof($period) == 1) {
                 $period_from = (int) substr($period[0], 0, 2) . "00";
                 $period_to = (int) substr($period[0], 0, 2) . "59";
             } else {
                 $period_from = (int) substr($period[0], 0, 2) . "00";
                 $period_to = (int) substr($period[1], 0, 2) . "59";
             }
             $column = $date_info['isoday'];
             if (!$week_start) {
                 if ($column < 7) {
                     $column++;
                 } else {
                     $column = 1;
                 }
             }
             if (sizeof($slots)) {
                 $in = false;
                 foreach ($slots as $slot) {
                     $slot_from = mktime(substr($slot['from'], 0, 2), substr($slot['from'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]);
                     $slot_to = mktime(substr($slot['to'], 0, 2), substr($slot['to'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]);
                     // always single object, we can sum up
                     $nr_available = (array) ilBookingReservation::getAvailableObject($object_ids, $slot_from, $slot_to - 1, false, true);
                     // check deadline
                     if ($slot_from < time() + $schedule->getDeadline() * 60 * 60 || !array_sum($nr_available)) {
                         continue;
                     }
                     // is slot active in current hour?
                     if ((int) $slot['from'] < $period_to && (int) $slot['to'] > $period_from) {
                         $from = ilDatePresentation::formatDate(new ilDateTime($slot_from, IL_CAL_UNIX));
                         $from = array_pop(explode(' ', $from));
                         $to = ilDatePresentation::formatDate(new ilDateTime($slot_to, IL_CAL_UNIX));
                         $to = array_pop(explode(' ', $to));
                         // show caption (first hour) of slot
                         $id = $slot_from . '_' . $slot_to;
                         if (!in_array($id, $slot_captions)) {
                             $dates[$hour][$column]['captions'][$id] = $from . '-' . $to;
                             $dates[$hour][$column]['available'][$id] = array_sum($nr_available);
                             $slot_captions[] = $id;
                         }
                         $in = true;
                     }
                 }
                 // (any) active slot
                 if ($in) {
                     $has_open_slot = true;
                     $dates[$hour][$column]['in_slot'] = $in;
                 }
             }
         }
     }
     return $has_open_slot;
 }
 /**
  * Confirmation screen to cancel consultation appointment or ressource booking
  * depends on calendar category
  */
 public function cancelBooking()
 {
     global $ilUser, $tpl;
     $entry = (int) $_GET['app_id'];
     include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
     $entry = new ilCalendarEntry($entry);
     $category = $this->calendarEntryToCategory($entry);
     if ($category->getType() == ilCalendarCategory::TYPE_CH) {
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         $booking = new ilBookingEntry($entry->getContextId());
         if (!$booking->hasBooked($entry->getEntryId())) {
             $this->ctrl->returnToParent($this);
             return false;
         }
         $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')';
     } else {
         if ($category->getType() == ilCalendarCategory::TYPE_BOOK) {
             $entry_title = ' ' . $entry->getTitle();
         } else {
             $this->ctrl->returnToParent($this);
             return false;
         }
     }
     $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $timezone = $ilUser->getTimeZone();
     switch ($user_settings->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             $title = $entry->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $timezone);
             $title .= "-" . $entry->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $timezone);
             break;
         case ilCalendarSettings::TIME_FORMAT_12:
             $title = $entry->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $timezone);
             $title .= "-" . $entry->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $timezone);
             break;
     }
     include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
     $conf = new ilConfirmationGUI();
     $conf->setFormAction($this->ctrl->getFormAction($this));
     $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info'));
     $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed');
     $conf->setCancel($this->lng->txt('cancel'), 'cancel');
     $conf->addItem('app_id', $entry->getEntryId(), $title . ' - ' . $entry_title);
     $tpl->setContent($conf->getHTML());
 }