/** * Import ical in calendar * @param ilCalendarCategory $cat */ protected function importIcal(ilCalendarCategory $cat) { // Delete old appointments include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($cat->getCategoryID())) as $app_id) { include_once './Services/Calendar/classes/class.ilCalendarEntry.php'; ilCalendarEntry::_delete($app_id); } ilCalendarCategoryAssignments::_deleteByCategoryId($cat->getCategoryID()); // Import new appointments include_once './Services/Calendar/classes/iCal/class.ilICalParser.php'; $parser = new ilICalParser($this->ical, ilICalParser::INPUT_STRING); $parser->setCategoryId($cat->getCategoryID()); $parser->parse(); }
/** * read permissions * * @access private * @param * @return */ private function readPermissions() { global $ilUser, $rbacsystem, $ilAccess; $this->editable = false; $this->visible = false; $this->importable = false; include_once './Services/Calendar/classes/class.ilCalendarShared.php'; $shared = ilCalendarShared::getSharedCalendarsForUser($ilUser->getId()); $cat = new ilCalendarCategory((int) $_GET['category_id']); switch ($cat->getType()) { case ilCalendarCategory::TYPE_USR: if ($cat->getObjId() == $ilUser->getId()) { $this->visible = true; $this->editable = true; $this->importable = true; } elseif (isset($shared[$cat->getCategoryID()])) { $this->visible = true; } break; case ilCalendarCategory::TYPE_GLOBAL: $this->importable = $this->editable = $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId()); $this->visible = true; break; case ilCalendarCategory::TYPE_OBJ: $this->editable = false; $refs = ilObject::_getAllReferences($cat->getObjId()); foreach ($refs as $ref) { if ($ilAccess->checkAccess('read', '', $ref)) { $this->visible = true; } if ($ilAccess->checkAccess('edit_event', '', $ref)) { $this->importable = true; } } break; case ilCalendarCategory::TYPE_BOOK: case ilCalendarCategory::TYPE_CH: $this->editable = $ilUser->getId() == $cat->getCategoryID(); $this->visible = true; $this->importable = false; break; } }
/** * 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; } }