コード例 #1
0
 /**
  * Create calendar appointments
  * @param ilBookingEntry $booking
  * @return 
  */
 protected function createAppointments(ilBookingEntry $booking)
 {
     include_once './Services/Calendar/classes/class.ilDateList.php';
     $concurrent_dates = new ilDateList(ilDateList::TYPE_DATETIME);
     $start = clone $this->form->getItemByPostVar('st')->getDate();
     for ($i = 0; $i < $this->form->getItemByPostVar('ap')->getValue(); $i++) {
         $concurrent_dates->add(clone $start);
         $start->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes());
         $start->increment(ilDateTime::HOUR, $this->form->getItemByPostVar('du')->getHours());
         #$start = new ilDateTime(,IL_CAL_UNIX);
     }
     include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
     $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_CH, $this->getUserId(), $this->lng->txt('cal_ch_personal_ch'), true);
     // Add calendar appointment for each
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
     include_once './Services/Booking/classes/class.ilBookingPeriod.php';
     foreach ($concurrent_dates as $dt) {
         $end = clone $dt;
         $end->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes());
         $end->increment(ilDateTime::HOUR, $this->form->getItemByPostVar('du')->getHours());
         $calc = new ilCalendarRecurrenceCalculator(new ilBookingPeriod($dt, $end), $this->form->getItemByPostVar('frequence')->getRecurrence());
         // Calculate with one year limit
         $limit = clone $dt;
         $limit->increment(ilDAteTime::YEAR, 1);
         $date_list = $calc->calculateDateList($dt, $limit);
         foreach ($date_list as $app_start) {
             $app_end = clone $app_start;
             $app_end->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes());
             $entry = new ilCalendarEntry();
             $entry->setContextId($booking->getId());
             $entry->setTitle($this->form->getInput('ti'));
             $entry->setSubtitle("#consultationhour#");
             // dynamic, see ilCalendarEntry
             $entry->setDescription($this->form->getInput('de'));
             $entry->setLocation($this->form->getInput('lo'));
             $entry->setStart($app_start);
             $entry->setEnd($app_end);
             $entry->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
             $entry->save();
             $cat_assign = new ilCalendarCategoryAssignments($entry->getEntryId());
             $cat_assign->addAssignment($def_cat->getCategoryID());
         }
     }
 }
コード例 #2
0
 /**
  * Book object for date
  * 
  * @param int $a_object_id
  * @param int $a_from timestamp
  * @param int $a_to timestamp
  */
 function processBooking($a_object_id, $a_from = null, $a_to = null)
 {
     global $ilUser;
     include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
     $reservation = new ilBookingReservation();
     $reservation->setObjectId($a_object_id);
     $reservation->setUserId($ilUser->getID());
     $reservation->setFrom($a_from);
     $reservation->setTo($a_to);
     $reservation->save();
     if ($a_from) {
         $this->lng->loadLanguageModule('dateplaner');
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
         $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true);
         include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
         $object = new ilBookingObject($a_object_id);
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         $entry = new ilCalendarEntry();
         $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX));
         $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX));
         $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle());
         $entry->setContextId($reservation->getId());
         $entry->save();
         include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
         $assignment->addAssignment($def_cat->getCategoryId());
     }
 }
