/**
  * set appointments
  *
  * @access public
  * @return
  */
 public function setAppointments($a_apps)
 {
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
     foreach ($a_apps as $event) {
         $entry = $event['event'];
         $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
         $tmp_arr['id'] = $entry->getEntryId();
         $tmp_arr['milestone'] = $entry->isMilestone();
         $tmp_arr['title'] = $entry->getPresentationTitle();
         $tmp_arr['description'] = $entry->getDescription();
         $tmp_arr['fullday'] = $entry->isFullday();
         #$tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
         #$tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
         $tmp_arr['begin'] = $event['dstart'];
         $tmp_arr['end'] = $event['dend'];
         $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
         if ($tmp_arr['fullday']) {
             $tmp_arr['duration'] += 60 * 60 * 24;
         }
         if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) {
             $tmp_arr['duration'] = '';
         }
         $tmp_arr['last_update'] = $entry->getLastUpdate()->get(IL_CAL_UNIX);
         $tmp_arr['frequence'] = $rec->getFrequenceType();
         $appointments[] = $tmp_arr;
     }
     $this->setData($appointments ? $appointments : array());
 }
コード例 #2
0
 protected function createRecurrences($app)
 {
     global $ilUser;
     include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
     foreach (ilCalendarRecurrences::_getRecurrences($app->getEntryId()) as $rec) {
         foreach (ilCalendarRecurrenceExclusions::getExclusionDates($app->getEntryId()) as $excl) {
             $this->writer->addLine($excl->toICal());
         }
         $this->writer->addLine($rec->toICal($ilUser->getId()));
     }
 }
コード例 #3
0
 /**
  * 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;
             }
         }
     }
 }
コード例 #4
0
 /**
  * init appointment
  *
  * @access protected
  * @param int appointment id
  * @return
  */
 protected function initAppointment($a_app_id = 0)
 {
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
     $this->app = new ilCalendarEntry($a_app_id);
     include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
     $this->notification = new ilCalendarUserNotification($this->app->getEntryId());
     if (!$a_app_id) {
         $start = clone $this->initialDate;
         $this->app->setStart($start);
         $seed_end = clone $this->initialDate;
         if ($this->default_fulltime) {
             #$seed_end->increment(IL_CAL_DAY,1);
         } else {
             $seed_end->increment(IL_CAL_HOUR, 1);
         }
         $this->app->setEnd($seed_end);
         $this->app->setFullday($this->default_fulltime);
         $this->rec = new ilCalendarRecurrence();
     } else {
         $this->rec = ilCalendarRecurrences::_getFirstRecurrence($this->app->getEntryId());
     }
 }
コード例 #5
0
 /**
  * set appointments
  *
  * @access public
  * @return
  */
 public function setAppointments($a_apps)
 {
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     $cat = new ilCalendarCategory($this->cat_id);
     foreach ($a_apps as $cal_entry_id) {
         $entry = new ilCalendarEntry($cal_entry_id);
         $rec = ilCalendarRecurrences::_getFirstRecurrence($entry->getEntryId());
         // booking
         if ($cat->getType() == ilCalendarCategory::TYPE_CH) {
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             $book = new ilBookingEntry($entry->getContextId());
             if ($book) {
                 $title = $entry->getTitle();
                 if ($book->isOwner()) {
                     $max = (int) $book->getNumberOfBookings();
                     $current = (int) $book->getCurrentNumberOfBookings($entry->getEntryId());
                     if ($max > 1) {
                         $title .= ' (' . $current . '/' . $max . ')';
                     } else {
                         if ($current == $max) {
                             $title .= ' (' . $this->lng->txt('cal_booked_out') . ')';
                         } else {
                             $title .= ' (' . $this->lng->txt('cal_book_free') . ')';
                         }
                     }
                 } else {
                     if ($book->hasBooked($entry->getEntryId())) {
                         $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
                     }
                 }
             }
         } else {
             $title = $entry->getPresentationTitle();
         }
         $tmp_arr['id'] = $entry->getEntryId();
         $tmp_arr['title'] = $title;
         $tmp_arr['description'] = $entry->getDescription();
         $tmp_arr['fullday'] = $entry->isFullday();
         $tmp_arr['begin'] = $entry->getStart()->get(IL_CAL_UNIX);
         $tmp_arr['end'] = $entry->getEnd()->get(IL_CAL_UNIX);
         $tmp_arr['dt_sort'] = $entry->getStart()->get(IL_CAL_UNIX);
         $tmp_arr['dt'] = ilDatePresentation::formatPeriod($entry->getStart(), $entry->getEnd());
         #$tmp_arr['duration'] = ($dur = $tmp_arr['end'] - $tmp_arr['begin']) ? $dur : 60 * 60 * 24;
         $tmp_arr['duration'] = $tmp_arr['end'] - $tmp_arr['begin'];
         if ($tmp_arr['fullday']) {
             $tmp_arr['duration'] += 60 * 60 * 24;
         }
         if (!$tmp_arr['fullday'] and $tmp_arr['end'] == $tmp_arr['begin']) {
             $tmp_arr['duration'] = '';
         }
         $tmp_arr['frequence'] = $rec->getFrequenceType();
         $tmp_arr['deletable'] = (!$entry->isAutoGenerated() and $this->is_editable);
         $appointments[] = $tmp_arr;
     }
     $this->setData($appointments ? $appointments : array());
 }