/**
  * 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();
 }
 /**
  * Delete calendar entries of bookings from the database.
  *
  * @param array $a_booking_ids
  */
 public function deleteCalendarEntriesOfBookings($a_booking_ids)
 {
     $set = $this->ilDB->prepare('SELECT calendar_entry_id FROM ' . dbc::BOOKINGS_TABLE . ' WHERE ' . $this->ilDB->in("id", $a_booking_ids) . ' AND pool_id =' . $this->ilDB->quote($this->pool_id, 'integer'));
     $result = $this->ilDB->execute($set, $a_booking_ids);
     while ($a_entry_id = $this->ilDB->fetchAssoc($result)) {
         ilCalendarEntry::_delete($a_entry_id['calendar_entry_id']);
     }
 }
 /**
  * Delete automatic generated appointments
  * 
  * @access public
  * @param int obj_id
  * @static
  */
 public static function deleteAppointments($a_obj_id)
 {
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     foreach (ilCalendarCategoryAssignments::_getAutoGeneratedAppointmentsByObjId($a_obj_id) as $app_id) {
         ilCalendarCategoryAssignments::_deleteByAppointmentId($app_id);
         ilCalendarEntry::_delete($app_id);
     }
 }
 /**
  * delete
  *
  * @access public
  * @return
  */
 public function delete()
 {
     global $ilDB;
     $query = "DELETE FROM cal_categories " . "WHERE cat_id = " . $this->db->quote($this->cat_id, 'integer') . " ";
     $res = $ilDB->manipulate($query);
     include_once './Services/Calendar/classes/class.ilCalendarHidden.php';
     ilCalendarHidden::_deleteCategories($this->cat_id);
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     foreach (ilCalendarCategoryAssignments::_getAssignedAppointments(array($this->cat_id)) as $app_id) {
         include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
         ilCalendarEntry::_delete($app_id);
     }
     ilCalendarCategoryAssignments::_deleteByCategoryId($this->cat_id);
 }
 /**
  * Delete automatic generated appointments
  * 
  * @access public
  * @param int obj_id
  * @param array context ids
  * @static
  */
 public static function deleteAppointments($a_obj_id, array $a_context_ids = null)
 {
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     foreach (ilCalendarCategoryAssignments::_getAutoGeneratedAppointmentsByObjId($a_obj_id) as $app_id) {
         // delete only selected entries
         if (is_array($a_context_ids)) {
             $entry = new ilCalendarEntry($app_id);
             if (!in_array($entry->getContextId(), $a_context_ids)) {
                 continue;
             }
         }
         ilCalendarCategoryAssignments::_deleteByAppointmentId($app_id);
         ilCalendarEntry::_delete($app_id);
     }
 }