コード例 #3
0
 /**
  * Generate Calendar Entries
  *
  * @param
  * @return
  */
 function generateCalendarEntries($a_num_per_course = 10)
 {
     include_once "./Services/Calendar/classes/class.ilDateTime.php";
     include_once "./Services/Calendar/classes/class.ilCalendarEntry.php";
     include_once "./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php";
     include_once "./Services/Calendar/classes/class.ilCalendarCategories.php";
     $this->log("Creating Calendar Entries");
     $crs_ref_ids = ilUtil::_getObjectsByOperations("crs", "read", 0, $limit = 1000000);
     $cnt = 1;
     foreach ($crs_ref_ids as $rid) {
         $obj_id = ilObject::_lookupObjId($rid);
         $cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($obj_id);
         $start = new ilDate(time(), IL_CAL_UNIX);
         $end = new ilDate(time(), IL_CAL_UNIX);
         $end->increment(IL_CAL_HOUR, 2);
         for ($i = 1; $i <= $a_num_per_course; $i++) {
             $this->log("Event " . $cnt);
             $entry = new ilCalendarEntry();
             $entry->setStart($start);
             //ilDateTiem
             $entry->setEnd($end);
             //ilDateTiem
             $entry->setFullday(false);
             //ilDateTiem
             $entry->setTitle("Event " . $cnt);
             //ilDateTiem
             $entry->save();
             $id = $entry->getEntryId();
             $ass = new ilCalendarCategoryAssignments($id);
             $ass->addAssignment($cat_id);
             $start->increment(IL_CAL_DAY, 1);
             $end->increment(IL_CAL_DAY, 1);
             //echo "-$cat_id-";
             //echo "+".ilDatePresentation::formatDate($start)."+";
             $cnt++;
         }
     }
 }
 public function insertBookingAppointment($a_insertedId, $a_booking_values, $a_from = NULL, $a_to = NULL)
 {
     //create appointment first
     if ($a_from == NULL || $a_to == NULL) {
         $a_from = $a_booking_values['from']['date'] . " " . $a_booking_values['from']['time'];
         $a_to = $a_booking_values['to']['date'] . " " . $a_booking_values['to']['time'];
     }
     $time_start = new ilDateTime($a_from, 1);
     $time_end = new ilDateTime($a_to, 1);
     $title = $a_booking_values['subject'];
     $room_name = $this->ilRoomSharingDatabase->getRoomName($a_booking_values['room']);
     $cal_cat_id = $a_booking_values['cal_id'];
     //use original ilCalendarEntry and let ILIAS do the work
     $app = new ilCalendarEntry();
     $app->setStart($time_start);
     $app->setEnd($time_end);
     $app->setFullday(false);
     $app->setTitle($title);
     $app->setDescription($a_booking_values['comment']);
     $app->setAutoGenerated(true);
     $app->enableNotification(false);
     $app->setLocation($room_name);
     $app->validate();
     $app->save();
     $ass = new ilCalendarCategoryAssignments($app->getEntryId());
     $ass->addAssignment($cal_cat_id);
     //update bookings-table afterwards
     $this->ilDB->manipulate('UPDATE ' . dbc::BOOKINGS_TABLE . ' SET calendar_entry_id = ' . $this->ilDB->quote($app->getEntryId(), 'integer') . ' WHERE id = ' . $this->ilDB->quote($a_insertedId, 'integer') . ' AND pool_id =' . $this->ilDB->quote($this->pool_id, 'integer'));
 }
コード例 #5
0
 /**
  * Create appointments
  *
  * @access public
  * @param
  * @return
  * @static
  */
 public static function createAppointments($a_obj, $a_appointments)
 {
     global $ilLog;
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     if (!($cat_id = ilCalendarCategories::_lookupCategoryIdByObjId($a_obj->getId()))) {
         $ilLog->write(__METHOD__ . ': Cannot find calendar category for obj_id ' . $a_obj->getId());
         $cat_id = self::createCategory($a_obj);
     }
     foreach ($a_appointments as $app_templ) {
         $app = new ilCalendarEntry();
         $app->setContextId($app_templ->getContextId());
         $app->setTitle($app_templ->getTitle());
         $app->setSubtitle($app_templ->getSubtitle());
         $app->setDescription($app_templ->getDescription());
         $app->setFurtherInformations($app_templ->getInformation());
         $app->setLocation($app_templ->getLocation());
         $app->setStart($app_templ->getStart());
         $app->setEnd($app_templ->getEnd());
         $app->setFullday($app_templ->isFullday());
         $app->setAutoGenerated(true);
         $app->setTranslationType($app_templ->getTranslationType());
         $app->save();
         $ass = new ilCalendarCategoryAssignments($app->getEntryId());
         $ass->addAssignment($cat_id);
     }
 }
コード例 #6
0
 /**
  * Book object for date
  * 
  * @param int $a_object_id
  * @param int $a_from timestamp
  * @param int $a_to timestamp
  * @param int $a_group_id 
  * @return int
  */
 function processBooking($a_object_id, $a_from = null, $a_to = null, $a_group_id = null)
 {
     global $ilUser, $ilAccess;
     // #11995
     if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
     }
     include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
     $reservation = new ilBookingReservation();
     $reservation->setObjectId($a_object_id);
     $reservation->setUserId($ilUser->getID());
     $reservation->setFrom($a_from);
     $reservation->setTo($a_to);
     $reservation->setGroupId($a_group_id);
     $reservation->save();
     if ($a_from) {
         $this->lng->loadLanguageModule('dateplaner');
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
         $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true);
         include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
         $object = new ilBookingObject($a_object_id);
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         $entry = new ilCalendarEntry();
         $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX));
         $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX));
         $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle());
         $entry->setContextId($reservation->getId());
         $entry->save();
         include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
         $assignment->addAssignment($def_cat->getCategoryId());
     }
     return $reservation->getId();
 }
