/**
  * calculate 
  *
  * @access protected
  */
 public function calculate()
 {
     global $ilDB;
     $events = $this->getEvents();
     // we need category type for booking handling
     $ids = array();
     foreach ($events as $event) {
         $ids[] = $event->getEntryId();
     }
     include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     $cat_map = ilCalendarCategoryAssignments::_getAppointmentCalendars($ids);
     include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
     $cat_types = array();
     foreach (array_unique($cat_map) as $cat_id) {
         $cat = new ilCalendarCategory($cat_id);
         $cat_types[$cat_id] = $cat->getType();
     }
     $counter = 0;
     foreach ($events as $event) {
         // Calculdate recurring events
         include_once 'Services/Calendar/classes/class.ilCalendarRecurrences.php';
         if ($recs = ilCalendarRecurrences::_getRecurrences($event->getEntryId())) {
             $duration = $event->getEnd()->get(IL_CAL_UNIX) - $event->getStart()->get(IL_CAL_UNIX);
             foreach ($recs as $rec) {
                 $calc = new ilCalendarRecurrenceCalculator($event, $rec);
                 foreach ($calc->calculateDateList($this->start, $this->end)->get() as $rec_date) {
                     $this->schedule[$counter]['event'] = $event;
                     $this->schedule[$counter]['dstart'] = $rec_date->get(IL_CAL_UNIX);
                     $this->schedule[$counter]['dend'] = $this->schedule[$counter]['dstart'] + $duration;
                     $this->schedule[$counter]['fullday'] = $event->isFullday();
                     $this->schedule[$counter]['category_id'] = $cat_map[$event->getEntryId()];
                     $this->schedule[$counter]['category_type'] = $cat_types[$cat_map[$event->getEntryId()]];
                     switch ($this->type) {
                         case self::TYPE_DAY:
                         case self::TYPE_WEEK:
                             // store date info (used for calculation of overlapping events)
                             $tmp_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone);
                             $this->schedule[$counter]['start_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
                             $tmp_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone);
                             $this->schedule[$counter]['end_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
                             break;
                         default:
                             break;
                     }
                     $counter++;
                     if ($this->areEventsLimited() && $counter >= $this->getEventsLimit()) {
                         break;
                     }
                 }
             }
         } else {
             $this->schedule[$counter]['event'] = $event;
             $this->schedule[$counter]['dstart'] = $event->getStart()->get(IL_CAL_UNIX);
             $this->schedule[$counter]['dend'] = $event->getEnd()->get(IL_CAL_UNIX);
             $this->schedule[$counter]['fullday'] = $event->isFullday();
             $this->schedule[$counter]['category_id'] = $cat_map[$event->getEntryId()];
             $this->schedule[$counter]['category_type'] = $cat_types[$cat_map[$event->getEntryId()]];
             if (!$event->isFullday()) {
                 switch ($this->type) {
                     case self::TYPE_DAY:
                     case self::TYPE_WEEK:
                         // store date info (used for calculation of overlapping events)
                         $tmp_date = new ilDateTime($this->schedule[$counter]['dstart'], IL_CAL_UNIX, $this->timezone);
                         $this->schedule[$counter]['start_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
                         $tmp_date = new ilDateTime($this->schedule[$counter]['dend'], IL_CAL_UNIX, $this->timezone);
                         $this->schedule[$counter]['end_info'] = $tmp_date->get(IL_CAL_FKT_GETDATE, '', $this->timezone);
                         break;
                     default:
                         break;
                 }
             }
             $counter++;
             if ($this->areEventsLimited() && $counter >= $this->getEventsLimit()) {
                 break;
             }
         }
     }
 }