/** * Import ics * @param type $file * @param type $category_id */ protected function doImportFile($file, $category_id) { include_once './Services/Calendar/classes/../classes/iCal/class.ilICalParser.php'; include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $GLOBALS['ilLog']->write(__METHOD__ . ': Starting ical import...'); $assigned_before = ilCalendarCategoryAssignments::lookupNumberOfAssignedAppointments(array($category_id)); $parser = new ilICalParser($file, ilICalParser::INPUT_FILE); $parser->setCategoryId($category_id); $parser->parse(); $assigned_after = ilCalendarCategoryAssignments::lookupNumberOfAssignedAppointments(array($category_id)); return $assigned_after - $assigned_before; }
/** * 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(); }