/** * Inject JS file in the header code. * * @param Tx_CalendarDisplay_Domain_Model_FeUser $user * @param Tx_CalendarDisplay_Domain_Model_Event $event * @return boolean */ public function render($user, $event) { $result = FALSE; if ($user->getTxCalendardisplayAdmin() || $event->getPurchaser()->getUid() == $user->getUid()) { $result = TRUE; } return $result; }
/** * If the given event is valid * * @param Tx_CalendarDisplay_Domain_Model_Event $event * @return boolean true */ public function isValid($event) { $isValid = TRUE; if ($event->getTimeBegin() == NULL || $event->getTimeBegin() == '') { $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_calendardisplay_domain_model_event.time_begin.required', 'CalendarDisplay'), 2); $isValid = FALSE; } if ($event->getTimeEnd() == NULL || $event->getTimeEnd() == '') { $this->addError(Tx_Extbase_Utility_Localization::translate('tx_calendardisplay_domain_model_event.time_end.required', 'CalendarDisplay'), 2); $isValid = FALSE; } return $isValid; }
/** * Define whether a resource should be displayed. * * @param Tx_CalendarDisplay_Domain_Model_Event $event * @param Tx_CalendarDisplay_Domain_Model_Resource $resource * @return boolean */ public function render($event, $resource) { $result = '0'; if ($event) { $bookings = $event->getBooking(); foreach ($bookings as $booking) { $_resource = $booking->getResources()->current(); if ($_resource->getUid() == $resource->getUid()) { $result = $booking->getNumber(); break; } } } return $result; }
/** * Deletes an existing Event * * @param Tx_CalendarDisplay_Domain_Model_Event $event the Event to be deleted * @return void */ public function deleteAction(Tx_CalendarDisplay_Domain_Model_Event $event) { // get current login user if it have right then add the new event $currentUser = $this->feUserRepository->findByUid(intval($GLOBALS['TSFE']->fe_user->user['uid'])); $getPurchaserId = $event->getPurchaser() ? $event->getPurchaser()->getUid() : NULL; if ($currentUser->getUid() == $getPurchaserId || $currentUser->getTxCalendardisplayAdmin() == 1) { // @bug Bookings are not deleted even if they seem attached to the event $this->eventRepository->remove($event); $this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('event_removed', 'CalendarDisplay')); } else { $this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('event_not_removed', 'CalendarDisplay')); } $this->redirect('list'); }