コード例 #7
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "calendar":
             // please note: we currently only support private user calendars to
             // be imported
             if ($a_rec["Type"] == 1) {
                 $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["ObjId"]);
                 if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
                     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
                     $category = new ilCalendarCategory(0);
                     $category->setTitle($a_rec["Title"]);
                     $category->setColor($a_rec["Color"]);
                     $category->setType(ilCalendarCategory::TYPE_USR);
                     $category->setObjId($usr_id);
                     $category->add();
                     $a_mapping->addMapping("Services/Calendar", "calendar", $a_rec["CatId"], $category->getCategoryID());
                 }
             }
             break;
         case "cal_entry":
             // please note: we currently only support private user calendars to
             // be imported
             if ((int) $a_rec["ContextId"] == 0) {
                 include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
                 $entry = new ilCalendarEntry(0);
                 $entry->setTitle($a_rec["Title"]);
                 $entry->setSubtitle($a_rec["Subtitle"]);
                 $entry->setDescription($a_rec["Description"]);
                 $entry->setLocation($a_rec["Location"]);
                 $entry->setFullday($a_rec["Fullday"]);
                 if ($a_rec["Starta"] != "") {
                     $entry->setStart(new ilDateTime($a_rec["Starta"], IL_CAL_DATETIME, 'UTC'));
                 }
                 if ($a_rec["Enda"] != "") {
                     $entry->setEnd(new ilDateTime($a_rec["Enda"], IL_CAL_DATETIME, 'UTC'));
                 }
                 $entry->setFurtherInformations($a_rec["Informations"]);
                 $entry->setAutoGenerated($a_rec["AutoGenerated"]);
                 $entry->setContextId($a_rec["ContextId"]);
                 $entry->setMilestone($a_rec["Milestone"]);
                 $entry->setCompletion($a_rec["Completion"]);
                 $entry->setTranslationType($a_rec["TranslationType"]);
                 $entry->enableNotification($a_rec["Notification"]);
                 $entry->save();
                 $a_mapping->addMapping("Services/Calendar", "cal_entry", $a_rec["Id"], $entry->getEntryId());
             }
             break;
         case "cal_assignment":
             $cat_id = $a_mapping->getMapping("Services/Calendar", "calendar", $a_rec["CatId"]);
             $entry_id = $a_mapping->getMapping("Services/Calendar", "cal_entry", $a_rec["EntryId"]);
             if ($cat_id > 0 && $entry_id > 0) {
                 include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
                 $ass = new ilCalendarCategoryAssignments($entry_id);
                 $ass->addAssignment($cat_id);
             }
             break;
         case "recurrence_rule":
             $entry_id = $a_mapping->getMapping("Services/Calendar", "cal_entry", $a_rec["EntryId"]);
             if ($entry_id > 0) {
                 include_once './Services/Calendar/classes/class.ilCalendarRecurrence.php';
                 $rec = new ilCalendarRecurrence();
                 $rec->setEntryId($entry_id);
                 $rec->setRecurrence($a_rec["CalRecurrence"]);
                 $rec->setFrequenceType($a_rec["FreqType"]);
                 if ($a_rec["FreqUntilDate"] != "") {
                     $rec->setFrequenceUntilDate(new ilDateTime($a_rec["FreqUntilDate"], IL_CAL_DATETIME));
                 }
                 $rec->setFrequenceUntilCount($a_rec["FreqUntilCount"]);
                 $rec->setInterval($a_rec["Interval"]);
                 $rec->setBYDAY($a_rec["Byday"]);
                 $rec->setBYWEEKNO($a_rec["Byweekno"]);
                 $rec->setBYMONTH($a_rec["Bymonth"]);
                 $rec->setBYMONTHDAY($a_rec["Bymonthday"]);
                 $rec->setBYYEARDAY($a_rec["Byyearday"]);
                 $rec->setBYSETPOS($a_rec["Bysetpos"]);
                 $rec->setWeekstart($a_rec["Weekstart"]);
                 $rec->save();
                 $a_mapping->addMapping("Services/Calendar", "recurrence_rule", $a_rec["RuleId"], $rec->getRecurrenceId());
             }
             break;
     }
 }
