/**
  * 
  * @param array $usr_ids
  * @param type $type
  */
 public function assignUsersToGroup(array $usr_ids)
 {
     global $ilCtrl;
     $group_id = (int) $_REQUEST['grp_id'];
     $tomorrow = new ilDateTime(time(), IL_CAL_UNIX);
     $tomorrow->increment(IL_CAL_DAY, 1);
     // Get all future consultation hours
     include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
     include_once './Services/Booking/classes/class.ilBookingEntry.php';
     $apps = ilConsultationHourAppointments::getAppointmentIdsByGroup($this->user_id, $group_id, $tomorrow);
     $users = $usr_ids;
     $assigned_users = array();
     foreach ($apps as $app) {
         $booking = ilBookingEntry::getInstanceByCalendarEntryId($app);
         foreach ($users as $user) {
             if ($booking->getCurrentNumberOfBookings($app) >= $booking->getNumberOfBookings()) {
                 break;
             }
             if (!ilBookingEntry::lookupBookingsOfUser($apps, $user)) {
                 include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
                 ilConsultationHourUtils::bookAppointment($user, $app);
                 $assigned_users[] = $user;
             }
         }
     }
     $this->sendInfoAboutUnassignedUsers(array_diff($users, $assigned_users));
     $ilCtrl->redirect($this, 'bookingList');
 }
 /**
  * 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);
 }