/** * Book object for date * * @param int $a_object_id * @param int $a_from timestamp * @param int $a_to timestamp */ function processBooking($a_object_id, $a_from = null, $a_to = null) { global $ilUser; include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $reservation = new ilBookingReservation(); $reservation->setObjectId($a_object_id); $reservation->setUserId($ilUser->getID()); $reservation->setFrom($a_from); $reservation->setTo($a_to); $reservation->save(); if ($a_from) { $this->lng->loadLanguageModule('dateplaner'); include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; include_once 'Services/Calendar/classes/class.ilCalendarCategory.php'; $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true); include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $object = new ilBookingObject($a_object_id); include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry(); $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX)); $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX)); $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle()); $entry->setContextId($reservation->getId()); $entry->save(); include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $assignment = new ilCalendarCategoryAssignments($entry->getEntryId()); $assignment->addAssignment($def_cat->getCategoryId()); } }
/** * Book object for date * * @param int $a_object_id * @param int $a_from timestamp * @param int $a_to timestamp * @param int $a_group_id * @return int */ function processBooking($a_object_id, $a_from = null, $a_to = null, $a_group_id = null) { global $ilUser, $ilAccess; // #11995 if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) { $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE); } include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $reservation = new ilBookingReservation(); $reservation->setObjectId($a_object_id); $reservation->setUserId($ilUser->getID()); $reservation->setFrom($a_from); $reservation->setTo($a_to); $reservation->setGroupId($a_group_id); $reservation->save(); if ($a_from) { $this->lng->loadLanguageModule('dateplaner'); include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; include_once 'Services/Calendar/classes/class.ilCalendarCategory.php'; $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true); include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $object = new ilBookingObject($a_object_id); include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry(); $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX)); $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX)); $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle()); $entry->setContextId($reservation->getId()); $entry->save(); include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'; $assignment = new ilCalendarCategoryAssignments($entry->getEntryId()); $assignment->addAssignment($def_cat->getCategoryId()); } return $reservation->getId(); }