コード例 #8
0
 /**
  * write a new event
  *
  * @access protected
  */
 protected function writeEvent()
 {
     $entry = new ilCalendarEntry();
     // Search for summary
     foreach ($this->getContainer()->getItemsByName('SUMMARY', false) as $item) {
         if (is_a($item, 'ilICalProperty')) {
             $entry->setTitle($this->purgeString($item->getValue()));
             break;
         }
     }
     // Search description
     foreach ($this->getContainer()->getItemsByName('DESCRIPTION', false) as $item) {
         if (is_a($item, 'ilICalProperty')) {
             $entry->setDescription($this->purgeString($item->getValue()));
             break;
         }
     }
     // Search location
     foreach ($this->getContainer()->getItemsByName('LOCATION', false) as $item) {
         if (is_a($item, 'ilICalProperty')) {
             $entry->setLocation($this->purgeString($item->getValue()));
             break;
         }
     }
     foreach ($this->getContainer()->getItemsByName('DTSTART') as $start) {
         $fullday = false;
         foreach ($start->getItemsByName('VALUE') as $type) {
             if ($type->getValue() == 'DATE') {
                 $fullday = true;
             }
         }
         $start_tz = $this->default_timezone;
         foreach ($start->getItemsByName('TZID') as $param) {
             $start_tz = $this->getTZ($param->getValue());
         }
         if ($fullday) {
             $start = new ilDate($start->getValue(), IL_CAL_DATE);
         } else {
             $start = new ilDateTime($start->getValue(), IL_CAL_DATETIME, $start_tz->getIdentifier());
         }
         $entry->setStart($start);
         $entry->setFullday($fullday);
     }
     foreach ($this->getContainer()->getItemsByName('DTEND') as $end) {
         $fullday = false;
         foreach ($end->getItemsByName('VALUE') as $type) {
             if ($type->getValue() == 'DATE') {
                 $fullday = true;
             }
         }
         $end_tz = $this->default_timezone;
         foreach ($end->getItemsByName('TZID') as $param) {
             $end_tz = $this->getTZ($param->getValue());
         }
         if ($fullday) {
             $end = new ilDate($end->getValue(), IL_CAL_DATE);
             $end->increment(IL_CAL_DAY, -1);
         } else {
             $end = new ilDateTime($end->getValue(), IL_CAL_DATETIME, $end_tz->getIdentifier());
         }
         $entry->setEnd($end);
         $entry->setFullday($fullday);
     }
     // save calendar event
     if ($this->category->getLocationType() == ilCalendarCategory::LTYPE_REMOTE) {
         $entry->setAutoGenerated(true);
     }
     $entry->save();
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     $ass = new ilCalendarCategoryAssignments($entry->getEntryId());
     $ass->addAssignment($this->category->getCategoryID());
     // Recurrences
     foreach ($this->getContainer()->getItemsByName('RRULE') as $recurrence) {
         #var_dump("<pre>",$recurrence,"</pre>");
         include_once './Services/Calendar/classes/class.ilCalendarRecurrence.php';
         $rec = new ilCalendarRecurrence();
         $rec->setEntryId($entry->getEntryId());
         foreach ($recurrence->getItemsByName('FREQ') as $freq) {
             switch ($freq->getValue()) {
                 case 'DAILY':
                 case 'WEEKLY':
                 case 'MONTHLY':
                 case 'YEARLY':
                     $rec->setFrequenceType((string) $freq->getValue());
                     break;
                 default:
                     $this->log->write(__METHOD__ . ': Cannot handle recurring event of type: ' . $freq->getValue());
                     break 3;
             }
         }
         foreach ($recurrence->getItemsByName('COUNT') as $value) {
             $rec->setFrequenceUntilCount((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('UNTIL') as $until) {
             $rec->setFrequenceUntilDate(new ilDate($until->getValue(), IL_CAL_DATE));
             break;
         }
         foreach ($recurrence->getItemsByName('INTERVAL') as $value) {
             $rec->setInterval((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('BYDAY') as $value) {
             $rec->setBYDAY((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('BYWEEKNO') as $value) {
             $rec->setBYWEEKNO((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('BYMONTH') as $value) {
             $rec->setBYMONTH((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('BYMONTHDAY') as $value) {
             $rec->setBYMONTHDAY((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('BYYEARDAY') as $value) {
             $rec->setBYYEARDAY((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('BYSETPOS') as $value) {
             $rec->setBYSETPOS((string) $value->getValue());
             break;
         }
         foreach ($recurrence->getItemsByName('WKST') as $value) {
             $rec->setWeekstart((string) $value->getValue());
             break;
         }
         $rec->save();
     }
 }