/**
  * Book consultation appointment, was confirmed
  */
 public function bookconfirmed()
 {
     global $ilUser;
     $entry = (int) $_REQUEST['app_id'];
     $user = (int) $_REQUEST['bkid'];
     $form = $this->initFormConfirmBooking();
     if ($form->checkInput()) {
         // check if appointment is bookable
         include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
         $cal_entry = new ilCalendarEntry($entry);
         include_once './Services/Booking/classes/class.ilBookingEntry.php';
         $booking = new ilBookingEntry($cal_entry->getContextId());
         if (!$booking->isAppointmentBookableForUser($entry, $GLOBALS['ilUser']->getId())) {
             ilUtil::sendFailure($this->lng->txt('cal_booking_failed_info'), true);
             $this->ctrl->returnToParent($this);
         }
         include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
         ilConsultationHourUtils::bookAppointment($ilUser->getId(), $entry);
         include_once './Services/Booking/classes/class.ilBookingEntry.php';
         ilBookingEntry::writeBookingMessage($entry, $ilUser->getId(), $form->getInput('comment'));
     }
     ilUtil::sendSuccess($this->lng->txt('cal_booking_confirmed'), true);
     $this->ctrl->returnToParent($this);
 }
 /**
  * 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');
 }
 /**
  * Lookup bookings for own and managed consultation hours of an object
  * @param type $a_obj_id
  * @param type $a_usr_id
  * @return array
  */
 public static function lookupManagedBookingsForObject($a_obj_id, $a_usr_id)
 {
     $bookings = self::lookupBookingsForObject($a_obj_id, $a_usr_id);
     include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
     foreach (ilConsultationHourUtils::lookupManagedUsers($a_usr_id) as $managed_user_id) {
         foreach (self::lookupBookingsForObject($a_obj_id, $managed_user_id) as $booked_user => $booking) {
             $fullname = ilObjUser::_lookupFullname($managed_user_id);
             foreach ($booking as $booking_entry) {
                 $booking_entry['explanation'] = '(' . $fullname . ')';
                 $bookings[$booked_user][] = $booking_entry;
             }
         }
     }
     return $bookings;
 }