Ejemplo n.º 1
0
 /**
  * implements the hook processDatamap_afterDatabaseOperations that gets invoked
  * when a form in the backend was saved and written to the database.
  * 
  * Here we will do the caching of recurring events
  * 
  * @param string $status
  * @param string $table
  * @param integer $id
  * @param array $fieldArray
  * @param t3lib_TCEmain $tce
  */
 public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $tce)
 {
     $GLOBALS['LANG']->includeLLFile('EXT:cz_simple_cal/Resources/Private/Language/locallang_mod.xml');
     if ($table == 'tx_czsimplecal_domain_model_event') {
         //if: an event was changed
         if ($status == 'new') {
             // if: record is new
             $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager');
             $indexer = $objectManager->get('Tx_CzSimpleCal_Indexer_Event');
             // get the uid of the new record
             if (!is_numeric($id)) {
                 $id = $tce->substNEWwithIDs[$id];
             }
             // create the slug
             $event = $this->fetchEventObject($id);
             $event->generateSlug();
             $this->getEventRepository()->update($event);
             // index events
             $indexer->create($event);
             $this->addFlashMessage($GLOBALS['LANG']->getLL('flashmessages.tx_czsimplecal_domain_model_event.create'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
         } else {
             if ($this->haveFieldsChanged(Tx_CzSimpleCal_Domain_Model_Event::getFieldsRequiringReindexing(), $fieldArray)) {
                 //if: record was updated and a value that requires re-indexing was changed
                 $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager');
                 $indexer = $objectManager->get('Tx_CzSimpleCal_Indexer_Event');
                 $indexer->update($id);
                 $this->addFlashMessage($GLOBALS['LANG']->getLL('flashmessages.tx_czsimplecal_domain_model_event.updateAndIndex'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
             } else {
                 $this->addFlashMessage($GLOBALS['LANG']->getLL('flashmessages.tx_czsimplecal_domain_model_event.updateNoIndex'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * build the exception timeline
  * 
  * @return Tx_CzSimpleCal_Recurrance_Timeline_Exception
  */
 protected function buildExceptionTimeline()
 {
     $exceptionTimeline = new Tx_CzSimpleCal_Recurrance_Timeline_Exception();
     foreach ($this->event->getExceptions() as $exception) {
         $type = $exception->getRecurranceType();
         if (empty($type)) {
             throw new RuntimeException('The recurrance_type should not be empty.');
         }
         $className = 'Tx_CzSimpleCal_Recurrance_Type_' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($type);
         if (!class_exists($className)) {
             throw new BadMethodCallException(sprintf('The class %s does not exist for creating recurring events.', $className));
         }
         $class = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className);
         if (!$class instanceof Tx_CzSimpleCal_Recurrance_Type_Base) {
             throw new BadMethodCallException(sprintf('The class %s does not implement Tx_CzSimpleCal_Recurrance_Type_Base.', get_class($class)));
         }
         $exceptionTimeline = $class->build($exception, $exceptionTimeline);
     }
     return $exceptionTimeline;
 }
Ejemplo n.º 3
0
 /**
  * create the indexes
  * 
  * @param Tx_CzSimpleCal_Domain_Model_Event $event
  */
 protected function doCreate($event)
 {
     $event->setLastIndexed(new DateTime());
     $this->eventRepository->update($event);
     if (!$event->isEnabled()) {
         return;
     }
     // get all recurrances...
     foreach ($event->getRecurrances() as $recurrance) {
         // ...and store them to the repository
         $instance = Tx_CzSimpleCal_Domain_Model_EventIndex::fromArray($recurrance);
         $this->eventIndexRepository->add($instance);
     }
     // store everything to database manually to allow correct unique hash creation when using scheduler
     //		$this->persistenceManager->persistAll();
 }
Ejemplo n.º 4
0
 public function testIsRecurrant()
 {
     $isRecurrant = $this->object->isRecurrant();
     self::assertTrue(is_bool($isRecurrant), 'isRecurrant returns a boolean');
 }
Ejemplo n.º 5
0
 /**
  * add the model id to an EventIndex
  * 
  * @param array $array
  * @return array
  */
 protected function addEvent($array)
 {
     $array['event'] = $this->event;
     $array['pid'] = $this->event->getPid();
     return $array;
 }
 /**
  * log if an event was created/updated/deleted to make this transparent in the backend
  *
  * @param Tx_CzSimpleCal_Domain_Model_Event $event
  * @param string $action the action (one of 1->'new', 2->'updated', 3->'delete')
  */
 protected function logEventLifecycle($event, $action)
 {
     $user = t3lib_div::makeInstance('t3lib_userAuthGroup');
     $actions = array(1 => 'added', 2 => 'edited', 3 => 'deleted');
     $user->writelog(1, $action, 0, 0, 'fe_user "%s" (%s) ' . $actions[$action] . ' the event "%s" (%s).', array($GLOBALS['TSFE']->fe_user->user['username'], $GLOBALS['TSFE']->fe_user->user['uid'], $event->getTitle(), $event->getUid()), 'tx_czsimplecal_domain_model_event', $event->getUid(), null, $event->getPid());
 }