/**
  * Cancel a booking
  * @param type $a_usr_id
  * @param type $a_app_id
  * @return bool
  */
 public static function cancelBooking($a_usr_id, $a_app_id, $a_send_notification = true)
 {
     // Delete personal copy of appointment
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     $app = new ilCalendarEntry($a_app_id);
     include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
     $user_apps = ilConsultationHourAppointments::getAppointmentIds($a_usr_id, $app->getContextId(), $app->getStart(), ilCalendarCategory::TYPE_CH, false);
     foreach ($user_apps as $uapp_id) {
         $uapp = new ilCalendarEntry($uapp_id);
         $uapp->delete();
         include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         ilCalendarCategoryAssignments::_deleteByAppointmentId($uapp_id);
         break;
     }
     // Delete booking entries
     // Send notification
     $booking = new ilBookingEntry($app->getContextId());
     if ($a_send_notification) {
         $booking->cancelBooking($a_app_id, $a_usr_id);
     } else {
         $booking->deleteBooking($a_app_id, $a_usr_id);
     }
     return true;
 }
 /**
  * delete multiple entries
  */
 public function delete()
 {
     if (!isset($_POST['apps'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         return $this->appointmentList();
     }
     include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     foreach ($_POST['apps'] as $entry_id) {
         // cancel booking for users
         $booking = ilBookingEntry::getInstanceByCalendarEntryId($entry_id);
         if ($booking) {
             foreach ($booking->getCurrentBookings($entry_id) as $user_id) {
                 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
                 ilConsultationHourUtils::cancelBooking($user_id, $entry_id, false);
             }
         }
         // remove calendar entries
         include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
         $entry = new ilCalendarEntry($entry_id);
         $entry->delete();
         ilCalendarCategoryAssignments::_deleteByAppointmentId($entry_id);
     }
     ilBookingEntry::removeObsoleteEntries();
     ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
     $this->ctrl->redirect($this, 'appointmentList');
 }
 /**
  * delete appointments
  *
  * @access protected
  * @return
  */
 protected function deleteAppointments()
 {
     if (!count($_POST['appointments'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         $this->details();
         return true;
     }
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     foreach ($_POST['appointments'] as $app_id) {
         $app = new ilCalendarEntry($app_id);
         $app->delete();
         include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         ilCalendarCategoryAssignments::_deleteByAppointmentId($app_id);
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     $this->details();
     return true;
 }
 /**
  * delete
  *
  * @access public
  * @return
  */
 public function delete()
 {
     global $ilDB;
     include_once './Services/Calendar/classes/class.ilCalendarRecurrence.php';
     ilCalendarRecurrence::_delete($this->getEntryId());
     $query = "DELETE FROM cal_entries " . "WHERE cal_id = " . $this->db->quote($this->getEntryId(), 'integer') . " ";
     $res = $ilDB->manipulate($query);
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     ilCalendarCategoryAssignments::_deleteByAppointmentId($this->getEntryId());
     return true;
 }
 /**
  * delete
  *
  * @access protected
  * @param
  * @return
  */
 protected function delete()
 {
     foreach ($_POST['appointments'] as $app_id) {
         $app = new ilCalendarEntry($app_id);
         $app->delete();
         include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         ilCalendarCategoryAssignments::_deleteByAppointmentId($app_id);
         include_once './Services/Calendar/classes/class.ilCalendarUserNotification.php';
         ilCalendarUserNotification::deleteCalendarEntry($app_id);
     }
     ilUtil::sendSuccess($this->lng->txt('cal_deleted_app'), true);
     $this->ctrl->returnToParent($this);
 }
 /**
  * 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 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);
     }
 }