public function isValidEvent(ilCalendarEntry $a_event)
 {
     global $ilUser;
     $booking = new ilBookingEntry($a_event->getContextId());
     // portfolio embedded: filter by consultation hour groups?
     if (!is_array($this->group_ids) || in_array($booking->getBookingGroup(), $this->group_ids)) {
         // do not filter against course/group in portfolio
         if ($this->cats->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
             $booking->setTargetObjIds(null);
         }
         if (($this->user_id == $ilUser->getId() || !$booking->isBookedOut($a_event->getEntryId(), true)) && $booking->isTargetObjectVisible($this->cats->getTargetRefId())) {
             return true;
         }
     }
     return false;
 }
 /**
  * Update multiple sequence items
  * @return
  */
 protected function updateMulti()
 {
     global $ilObjDataCache;
     $this->initFormSequence(self::MODE_MULTI);
     if ($this->form->checkInput()) {
         $this->form->setValuesByPost();
         $apps = explode(';', $_POST['apps']);
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         // do collision-check if max bookings were reduced
         // no collision check
         $first = $apps;
         $first = array_shift($first);
         $entry = ilBookingEntry::getInstanceByCalendarEntryId($first);
         #if($this->form->getInput('bo') < $entry->getNumberOfBookings())
         #{
         #   $this->edit();
         #   return;
         #}
         // create new context
         $booking = new ilBookingEntry();
         $booking->setObjId($this->getUserId());
         $booking->setNumberOfBookings($this->form->getInput('bo'));
         $deadline = $this->form->getInput('dead');
         $deadline = $deadline['dd'] * 24 + $deadline['hh'];
         $booking->setDeadlineHours($deadline);
         $tgt = explode(',', $this->form->getInput('tgt'));
         $obj_ids = array();
         foreach ((array) $tgt as $ref_id) {
             if (!trim($ref_id)) {
                 continue;
             }
             $obj_id = $ilObjDataCache->lookupObjId($ref_id);
             $type = ilObject::_lookupType($obj_id);
             $valid_types = array('crs', 'grp');
             if (!$obj_id or !in_array($type, $valid_types)) {
                 ilUtil::sendFailure($this->lng->txt('cal_ch_unknown_repository_object'));
                 $this->edit();
                 return;
             }
             $obj_ids[] = $obj_id;
         }
         $booking->setTargetObjIds($obj_ids);
         include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
         if (ilConsultationHourGroups::getCountGroupsOfUser($this->getUserId())) {
             $booking->setBookingGroup($this->form->getInput('grp'));
         }
         $booking->save();
         // update entries
         $title = $this->form->getInput('ti');
         $location = $this->form->getInput('lo');
         $description = $this->form->getInput('de');
         foreach ($apps as $item_id) {
             $entry = new ilCalendarEntry($item_id);
             $entry->setContextId($booking->getId());
             $entry->setTitle($title);
             $entry->setLocation($location);
             $entry->setDescription($description);
             $entry->update();
         }
         ilBookingEntry::removeObsoleteEntries();
         ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
         $this->ctrl->redirect($this, 'appointmentList');
     }
     $this->tpl->setContent($this->form->getHTML());
 }