Esempio n. 1
0
 function saveCalendar($pid)
 {
     $crdate = time();
     $insertFields = array('pid' => $this->conf['rights.']['create.']['calendar.']['saveCalendarToPid'] ? $this->conf['rights.']['create.']['calendar.']['saveCalendarToPid'] : $pid, 'tstamp' => $crdate, 'crdate' => $crdate);
     // TODO: Check if all values are correct
     $this->searchForAdditionalFieldsToAddFromPostData($insertFields, 'calendar');
     $this->retrievePostData($insertFields);
     // Creating DB records
     $insertFields['cruser_id'] = $this->rightsObj->getUserId();
     $insertFields['owner_ids'] = strip_tags($this->controller->piVars['owner_ids']);
     $insertFields['freeAndBusyUser_ids'] = strip_tags($this->controller->piVars['freeAndBusyUser_ids']);
     $uid = $this->_saveCalendar($insertFields);
     if ($this->rightsObj->isAllowedToCreateCalendarType()) {
         $this->checkOnNewOrDeletableFiles('tx_cal_calendar', 'ics_file', $insertFields, $uid);
     }
     $this->unsetPiVars();
     \TYPO3\CMS\Cal\Utility\Functions::clearCache();
     return $this->find($uid, $this->conf['pidList']);
 }
Esempio n. 2
0
 function updateEvents($uid, $pid, $urlString, $md5, $cruser_id)
 {
     $urls = GeneralUtility::trimExplode("\n", $urlString, 1);
     $mD5Array = array();
     $contentArray = array();
     foreach ($urls as $key => $url) {
         /* If the calendar has a URL, get a checksum on the contents */
         if ($url != '') {
             $contents = GeneralUtility::getURL($url);
             $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_icalendar_service', 'importIcsContent', 'service');
             // Hook: configuration
             foreach ($hookObjectsArr as $hookObj) {
                 if (method_exists($hookObj, 'importIcsContent')) {
                     $hookObj->importIcsContent($contents);
                 }
             }
             $mD5Array[$key] = md5($contents);
             $contentArray[$key] = $contents;
         }
     }
     $newMD5 = md5(implode('', $mD5Array));
     /* If the calendar has changed */
     if ($newMD5 != $md5) {
         $notInUids = array();
         foreach ($contentArray as $contents) {
             /* Parse the contents into ICS data structure */
             $iCalendar = $this->getiCalendarFromICSFile($contents);
             /* Create new events belonging to the specified calendar */
             $notInUids = array_merge($notInUids, $this->insertCalEventsIntoDB($iCalendar->_components, $uid, $pid, $cruser_id));
         }
         $notInUids = array_unique($notInUids);
         /* Delete old events, that have not been updated */
         $this->deleteTemporaryEvents($uid, $notInUids);
         \TYPO3\CMS\Cal\Utility\Functions::clearCache();
         return $newMD5;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 function removeEvent($uid)
 {
     $event = $this->find($uid, $this->conf['pidList'], true, true);
     if (is_object($event) && $event->isUserAllowedToDelete()) {
         $config = $this->conf['calendar'];
         $this->conf['calendar'] = intval($this->controller->piVars['calendar_id']);
         $event = $this->find($uid, $this->conf['pidList'], true, true);
         $this->conf['calendar'] = $config;
         $updateFields = array('tstamp' => time(), 'deleted' => 1);
         $table = 'tx_cal_event';
         $where = 'uid = ' . $uid;
         $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $where, $updateFields);
         $fields = $event->getValuesAsArray();
         $fields['deleted'] = 1;
         $fields['tstamp'] = $updateFields['tstamp'];
         $this->_notify($fields);
         $this->stopReminder($uid);
         /** @var \TYPO3\CMS\Cal\Utility\RecurrenceGenerator $rgc */
         $rgc = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Utility\\RecurrenceGenerator');
         $rgc->cleanIndexTableOfUid($uid, $table);
         // Hook: removeEvent
         $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_todo_service', 'todoServiceClass');
         \TYPO3\CMS\Cal\Utility\Functions::executeHookObjectsFunction($hookObjectsArr, 'removeTodo', $this, $event);
         \TYPO3\CMS\Cal\Utility\Functions::clearCache();
         $this->unsetPiVars();
     }
 }
Esempio n. 4
0
 function saveExceptionEvent($pid)
 {
     $crdate = time();
     $insertFields = array('pid' => $pid, 'tstamp' => $crdate, 'crdate' => $crdate);
     // TODO: Check if all values are correct
     if ($this->controller->piVars['exception_start_day'] != '') {
         $insertFields['start_date'] = strip_tags($this->controller->piVars['exception_start_day']);
     } else {
         return;
     }
     if ($this->controller->piVars['exception_end_day'] != '') {
         $insertFields['end_date'] = strip_tags($this->controller->piVars['exception_end_day']);
     }
     if ($this->controller->piVars['exception_title'] != '') {
         $insertFields['title'] = strip_tags($this->controller->piVars['exception_title']);
     }
     // Creating DB records
     $insertFields['cruser_id'] = $this->rightsObj->getUserId();
     $insertFields['fe_cruser_id'] = $this->rightsObj->getUserId();
     if ($insertFields['title'] == '') {
         $insertFields['title'] = strip_tags($this->controller->piVars['exception_start_day']) . ' exception';
     }
     $table = 'tx_cal_exception_event';
     $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields);
     if (FALSE === $result) {
         throw new \RuntimeException('Could not write exception event record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458134);
     }
     $uid = $GLOBALS['TYPO3_DB']->sql_insert_id();
     $this->insertIdsIntoTableWithMMRelation('tx_cal_exception_event_mm', array($uid), intval($this->controller->piVars['event_uid']), 'tx_cal_exception_event');
     $this->unsetPiVars();
     \TYPO3\CMS\Cal\Utility\Functions::clearCache();
 }
Esempio n. 5
0
 private function checkAction()
 {
     switch ($this->controller->piVars['adminAction']) {
         case 'editCalendarSubscription':
             $table = 'fe_users';
             $where = 'uid = ' . $this->rightsObj->getUserId();
             $ids = is_array($this->controller->piVars['calendarSubscription']) ? $this->controller->piVars['calendarSubscription'] : ($this->controller->piVars['calendarSubscription'] != '' ? \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->controller->piVars['calendarSubscription'], 1) : array());
             $allIds = $this->controller->piVars['calendarSubscriptionIds'] ? \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->controller->piVars['calendarSubscriptionIds'], 1) : array();
             $fields = array('tx_cal_calendar_subscription' => implode(',', array_diff($allIds, $ids)));
             $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $where, $fields);
             $this->conf['calendar'] = $this->conf['view.']['calendar'] = $this->conf['view.']['allowedCalendar'] = $this->conf['category'] = $this->conf['view.']['category'] = $this->conf['view.']['allowedCategory'] = '';
             $this->controller->checkCalendarAndCategory();
             unset($this->controller->piVars['calendarSubscription']);
             \TYPO3\CMS\Cal\Utility\Functions::clearCache();
             break;
     }
 }