public function scheduleReminder($calEventUID) { // Get complete record $eventRecord = BackendUtility::getRecord('tx_cal_event', $calEventUID); // get the related monitoring records $taskId = null; $offset = 0; $select = '*'; $table = 'tx_cal_fe_user_event_monitor_mm'; $where = 'uid_local = ' . $calEventUID; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $taskId = $row['schedulerId']; $offset = $row['offset']; // maybe there is a recurring instance // get the uids of recurring events from index $now = new \TYPO3\CMS\Cal\Model\CalDate(); $now->setTZbyId('UTC'); $now->addSeconds($offset * 60); $startDateTimeObject = new \TYPO3\CMS\Cal\Model\CalDate($eventRecord['start_date'] . '000000'); $startDateTimeObject->setTZbyId('UTC'); $startDateTimeObject->addSeconds($eventRecord['start_time']); $start_datetime = $startDateTimeObject->format('%Y%m%d%H%M%S'); $select2 = '*'; $table2 = 'tx_cal_index'; $where2 = 'start_datetime >= ' . $now->format('%Y%m%d%H%M%S') . ' AND event_uid = ' . $calEventUID; $orderby2 = 'start_datetime asc'; $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select2, $table2, $where2, $orderby2); if ($result) { $tmp = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2); if (is_array($tmp)) { $start_datetime = $tmp['start_datetime']; $nextOccuranceTime = new \TYPO3\CMS\Cal\Model\CalDate($tmp['start_datetime']); $nextOccuranceTime->setTZbyId('UTC'); $nextOccuranceEndTime = new \TYPO3\CMS\Cal\Model\CalDate($tmp['end_datetime']); $nextOccuranceEndTime->setTZbyId('UTC'); $eventRecord['start_date'] = $nextOccuranceTime->format('%Y%m%d'); $eventRecord['start_time'] = $nextOccuranceTime->getHour() * 3600 + $nextOccuranceTime->getMinute() * 60 + $nextOccuranceTime->getSecond(); $eventRecord['end_date'] = $nextOccuranceEndTime->format('%Y%m%d'); $eventRecord['end_time'] = $nextOccuranceEndTime->getHour() * 3600 + $nextOccuranceEndTime->getMinute() * 60 + $nextOccuranceEndTime->getSecond(); } $GLOBALS['TYPO3_DB']->sql_free_result($result2); } if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('scheduler')) { $scheduler = new \TYPO3\CMS\Scheduler\Scheduler(); $date = new \TYPO3\CMS\Cal\Model\CalDate($start_datetime); $date->setTZbyId('UTC'); $timestamp = $date->getTime(); $offsetTime = new \TYPO3\CMS\Cal\Model\CalDate(); $offsetTime->copy($date); $offsetTime->setTZbyId('UTC'); $offsetTime->addSeconds(-1 * $offset * 60); if ($taskId > 0) { if ($offsetTime->isFuture()) { try { $task = $scheduler->fetchTask($taskId); $execution = new \TYPO3\CMS\Scheduler\Execution(); $execution->setStart($timestamp - $offset * 60); $execution->setIsNewSingleExecution(true); $execution->setMultiple(false); $execution->setEnd(time() - 1); $task->setExecution($execution); $task->setDisabled(false); $scheduler->saveTask($task); } catch (OutOfBoundsException $e) { $this->createSchedulerTask($scheduler, $date, $calEventUID, $timestamp, $offset, $row['uid']); } } else { $this->deleteReminder($calEventUID); } } else { // taskId == 0 -> schedule task $this->createSchedulerTask($scheduler, $date, $calEventUID, $timestamp, $offset, $row['uid']); } } } }
/** * * @param * array iCalendar component array * @return array */ function insertCalEventsIntoDB($iCalendarComponentArray = array(), $calId, $pid = '', $cruserId = '', $isTemp = 1, $deleteNotUsedCategories = true) { $insertedOrUpdatedEventUids = array(); $insertedOrUpdatedCategoryUids = array(); if (empty($iCalendarComponentArray)) { return $insertedOrUpdatedEventUids; } $offsetArray = array(); foreach ($iCalendarComponentArray as $component) { $table = 'tx_cal_event'; $insertFields = array(); $insertFields['isTemp'] = $isTemp; $insertFields['tstamp'] = time(); $insertFields['crdate'] = time(); $insertFields['pid'] = $pid; if (is_a($component, '\\TYPO3\\CMS\\Cal\\Model\\ICalendar\\vevent')) { $insertFields['cruser_id'] = $cruserId; $insertFields['calendar_id'] = $calId; if ($component->getAttribute('DTSTART')) { $startdate = $component->getAttribute('DTSTART'); if (is_array($startdate)) { $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($startdate['year'] . $startdate['month'] . $startdate['mday'] . '000000'); } else { $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($startdate); } $params = $component->getAttributeParameters('DTSTART'); $timezone = $params['TZID']; if ($timezone) { $dateTime->convertTZbyID($timezone); } $insertFields['start_date'] = $dateTime->format('%Y%m%d'); $insertFields['start_time'] = $dateTime->hour * 3600 + $dateTime->minute * 60; } else { continue; } if ($component->getAttribute('DTEND')) { $enddate = $component->getAttribute('DTEND'); if (is_array($enddate)) { $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($enddate['year'] . $enddate['month'] . $enddate['mday'] . '000000'); } else { $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($enddate); } $params = $component->getAttributeParameters('DTEND'); $timezone = $params['TZID']; if ($timezone) { $dateTime->convertTZbyID($timezone); } $insertFields['end_date'] = $dateTime->format('%Y%m%d'); $insertFields['end_time'] = $dateTime->hour * 3600 + $dateTime->minute * 60; } if ($component->getAttribute('DURATION')) { $enddate = $insertFields['start_time'] + $component->getAttribute('DURATION'); $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['start_date']); $dateTime->addSeconds($enddate); $params = $component->getAttributeParameters('DURATION'); $timezone = $params['TZID']; if ($timezone) { $dateTime->convertTZbyID($timezone); } $insertFields['end_date'] = $dateTime->format('%Y%m%d'); $insertFields['end_time'] = $dateTime->hour * 3600 + $dateTime->minute * 60; } $insertFields['icsUid'] = $component->getAttribute('UID'); $insertFields['title'] = $component->getAttribute('SUMMARY'); if ($component->organizerName()) { $insertFields['organizer'] = str_replace('"', '', $component->organizerName()); } $insertFields['location'] = $component->getAttribute('LOCATION'); if ($insertFields['location'] == null) { $insertFields['location'] = ''; } $insertFields['description'] = $component->getAttribute('DESCRIPTION'); $categoryString = $component->getAttribute('CATEGORY'); if ($categoryString == "") { $categoryString = $component->getAttribute('CATEGORIES'); } $categories = GeneralUtility::trimExplode(',', $categoryString, 1); $categoryUids = array(); foreach ($categories as $category) { $category = trim($category); $categorySelect = '*'; $categoryTable = 'tx_cal_category'; $categoryWhere = 'calendar_id = ' . intval($calId) . ' AND title =' . $GLOBALS['TYPO3_DB']->fullQuoteStr($category, $categoryTable); $foundCategory = false; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($categorySelect, $categoryTable, $categoryWhere); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $foundCategory = true; $categoryUids[] = $row['uid']; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } if (!$foundCategory) { $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($categoryTable, array('tstamp' => $insertFields['tstamp'], 'crdate' => $insertFields['crdate'], 'pid' => $pid, 'title' => $category, 'calendar_id' => $calId)); if (FALSE === $result) { throw new \RuntimeException('Could not write ' . $categoryTable . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458143); } $categoryUids[] = $GLOBALS['TYPO3_DB']->sql_insert_id(); } } if ($component->getAttribute('RRULE')) { $rrule = $component->getAttribute('RRULE'); $this->insertRuleValues($rrule, $insertFields); } if ($component->getAttribute('RDATE')) { $rdate = $component->getAttribute('RDATE'); if (is_array($rdate)) { $insertFields['rdate'] = implode(',', $rdate); } else { $insertFields['rdate'] = $rdate; } if ($component->getAttributeParameters('RDATE')) { $parameterArray = $component->getAttributeParameters('RDATE'); $keys = array_keys($parameterArray); $insertFields['rdate_type'] = strtolower($keys[0]); } else { $insertFields['rdate_type'] = 'date_time'; } } // Fix for allday events if ($insertFields['start_time'] == 0 && $insertFields['end_time'] == 0) { $date = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['end_date'] . '000000'); $date->setTZbyId('UTC'); $date->subtractSeconds(86400); $insertFields['end_date'] = $date->format('%Y%m%d'); } $eventRow = BackendUtility::getRecordRaw('tx_cal_event', 'icsUid="' . $insertFields['icsUid'] . '"'); if ($eventRow['uid']) { $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . $eventRow['uid'], $insertFields); $eventUid = $eventRow['uid']; } else { $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields); if (FALSE === $result) { throw new \RuntimeException('Could not write ' . $table . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458144); } $eventUid = $GLOBALS['TYPO3_DB']->sql_insert_id(); } $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']); if ($component->getAttribute('RECURRENCE-ID')) { $recurrenceIdStart = new \TYPO3\CMS\Cal\Model\CalDate($component->getAttribute('RECURRENCE-ID')); $params = $component->getAttributeParameters('RECURRENCE-ID'); $timezone = $params['TZID']; if ($timezone) { $recurrenceIdStart->convertTZbyID($timezone); } $indexEntry = BackendUtility::getRecordRaw('tx_cal_index', 'event_uid="' . $eventUid . '" AND start_datetime="' . $recurrenceIdStart->format('%Y%m%d%H%M%S') . '"'); if ($indexEntry) { $origStartDate = new \TYPO3\CMS\Cal\Model\CalDate(); $origStartDate = new \TYPO3\CMS\Cal\Model\CalDate(); $table = 'tx_cal_event_deviation'; $insertFields['parentid'] = $eventUid; $insertFields['orig_start_time'] = $recurrenceIdStart->getHour() * 3600 + $recurrenceIdStart->getMinute() * 60; $recurrenceIdStart->setHour(0); $recurrenceIdStart->setMinute(0); $recurrenceIdStart->setSecond(0); $insertFields['orig_start_date'] = $recurrenceIdStart->getTime(); unset($insertFields['calendar_id']); if ($indexEntry['event_deviation_uid'] > 0) { $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . $indexEntry['event_deviation_uid'], $insertFields); $eventDeviationUid = $indexEntry['event_deviation_uid']; } else { $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields); if (FALSE === $result) { throw new \RuntimeException('Could not write ' . $table . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458145); } $eventDeviationUid = $GLOBALS['TYPO3_DB']->sql_insert_id(); } $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_cal_index', 'uid=' . $indexEntry['uid'], array('event_deviation_uid' => $eventDeviationUid)); } } else { /* Delete the old exception relations */ $exceptionEventUidsToBeDeleted = array(); $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_exception_event.uid', 'tx_cal_exception_event,tx_cal_exception_event_mm', 'tx_cal_exception_event.uid = tx_cal_exception_event_mm.uid_foreign AND tx_cal_exception_event_mm.uid_local=' . $eventUid); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $exceptionEventUidsToBeDeleted[] = $row['uid']; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } if (!empty($exceptionEventUidsToBeDeleted)) { $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event', 'uid in (' . implode(',', $exceptionEventUidsToBeDeleted) . ')'); } $exceptionEventGroupUidsToBeDeleted = array(); $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_exception_event_group.uid', 'tx_cal_exception_event_group,tx_cal_exception_event_group_mm', 'tx_cal_exception_event_group.uid = tx_cal_exception_event_group_mm.uid_foreign AND tx_cal_exception_event_group_mm.uid_local=' . $eventUid); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $exceptionEventGroupUidsToBeDeleted[] = $row['uid']; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } if (!empty($exceptionEventGroupUidsToBeDeleted)) { $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event_group', 'uid in (' . implode(',', $exceptionEventGroupUidsToBeDeleted) . ')'); } $where = ' uid_local=' . $eventUid; $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event_mm', $where); $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event_group_mm', $where); // Exceptions: if ($component->getAttribute('EXDATE')) { if (is_array($component->getAttribute('EXDATE'))) { foreach ($component->getAttribute('EXDATE') as $exceptionDescription) { $this->createException($pid, $cruserId, $eventUid, $exceptionDescription); } } else { $this->createException($pid, $cruserId, $eventUid, $component->getAttribute('EXDATE')); } } if ($component->getAttribute('EXRULE')) { if (is_array($component->getAttribute('EXRULE'))) { foreach ($component->getAttribute('EXRULE') as $exceptionDescription) { $this->createExceptionRule($pid, $cruserId, $eventUid, $exceptionDescription); } } else { $this->createExceptionRule($pid, $cruserId, $eventUid, $component->getAttribute('EXRULE')); } } $pageTSConf = BackendUtility::getPagesTSconfig($pid); if ($pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']) { $pageIDForPlugin = $pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']; } else { $pageIDForPlugin = $pid; } /** @var \TYPO3\CMS\Cal\Utility\RecurrenceGenerator $rgc */ $rgc = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Utility\\RecurrenceGenerator', $pageIDForPlugin); $rgc->generateIndexForUid($eventUid, 'tx_cal_event'); if ($this->conf['view.']['event.']['remind']) { /* Schedule reminders for new and changed events */ $pageTSConf = BackendUtility::getPagesTSconfig($pid); $offset = is_numeric($pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time']) ? $pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time'] * 60 : 0; $date = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['start_date'] . '000000'); $date->setTZbyId('UTC'); $reminderTimestamp = $date->getTime() + $insertFields['start_time'] - $offset; $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); $reminderService->scheduleReminder($eventUid); } /* Delete the old category relations */ $where = ' uid_local=' . $eventUid; $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_event_category_mm', $where); foreach ($categoryUids as $uid) { $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_cal_event_category_mm', array('uid_local' => $eventUid, 'uid_foreign' => $uid)); if (FALSE === $result) { throw new \RuntimeException('Could not write tx_cal_event_category_mm record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458146); } } $insertedOrUpdatedEventUids[] = $eventUid; $insertedOrUpdatedCategoryUids = array_merge($insertedOrUpdatedCategoryUids, $categoryUids); // Hook: insertCalEventsIntoDB $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_icalendar_service', 'iCalendarServiceClass', 'service'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'insertCalEventsIntoDB')) { $hookObj->insertCalEventsIntoDB($this, $eventUid, $component); } } } } } if ($deleteNotUsedCategories) { /* Delete the categories */ $where = ' calendar_id=' . $calId; if (!empty($insertedOrUpdatedCategoryUids)) { array_unique($insertedOrUpdatedCategoryUids); $where .= ' AND uid NOT IN (' . implode(',', $insertedOrUpdatedCategoryUids) . ')'; } $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']); $GLOBALS['TYPO3_DB']->exec_DELETEquery($extConf['categoryService'], $where); } return $insertedOrUpdatedEventUids; }
public function getEventsColumnMarker(&$template, &$sims, &$rems, &$wrapped, $view) { $content = ''; $conf =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'conf'); $dayStart = $conf['view.']['day.']['dayStart']; // '0700'; // Start time for day grid $dayEnd = $conf['view.']['day.']['dayEnd']; // '2300'; // End time for day grid $gridLength = $conf['view.']['day.']['gridLength']; // '15'; // Grid distance in minutes for day view, multiples of 15 preferred while (strlen($dayStart) < 6) { $dayStart .= '0'; } while (strlen($dayEnd) < 6) { $dayEnd .= '0'; } if ($gridLength == 0) { $gridLength = 15; } $d_start = new \TYPO3\CMS\Cal\Model\CalDate($this->Ymd . $dayStart); $d_start->setTZbyId('UTC'); $d_end = new \TYPO3\CMS\Cal\Model\CalDate($this->Ymd . $dayEnd); $d_end->setTZbyId('UTC'); // splitting the events into H:M, to find out if events run in parallel $i = new \TYPO3\CMS\Cal\Model\CalDate(); $eventArray = array(); $viewArray = array(); $positionArray = array(); $timeKeys = array_keys($this->events); // Sort by starttime, otherwise $pos_array keys may be assigned multiple times and events may therefore overwrite each other asort($timeKeys); foreach ($timeKeys as $timeKey) { $eventKeys = array_keys($this->events[$timeKey]); foreach ($eventKeys as $eventKey) { if (!$this->events[$timeKey][$eventKey]->isAllday() && $this->events[$timeKey][$eventKey]->getStart()->format('%Y%m%d') == $this->events[$timeKey][$eventKey]->getEnd()->format('%Y%m%d')) { $eventMappingKey = $this->events[$timeKey][$eventKey]->getType() . '_' . $this->events[$timeKey][$eventKey]->getUid() . '_' . $this->events[$timeKey][$eventKey]->getStart()->format('%Y%m%d%H%M%S'); $eventArray[$eventMappingKey] =& $this->events[$timeKey][$eventKey]; $i->copy($this->events[$timeKey][$eventKey]->getStart()); $time = $i->getTime(); $time = $time - $time % ($gridLength * 60); $i = new \TYPO3\CMS\Cal\Model\CalDate($time); if ($i->before($d_start)) { $i->copy($d_start); } $entries = 0; for (; $i->before($this->events[$timeKey][$eventKey]->getEnd()); $i->addSeconds($gridLength * 60)) { $ymd = $i->format('%Y%m%d'); $hm = $i->format('%H%M'); $viewArray[$ymd][$hm][] = $eventMappingKey; $entries++; $count = count($viewArray[$ymd][$hm]); foreach ($viewArray[$ymd][$hm] as $mappingKey) { if (!$positionArray[$mappingKey] || $positionArray[$mappingKey] < $count) { $positionArray[$mappingKey] = $count; } } } $rowspan_array[$this->Ymd][$eventMappingKey] = $entries; } } } if (!empty($viewArray[$this->Ymd])) { $max = array(); foreach ($viewArray[$this->Ymd] as $array_time => $time_val) { $c = count($viewArray[$this->Ymd][$array_time]); array_push($max, $c); } $nbrGridCols = max($max); } else { $nbrGridCols = 1; } // splitting the events into H:M, to find out if events run in parallel $pos_array = array(); $i->copy($d_start); $t_array = array(); while ($i->before($d_end)) { $i_formatted = $i->format('%H%M'); if (is_array($viewArray[$this->Ymd][$i_formatted]) && count($viewArray[$this->Ymd][$i_formatted]) > 0) { foreach ($viewArray[$this->Ymd][$i_formatted] as $eventKey) { $event =& $eventArray[$eventKey]; $eventStart = $event->getStart(); $eventMappingKey = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M%S'); if (array_key_exists($eventMappingKey, $pos_array)) { $eventEnd = $event->getEnd(); $eventEnd->subtractSeconds($eventEnd->getMinute() % $gridLength * 60); if ($i_formatted >= $eventEnd->format('%H%M')) { $t_array[$i_formatted][$pos_array[$eventMappingKey]] = array('ended' => $eventMappingKey); } else { $t_array[$i_formatted][$pos_array[$eventMappingKey]] = array('started' => $eventMappingKey); } } else { for ($j = 0; $j < $nbrGridCols; $j++) { if (count($t_array[$i_formatted][$j]) == 0 || !isset($t_array[$i_formatted][$j])) { $pos_array[$eventMappingKey] = $j; $t_array[$i_formatted][$j] = array('begin' => $eventMappingKey); break; } } } } } else { $t_array[$i_formatted] = ''; } $i->addSeconds($gridLength * 60); } $sims['###EVENTS_COLUMN###'] = $this->renderEventsColumn($eventArray, $d_start, $d_end, $viewArray, $t_array, $positionArray); }
function formatDate($ymdDate, $format) { if ($ymdDate) { $dateObj = new \TYPO3\CMS\Cal\Model\CalDate(intval($ymdDate) . '000000'); $dateObj->setTZbyId('UTC'); return $dateObj->getTime(); } else { $dateString = ''; } return $dateString; }
function replaceViewMarker($page) { $next_day = new \TYPO3\CMS\Cal\Model\CalDate(); $next_day->copy($this->controller->getDateTimeObject); $next_day->addSeconds(86400); $prev_day = new \TYPO3\CMS\Cal\Model\CalDate(); $prev_day->copy($this->controller->getDateTimeObject); $prev_day->subtractSeconds(86400); $next_week = new \TYPO3\CMS\Cal\Model\CalDate(Calc::beginOfNextWeek($this->conf['day'], $this->conf['month'], $this->conf['year'])); $prev_week = new \TYPO3\CMS\Cal\Model\CalDate(Calc::beginOfPrevWeek($this->conf['day'], $this->conf['month'], $this->conf['year'])); $next_year = $this->conf['year'] + 1 . sprintf("%02d", $this->conf['month']) . sprintf("%02d", $this->conf['day']); $prev_year = $this->conf['year'] - 1 . sprintf("%02d", $this->conf['month']) . sprintf("%02d", $this->conf['day']); $endOfNextMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfNextMonth($this->conf['day'], $this->conf['month'], $this->conf['year'])); $endOfNextMonth->setDay($this->conf['day']); $startOfPrevMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfPrevMonth($this->conf['day'], $this->conf['month'], $this->conf['year'])); $startOfPrevMonth->setDay($this->conf['day']); $next_month = $endOfNextMonth->format('%Y%m%d'); $prev_month = $startOfPrevMonth->format('%Y%m%d'); $startOfThisWeek = new \TYPO3\CMS\Cal\Model\CalDate(Calc::beginOfWeek($this->conf['day'], $this->conf['month'], $this->conf['year'])); $endOfThisWeek = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfWeek($this->conf['day'], $this->conf['month'], $this->conf['year'])); $GLOBALS['TSFE']->register['cal_week_starttime'] = $startOfThisWeek->getTime(); $GLOBALS['TSFE']->register['cal_week_endtime'] = $endOfThisWeek->getTime(); $this->initLocalCObject(); $dayViewPid = $this->conf['view.']['day.']['dayViewPid'] ? $this->conf['view.']['day.']['dayViewPid'] : false; $weekViewPid = $this->conf['view.']['week.']['weekViewPid'] ? $this->conf['view.']['week.']['weekViewPid'] : false; $monthViewPid = $this->conf['view.']['month.']['monthViewPid'] ? $this->conf['view.']['month.']['monthViewPid'] : false; $yearViewPid = $this->conf['view.']['year.']['yearViewPid'] ? $this->conf['view.']['year.']['yearViewPid'] : false; // next day $nextdaylinktext = $this->cObj->getSubpart($page, '###NEXT_DAYLINKTEXT###'); $this->local_cObj->setCurrentVal($nextdaylinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $next_day->format('%Y%m%d'), 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $dayViewPid); $rems['###NEXT_DAYLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['day.']['nextDayLink'], $this->conf['view.']['day.']['nextDayLink.']); // prev day $prevdaylinktext = $this->cObj->getSubpart($page, '###PREV_DAYLINKTEXT###'); $this->local_cObj->setCurrentVal($prevdaylinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $prev_day->format('%Y%m%d'), 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $dayViewPid); $rems['###PREV_DAYLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['day.']['prevDayLink'], $this->conf['view.']['day.']['prevDayLink.']); // next week $nextweeklinktext = $this->cObj->getSubpart($page, '###NEXT_WEEKLINKTEXT###'); $this->local_cObj->setCurrentVal($nextweeklinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $next_week->format('%Y%m%d'), 'view' => $this->conf['view.']['weekLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $weekViewPid); $rems['###NEXT_WEEKLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['nextWeekLink'], $this->conf['view.']['week.']['nextWeekLink.']); // prev week $prevweeklinktext = $this->cObj->getSubpart($page, '###PREV_WEEKLINKTEXT###'); $this->local_cObj->setCurrentVal($prevweeklinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $prev_week->format('%Y%m%d'), 'view' => $this->conf['view.']['weekLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $weekViewPid); $rems['###PREV_WEEKLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['prevWeekLink'], $this->conf['view.']['week.']['prevWeekLink.']); // next month $nextmonthlinktext = $this->cObj->getSubpart($page, '###NEXT_MONTHLINKTEXT###'); $this->local_cObj->setCurrentVal($nextmonthlinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $next_month, 'view' => $this->conf['view.']['monthLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $monthViewPid); $rems['###NEXT_MONTHLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['month.']['nextMonthLink'], $this->conf['view.']['month.']['nextMonthLink.']); // prev month $prevmonthlinktext = $this->cObj->getSubpart($page, '###PREV_MONTHLINKTEXT###'); $this->local_cObj->setCurrentVal($prevmonthlinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $prev_month, 'view' => $this->conf['view.']['monthLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $monthViewPid); $rems['###PREV_MONTHLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['month.']['prevMonthLink'], $this->conf['view.']['month.']['prevMonthLink.']); // next year $nextyearlinktext = $this->cObj->getSubpart($page, '###NEXT_YEARLINKTEXT###'); $this->local_cObj->setCurrentVal($nextyearlinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $next_year, 'view' => $this->conf['view.']['yearLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $yearViewPid); $rems['###NEXT_YEARLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['year.']['nextYearLink'], $this->conf['view.']['year.']['nextYearLink.']); // prev year $prevyearlinktext = $this->cObj->getSubpart($page, '###PREV_YEARLINKTEXT###'); $this->local_cObj->setCurrentVal($prevyearlinktext); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $prev_year, 'view' => $this->conf['view.']['yearLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $yearViewPid); $rems['###PREV_YEARLINK###'] = $this->local_cObj->cObjGetSingle($this->conf['view.']['year.']['prevYearLink'], $this->conf['view.']['year.']['prevYearLink.']); $this->local_cObj->setCurrentVal($this->controller->getDateTimeObject->getTime()); $sims['###DISPLAY_DATE###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$this->conf['view'] . '.']['displayDate'], $this->conf['view.'][$this->conf['view'] . '.']['displayDate.']); $wrapped = array(); $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_base_model', 'searchForObjectMarker', 'model'); // Hook: postSearchForObjectMarker foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'postSearchForObjectMarker')) { $hookObj->postSearchForObjectMarker($this, $page, $sims, $rems, $wrapped, $this->conf['view']); } } $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, array()); $languageArray = array('getdate' => $this->conf['getdate'], 'next_month' => $next_month, 'prev_month' => $prev_month, 'calendar_name' => $this->conf['calendarName'], 'this_year' => $this->conf['year'], 'next_year' => $next_year, 'prev_year' => $prev_year); return \TYPO3\CMS\Cal\Controller\Controller::replace_tags($languageArray, $page); }
function getSubscriptionMarker(&$template, &$sims, &$rems, &$wrapped, $view) { $uid = $this->conf['uid']; $type = $this->conf['type']; $monitoring = $this->conf['monitor']; $getdate = $this->conf['getdate']; $captchaStr = 0; $rems['###SUBSCRIPTION###'] = ''; $sims['###NOTLOGGEDIN_NOMONITORING_HEADING###'] = ''; $sims['###NOTLOGGEDIN_NOMONITORING_SUBMIT###'] = ''; $sims['###NOTLOGGEDIN_MONITORING_HEADING###'] = ''; $sims['###NOTLOGGEDIN_MONITORING_SUBMIT###'] = ''; $sims_temp['L_CAPTCHA_START_SUCCESS'] = ''; $sims_temp['L_CAPTCHA_STOP_SUCCESS'] = ''; // controller = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','controller'); $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller'); // cObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','cobj'); $cObj =& $this->controller->cObj; if (($this->conf['allowSubscribe'] == 1 || $this->conf['subscribeFeUser'] == 1 && $rightsObj->isLoggedIn()) && $uid) { if ($monitoring != null && $monitoring != '') { $user_uid = $rightsObj->getUserId(); switch ($monitoring) { case 'start': if ($user_uid > 0) { $table = 'tx_cal_fe_user_event_monitor_mm'; $fields_values = array('uid_local' => $uid, 'uid_foreign' => $user_uid, 'tablenames' => 'fe_users', 'sorting' => 1, 'pid' => $this->conf['rights.']['create.']['event.']['saveEventToPid'], 'offset' => $this->conf['view.']['event.']['remind.']['time']); $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fields_values); if (FALSE === $result) { throw new \RuntimeException('Could not write ' . $table . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458137); } $pageTSConf = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($this->conf['rights.']['create.']['event.']['saveEventToPid']); $offset = is_numeric($pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time']) ? $pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time'] * 60 : 0; $date = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['start_date'] . '000000'); $date->setTZbyId('UTC'); $reminderTimestamp = $date->getTime() + $insertFields['start_time'] - $offset; $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); $reminderService->scheduleReminder($uid); } else { if ($this->conf['subscribeWithCaptcha'] == 1 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('captcha')) { session_start(); $captchaStr = $_SESSION['tx_captcha_string']; $_SESSION['tx_captcha_string'] = ''; } else { $captchaStr = -1; } if ($captchaStr && $this->controller->piVars['captcha'] === $captchaStr || $this->conf['subscribeWithCaptcha'] == 0) { // send confirm email!! $email = $this->controller->piVars['email']; $mailer = $mail = new \TYPO3\CMS\Core\Mail\MailMessage(); if (GeneralUtility::validEmail($this->conf['view.']['event.']['notify.']['emailAddress'])) { $mailer->setFrom(array($this->conf['view.']['event.']['notify.']['emailAddress'] => $this->conf['view.']['event.']['notify.']['fromName'])); } if (GeneralUtility::validEmail($this->conf['view.']['event.']['notify.']['emailReplyAddress'])) { $mailer->setReplyTo(array($this->conf['view.']['event.']['notify.']['emailReplyAddress'] => $this->conf['view.']['event.']['notify.']['replyToName'])); } $mailer->getHeaders()->addTextHeader('Organization: ', $this->conf['view.']['event.']['notify.']['organisation']); $local_template = $cObj->fileResource($this->conf['view.']['event.']['notify.']['confirmTemplate']); $htmlTemplate = $cObj->getSubpart($local_template, '###HTML###'); $plainTemplate = $cObj->getSubpart($local_template, '###PLAIN###'); $local_switch = array(); $local_rems = array(); $local_wrapped = array(); $this->getMarker($htmlTemplate, $local_switch, $local_rems, $local_wrapped, 'event'); $this->getMarker($plainTemplate, $local_switch, $local_rems, $local_wrapped, 'event'); $local_switch['###CONFIRM_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[monitor]' => 'start', 'tx_cal_controller[email]' => $email, 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[sid]' => md5($this->getUid() . $email . $this->getCreationDate()))); $local_switch['###EVENT_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['eventViewPid'], '', array('tx_cal_controller[view]' => 'event', 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[type]' => $this->getType(), 'tx_cal_controller[getdate]' => $this->getStart->format('%Y%m%d'))); $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $local_switch, $local_rems, $local_wrapped); $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $local_switch, $local_rems, $local_wrapped); $plainTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($plainTemplate, $local_switch, $local_rems, $local_wrapped); $mailer->setSubject($this->conf['view.']['event.']['notify.']['confirmTitle']); $rems['###SUBSCRIPTION###'] = $this->controller->pi_getLL('l_monitor_start_thanks'); $this->controller->finish($htmlTemplate); $this->controller->finish($plainTemplate); $mailer->setTo(array($email)); $mailer->setBody(strip_tags($plainTemplate), 'text/plain'); $mailer->addPart(\TYPO3\CMS\Cal\Utility\Functions::fixURI($htmlTemplate), 'text/html'); $mailer->send(); return; } else { $sims_temp['L_CAPTCHA_START_SUCCESS'] = $this->controller->pi_getLL('l_monitor_wrong_captcha'); } } break; case 'stop': if ($user_uid > 0) { $table = 'tx_cal_fe_user_event_monitor_mm'; $where = 'uid_foreign = ' . $user_uid . ' AND uid_local = ' . $uid . ' AND tablenames = "fe_users"'; $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, $where); } else { if ($this->conf['subscribeWithCaptcha'] == 1 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('captcha')) { session_start(); $captchaStr = $_SESSION['tx_captcha_string']; $_SESSION['tx_captcha_string'] = ''; } else { $captchaStr = -1; } if ($captchaStr && $this->controller->piVars['captcha'] === $captchaStr || $this->conf['subscribeWithCaptcha'] == 0) { $email = $this->controller->piVars['email']; $table = 'tx_cal_unknown_users'; $select = 'crdate'; $where = 'email = "' . $email . '"'; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); $crdate = 0; if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $crdate = $row['crdate']; break; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } $mailer = $mail = new \TYPO3\CMS\Core\Mail\MailMessage(); $mailer->setFrom(array($this->conf['view.']['event.']['notify.']['emailAddress'] => $this->conf['view.']['event.']['notify.']['fromName'])); $mailer->setReplyTo(array($this->conf['view.']['event.']['notify.']['emailReplyAddress'] => $this->conf['view.']['event.']['notify.']['replyToName'])); $mailer->getHeaders()->addTextHeader('Organization: ', $this->conf['view.']['event.']['notify.']['organisation']); $local_template = $cObj->fileResource($this->conf['view.']['event.']['notify.']['unsubscribeConfirmTemplate']); $htmlTemplate = $cObj->getSubpart($local_template, '###HTML###'); $plainTemplate = $cObj->getSubpart($local_template, '###PLAIN###'); $local_switch = array(); $local_rems = array(); $local_wrapped = array(); $this->getMarker($htmlTemplate, $local_switch, $local_rems, $local_wrapped, 'event'); $local_switch['###CONFIRM_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[email]' => $email, 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[sid]' => md5($this->getUid() . $email . $crdate))); $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $local_switch, $local_rems, $local_wrapped); $local_switch = array(); $local_rems = array(); $local_wrapped = array(); $this->getMarker($plainTemplate, $local_switch, $local_rems, $local_wrapped, 'event'); $local_switch['###CONFIRM_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[email]' => $email, 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[sid]' => md5($this->getUid() . $email . $crdate))); $plainTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($plainTemplate, $local_switch, $local_rems, $local_wrapped); $mailer->setSubject($this->conf['view.']['event.']['notify.']['unsubscribeConfirmTitle']); $rems['###SUBSCRIPTION###'] = $this->controller->pi_getLL('l_monitor_stop_thanks'); $this->controller->finish($htmlTemplate); $this->controller->finish($plainTemplate); $mailer->setTo(array($email)); $mailer->setBody(strip_tags($plainTemplate), 'text/plain'); $mailer->addPart(\TYPO3\CMS\Cal\Utility\Functions::fixURI($htmlTemplate), 'text/html'); $mailer->send(); return; } else { $sims_temp['L_CAPTCHA_STOP_SUCCESS'] = $this->controller->pi_getLL('l_monitor_wrong_captcha'); } } break; } } /* If we have a logged in user */ if ($rightsObj->isLoggedIn()) { $select = '*'; $from_table = 'tx_cal_fe_user_event_monitor_mm'; $whereClause = 'uid_foreign = ' . $rightsObj->getUserId() . ' AND uid_local = ' . $uid; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $from_table, $whereClause, $groupBy = '', $orderBy = '', $limit = ''); $found_one = false; // create a local cObj with a customized data array, that is allowed to be changed $this->initLocalCObject($this->getValuesAsArray()); $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_monitor_event_logged_in_monitoring')); if ($result) { while ($row1 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'event', 'monitor' => 'stop', 'type' => $type, 'uid' => $uid), $this->conf['cache'], $this->conf['clear_anyway']); $rems['###SUBSCRIPTION###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$view . '.']['event.']['isMonitoringEventLink'], $this->conf['view.'][$view . '.']['event.']['isMonitoringEventLink.']); $found_one = true; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } if (!$found_one) { $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_monitor_event_logged_in_nomonitoring')); $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'event', 'monitor' => 'start', 'type' => $type, 'uid' => $uid), $this->conf['cache'], $this->conf['clear_anyway']); $rems['###SUBSCRIPTION###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$view . '.']['event.']['isNotMonitoringEventLink'], $this->conf['view.'][$view . '.']['event.']['isNotMonitoringEventLink.']); } } else { /* Not a logged in user */ /* If a CAPTCHA is required to subscribe, add a couple extra markers */ if ($this->conf['subscribeWithCaptcha'] == 1 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('captcha')) { $sims_temp['CAPTCHA_SRC'] = '<img src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('captcha') . 'captcha/captcha.php' . '" alt="" />'; $sims_temp['L_CAPTCHA_TEXT'] = $this->controller->pi_getLL('l_captcha_text'); $sims_temp['CAPTCHA_TEXT'] = '<input type="text" size=10 name="tx_cal_controller[captcha]" value="">'; } else { $sims_temp['CAPTCHA_SRC'] = ''; $sims_temp['L_CAPTCHA_TEXT'] = ''; $sims_temp['CAPTCHA_TEXT'] = ''; } $notLoggedinNoMonitoring = $cObj->getSubpart($template, '###NOTLOGGEDIN_NOMONITORING###'); $parameter = array('no_cache' => 1, 'view' => 'event', 'monitor' => 'start', 'type' => $type, 'uid' => $uid); $actionUrl = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url($parameter)); $parameter2 = array('no_cache' => 1, 'getdate' => $getdate, 'view' => 'event', 'monitor' => 'stop'); $actionUrl2 = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url($parameter2)); $sims_temp['NOTLOGGEDIN_NOMONITORING_HEADING'] = $this->controller->pi_getLL('l_monitor_event_logged_in_nomonitoring'); $sims_temp['NOTLOGGEDIN_NOMONITORING_SUBMIT'] = $this->controller->pi_getLL('l_submit'); $sims_temp['L_ENTER_EMAIL'] = $this->controller->pi_getLL('l_enter_email'); $sims_temp['ACTIONURL'] = $actionUrl; $monitor = \TYPO3\CMS\Cal\Controller\Controller::replace_tags($sims_temp, $notLoggedinNoMonitoring); $sims_temp['ACTIONURL'] = $actionUrl2; $notLoggedinMonitoring = $cObj->getSubpart($template, '###NOTLOGGEDIN_MONITORING###'); $sims_temp['NOTLOGGEDIN_MONITORING_HEADING'] = $this->controller->pi_getLL('l_monitor_event_logged_in_monitoring'); $sims_temp['NOTLOGGEDIN_MONITORING_SUBMIT'] = $this->controller->pi_getLL('l_submit'); $sims_temp['L_ENTER_EMAIL'] = $this->controller->pi_getLL('l_enter_email'); $monitor .= \TYPO3\CMS\Cal\Controller\Controller::replace_tags($sims_temp, $notLoggedinMonitoring); $rems['###SUBSCRIPTION###'] = $monitor; } } else { $rems['###SUBSCRIPTION###'] = ''; } }
function getRecurringEventsFromIndex($event, $ex_event_dates = array()) { $maxRecurringEvents = (int) $this->conf['view.'][$this->conf['view'] . '.']['maxRecurringEvents']; $maxRecurringEvents = !empty($maxRecurringEvents) ? $maxRecurringEvents : 99999; $master_array = array(); $startDate = $event->getStart(); $dontShowOldEvents = (int) $this->conf['view.'][$this->conf['view'] . '.']['dontShowOldEvents']; if ($dontShowOldEvents > 0) { $now = new \TYPO3\CMS\Cal\Model\CalDate(); if ($dontShowOldEvents == 2) { $now->setHour(0); $now->setMinute(0); $now->setSecond(0); } if ($startDate->getTime() > $now->getTime() && !$ex_event_dates[$startDate->format('%Y%m%d')]) { $master_array[$startDate->format('%Y%m%d')][$event->isAllday() ? '-1' : $startDate->format('%H%M')][$event->getUid()] =& $event; } } else { if (!$ex_event_dates[$startDate->format('%Y%m%d')] && !$event->getStart()->after($this->endtime) && !$event->getEnd()->before($this->starttime)) { $master_array[$startDate->format('%Y%m%d')][$event->isAllday() ? '-1' : $startDate->format('%H%M')][$event->getUid()] =& $event; } } $added = 0; // if the 'parent' event is still in future, set $added to 1, because we already have one instance of this event $now = new \TYPO3\CMS\Cal\Model\CalDate(); if (intval($now->format('%Y%m%d%H%M%S')) < intval($event->getStart()->format('%Y%m%d%H%M%S'))) { $added = 1; } $select = '*'; $table = 'tx_cal_index'; $where = 'event_uid = ' . $event->getUid() . ' AND start_datetime >= ' . $this->starttime->format('%Y%m%d%H%M%S') . ' AND start_datetime <= ' . $this->endtime->format('%Y%m%d%H%M%S') . ' AND tablename = "' . ($event->getType() == 'tx_cal_phpicalendar' ? $event->isException ? 'tx_cal_exception_event' : 'tx_cal_event' : $event->getType()) . '"'; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, '', 'start_datetime'); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if ($added < $maxRecurringEvents) { $nextOccuranceTime = new \TYPO3\CMS\Cal\Model\CalDate($row['start_datetime']); $nextOccuranceEndTime = new \TYPO3\CMS\Cal\Model\CalDate($row['end_datetime']); $new_event = null; if ($row['event_deviation_uid'] > 0) { $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_cal_event_deviation', 'uid=' . $row['event_deviation_uid'] . $this->cObj->enableFields('tx_cal_event_deviation')); if ($result2) { while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2)) { $new_event = new \TYPO3\CMS\Cal\Model\EventRecDeviationModel($event, $row2, $nextOccuranceTime, $nextOccuranceEndTime); } } } else { $new_event = new \TYPO3\CMS\Cal\Model\EventRecModel($event, $nextOccuranceTime, $nextOccuranceEndTime); } if (!$ex_event_dates[$new_event->getStart()->format('%Y%m%d')]) { if ($new_event->isAllday()) { $master_array[$nextOccuranceTime->format('%Y%m%d')]['-1'][$event->getUid()] = $new_event; } else { $master_array[$nextOccuranceTime->format('%Y%m%d')][$nextOccuranceTime->format('%H%M')][$event->getUid()] = $new_event; } $added++; } } } $GLOBALS['TYPO3_DB']->sql_free_result($result); } return $master_array; }
/** * Draws the week view. * * @param $master_array array * The events to be drawn. * @param $getdate integer * The date of the event * @return string The HTML output. */ public function drawWeek(&$master_array, $getdate) { if ($this->conf['useNewTemplatesAndRendering']) { return $this->newDrawWeek($master_array, $getdate); } $this->_init($master_array); $page = $this->cObj->fileResource($this->conf['view.']['week.']['weekTemplate']); if ($page == '') { return "<h3>week: no template file found:</h3>" . $this->conf['view.']['week.']['weekTemplate'] . "<br />Please check your template record and add both cal items at 'include static (from extension)'"; } $weekTemplate = $this->cObj->getSubpart($page, '###WEEK_TEMPLATE###'); if ($weekTemplate == '') { $rems = array(); return $this->finish($page, $rems); } $dayStart = $this->conf['view.']['day.']['dayStart']; // '0700'; // Start time for day grid $dayEnd = $this->conf['view.']['day.']['dayEnd']; // '2300'; // End time for day grid $gridLength = $this->conf['view.']['day.']['gridLength']; // '15'; // Grid distance in minutes for day view, multiples of 15 preferred if (!isset($getdate) || $getdate == '') { $getdate_obj = new \TYPO3\CMS\Cal\Model\CalDate(); $getdate = $getdate_obj->format('%Y%m%d'); } $day_array2 = array(); preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2); $this_day = $day_array2[3]; $this_month = $day_array2[2]; $this_year = $day_array2[1]; $unix_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000'); $today = new \TYPO3\CMS\Cal\Model\CalDate(); $todayFormatted = $today->format('%Y%m%d'); $now = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000'); $endOfNextMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfNextMonth($this_day, $this_month, $this_year)); $now->addSeconds(60 * 60 * 24 * 31); $next_month = $now->format('%Y%m%d'); if ($now->after($endOfNextMonth)) { $next_month = $endOfNextMonth->format('%Y%m%d'); } $now = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000'); $startOfPrevMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfPrevMonth($this_day, $this_month, $this_year)); $startOfPrevMonth->setDay(1); $now->subtractSeconds(60 * 60 * 24 * 31); $prev_month = $now->format('%Y%m%d'); if ($now->before($startOfPrevMonth)) { $prev_month = $startOfPrevMonth->format('%Y%m%d'); } $dateOfMonth = Calc::beginOfWeek(1, $this_month, $this_year); $start_month_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfMonth . '000000'); $thisday2 = $unix_time->format($this->conf['view.']['week.']['dateFormatWeekList']); $num_of_events2 = 0; $next_week_obj = new \TYPO3\CMS\Cal\Model\CalDate(); $next_week_obj->copy($unix_time); $next_week_obj->addSeconds(60 * 60 * 24 * 7); $next_week = $next_week_obj->format('%Y%m%d'); $next_week_obj->subtractSeconds(60 * 60 * 24 * 7 * 2); $prev_week = $next_week_obj->format('%Y%m%d'); $next_day_obj = $unix_time->getNextDay(); $next_day = $next_day_obj->format('%Y%m%d'); $prev_day_obj = $unix_time->getPrevDay(); $prev_day = $prev_day_obj->format('%Y%m%d'); $dateOfWeek = Calc::beginOfWeek($unix_time->getDay(), $unix_time->getMonth(), $unix_time->getYear()); $week_start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000'); // Nasty fix to work with TS strftime $start_week_time = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000'); $start_week_time->setTZbyID('UTC'); $end_week_time = new \TYPO3\CMS\Cal\Model\CalDate(); $end_week_time->copy($start_week_time); $end_week_time->addSeconds(604799); $GLOBALS['TSFE']->register['cal_week_endtime'] = $end_week_time->getTime(); $GLOBALS['TSFE']->register['cal_week_starttime'] = $start_week_time->getTime(); $display_date = $this->cObj->cObjGetSingle($this->conf['view.']['week.']['titleWrap'], $this->conf['view.']['week.']['titleWrap.']); $this->initLocalCObject(); $dayLinkViewTarget =& $this->conf['view.']['dayLinkTarget']; $this->local_cObj->data['view'] = $dayLinkViewTarget; $this->local_cObj->setCurrentVal($this->conf['view.']['week.']['legendNextDayLink']); $legend_next_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['legendNextDayLink'], $this->conf['view.']['week.']['legendNextDayLink.']); $this->local_cObj->setCurrentVal($this->conf['view.']['week.']['legendPrevDayLink']); $legend_prev_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['legendPrevDayLink'], $this->conf['view.']['week.']['legendPrevDayLink.']); // Figure out colspans $dayborder = 0; $thisdate = $start_week_time; $eventArray = array(); $view_array = array(); $rowspan_array = array(); $endOfDay = new \TYPO3\CMS\Cal\Model\CalDate(); $startOfDay = new \TYPO3\CMS\Cal\Model\CalDate(); // creating the dateObjects only once: $starttime = new \TYPO3\CMS\Cal\Model\CalDate(); $endtime = new \TYPO3\CMS\Cal\Model\CalDate(); $j = new \TYPO3\CMS\Cal\Model\CalDate(); if (count($this->master_array) > 0) { $masterKeys = array_keys($this->master_array); foreach ($masterKeys as $ovlKey) { $dTimeStart = array(); $dTimeEnd = array(); $dDate = array(); preg_match('/([0-9]{2})([0-9]{2})/', $this->conf['view.']['day.']['dayStart'], $dTimeStart); preg_match('/([0-9]{2})([0-9]{2})/', $this->conf['view.']['day.']['dayEnd'], $dTimeEnd); preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $ovlKey, $dDate); $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00'); $d_start->setTZbyID('UTC'); $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00'); $d_end->setTZbyID('UTC'); // minus 1 second to allow endtime 24:00 $d_end->subtractSeconds(1); $ovlTimeKeys = array_keys($this->master_array[$ovlKey]); foreach ($ovlTimeKeys as $ovl_time_key) { $ovlDayKeys = array_keys($this->master_array[$ovlKey][$ovl_time_key]); foreach ($ovlDayKeys as $ovl2Key) { $event =& $this->master_array[$ovlKey][$ovl_time_key][$ovl2Key]; $eventStart = $event->getStart(); $eventMappingKey = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'); $eventArray[$ovlKey . '_' . $eventMappingKey] =& $event; $starttime->copy($event->getStart()); $endtime->copy($event->getEnd()); if ($ovl_time_key == '-1') { $j->copy($starttime); $view_array[$j->format('%Y%m%d')]['-1'][] = $ovlKey . '_' . $eventMappingKey; $j->addSeconds(86400); for (; $j->before($endtime) && $j->before($end_week_time); $j->addSeconds(86400)) { $view_array[$j->format('%Y%m%d')]['-1'][] = $ovlKey . '_' . $eventMappingKey; } } else { if ($starttime->before($end_week_time)) { $starttime->subtractSeconds($starttime->getMinute() % $gridLength * 60); $endtime->addSeconds($endtime->getMinute() % $gridLength * 60); $entries = 1; $old_day = new \TYPO3\CMS\Cal\Model\CalDate($ovlKey . '000000'); $endOfDay->copy($d_end); $startOfDay->copy($d_start); // get x-array possition for ($k = 0; $k < count($view_array[$ovlKey]); $k++) { if (empty($view_array[$starttime->format('%Y%m%d')][$starttime->format('%H%M')][$k])) { break; } } $j->copy($starttime); if ($j->before($startOfDay)) { $j->copy($startOfDay); } $counter = 0; while ($j->before($endtime) && $j->before($end_week_time)) { $counter++; $view_array[$j->format('%Y%m%d')][$j->format('%H%M')][] = $ovlKey . '_' . $eventMappingKey; if ($j->after($endOfDay)) { $rowspan_array[$old_day->format('%Y%m%d')][$eventMappingKey] = $entries - 1; $endOfDay->addSeconds(86400); $old_day->copy($endOfDay); $startOfDay->addSeconds(86400); $j->addSeconds(86400); $j->setHour($startOfDay->getHour()); $j->setMinute($startOfDay->getMinute()); $j->subtractSeconds($gridLength * 60); for ($k = 0; $k < count($view_array[$startOfDay->format('%Y%m%d')]); $k++) { if (empty($view_array[$startOfDay->format('%Y%m%d')][$startOfDay->format('%H%M')][$k])) { break; } } $entries = 0; $eventArray[$startOfDay->format('%Y%m%d') . '_' . $eventMappingKey] =& $event; } $j->addSeconds($gridLength * 60); $entries++; } $rowspan_array[$old_day->format('%Y%m%d')][$eventMappingKey] = $entries - 1; } } } } } } if ($this->conf['view.']['week.']['dynamic'] == 1) { $dayStart = '2359'; $dayEnd = '0000'; $firstStart = true; $firstEnd = true; $dynamicEnd = intval($end_week_time->format('%Y%m%d')); for ($dynamicStart = intval($start_week_time->format('%Y%m%d')); $dynamicStart < $dynamicEnd; $dynamicStart++) { if (is_array($view_array[$dynamicStart])) { $timeKeys = array_keys($view_array[$dynamicStart]); $formatedLast = array_pop($timeKeys); while (intval($formatedLast) < 0 && !empty($timeKeys)) { $formatedLast = array_pop($timeKeys); } $formatedFirst = null; if (count($timeKeys) > 0) { do { $formatedFirst = array_shift($timeKeys); } while (intval($formatedFirst) < 0 && !empty($timeKeys)); } else { $formatedFirst = $formatedLast; } if (intval($formatedFirst) > 0 && (intval($formatedFirst) < intval($dayStart) || $firstStart)) { $dayStart = sprintf("%04d", $formatedFirst); $firstStart = false; } if (intval($formatedLast) > intval($dayEnd) || $firstEnd) { $dayEnd = sprintf("%04d", $formatedLast + $gridLength); $firstEnd = false; } } } $dayStart = substr($dayStart, 0, 2) . '00'; } $startdate = new \TYPO3\CMS\Cal\Model\CalDate($start_week_time->format('%Y%m%d') . '000000'); $enddate = new \TYPO3\CMS\Cal\Model\CalDate(); $enddate->copy($end_week_time); for ($i = $startdate; $enddate->after($i); $i->addSeconds(86400)) { if (!empty($view_array[$i->format('%Y%m%d')])) { $max = array(); foreach (array_keys($view_array[$i->format('%Y%m%d')]) as $array_time) { $c = count($view_array[$i->format('%Y%m%d')][$array_time]); array_push($max, $c); } $nbrGridCols[$i->format('%Y%m%d')] = max($max); } else { $nbrGridCols[$i->format('%Y%m%d')] = 1; } } $t_array = array(); $pos_array = array(); preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart); preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd); $nd = new \TYPO3\CMS\Cal\Model\CalDate(); foreach (array_keys($view_array) as $week_key) { $week_day =& $view_array[$week_key]; preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $week_key, $dDate); $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00'); $d_start->setTZbyId('UTC'); $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00'); $d_end->setTZbyId('UTC'); $d_start->subtractSeconds($d_start->getMinute() % $gridLength * 60); $d_end->addSeconds(($gridLength - $d_end->getMinute() % $gridLength) * 60); for ($i->copy($d_start); !$i->after($d_end); $i->addSeconds($gridLength * 60)) { $timeKey = $i->format('%H%M'); if (is_array($view_array[$week_key][$timeKey]) && count($view_array[$week_key][$timeKey]) > 0) { foreach (array_keys($view_array[$week_key][$timeKey]) as $eventKey) { $event =& $eventArray[$view_array[$week_key][$timeKey][$eventKey]]; $eventStart = $event->getStart(); $startFormatted = $eventStart->format('%Y%m%d%H%M'); $eventType = $event->getType(); $eventUid = $event->getUid(); if (is_array($pos_array[$week_key]) && array_key_exists($eventType . $eventUid . '_' . $startFormatted, $pos_array[$week_key])) { $nd->copy($event->getEnd()); $nd->addSeconds(($gridLength - $nd->getMinute() % $gridLength) * 60); if ($nd->before($i)) { $t_array[$week_key][$timeKey][$pos_array[$week_key][$eventType . $eventUid . '_' . $startFormatted]] = array('ended' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted); } else { $t_array[$week_key][$timeKey][$pos_array[$week_key][$eventType . $eventUid . '_' . $startFormatted]] = array('started' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted); } } else { for ($j = 0; $j < $nbrGridCols[$week_key] ? $nbrGridCols[$week_key] : 1; $j++) { if (!isset($t_array[$week_key][$timeKey][$j]) || count($t_array[$week_key][$timeKey][$j]) == 0) { $pos_array[$week_key][$event->getType() . $event->getUid() . '_' . $startFormatted] = $j; $t_array[$week_key][$timeKey][$j] = array('begin' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted); break; } } } } } else { $t_array[$week_key][$timeKey] = ''; } } } $thisdate = new \TYPO3\CMS\Cal\Model\CalDate(); $thisdate->copy($week_start_day); for ($i = 0; $i < 7; $i++) { $weekarray[$i] = $thisdate->format('%Y%m%d'); $thisdate->addSeconds(86400); } $sims = array('###GETDATE###' => $getdate, '###DISPLAY_DATE###' => $display_date, '###LEGEND_PREV_DAY###' => $legend_prev_day_link, '###LEGEND_NEXT_DAY###' => $legend_next_day_link, '###SIDEBAR_DATE###' => ''); // Replaces the allday events $alldays = $this->cObj->getSubpart($weekTemplate, '###ALLDAYSOFWEEK##'); foreach ($weekarray as $get_date) { $replace = ''; if (is_array($view_array[$get_date]['-1'])) { foreach ($view_array[$get_date]['-1'] as $id => $allday) { $replace .= $eventArray[$allday]->renderEventForAllDay(); } } $weekreplace .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($alldays, array('###COLSPAN###' => 'colspan="' . ($nbrGridCols[$get_date] ? $nbrGridCols[$get_date] : 1) . '"', '###ALLDAY###' => $replace)); } $rems = array(); $rems['###ALLDAYSOFWEEK###'] = $weekreplace; // Replaces the daysofweek $loop_dof = $this->cObj->getSubpart($weekTemplate, '###DAYSOFWEEK###'); $start_day = new \TYPO3\CMS\Cal\Model\CalDate(); $start_day->copy($week_start_day); $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent(); for ($i = 0; $i < 7; $i++) { $day_num = $start_day->format('%w'); $daylink = $start_day->format('%Y%m%d'); $weekday = $start_day->format($this->conf['view.']['week.']['dateFormatWeekList']); if ($daylink == $getdate) { $row1 = 'rowToday'; $row2 = 'rowOn'; $row3 = 'rowToday'; } else { $row1 = 'rowOff'; $row2 = 'rowOn'; $row3 = 'rowOff'; } $dayLinkViewTarget =& $this->conf['view.']['dayLinkTarget']; if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($view_array[$daylink] || $isAllowedToCreateEvent)) { $this->initLocalCObject(); $this->local_cObj->setCurrentVal($weekday); if (!empty($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid'])) { $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']); } else { $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway']); } $this->local_cObj->data['view'] = $dayLinkViewTarget; $link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']); $link = $this->cObj->stdWrap($link, $this->conf['view.']['week.']['weekday_stdWrap.']); } else { $link = $this->cObj->stdWrap($weekday, $this->conf['view.']['week.']['weekday_stdWrap.']); } $start_day->addSeconds(86400); $colspan = 'colspan="' . ($nbrGridCols[$daylink] ? $nbrGridCols[$daylink] : 1) . '"'; $search = array('###LINK###', '###DAYLINK###', '###ROW1###', '###ROW2###', '###ROW3###', '###COLSPAN###', '###TIME###'); $replace = array($link, $daylink, $row1, $row2, $row3, $colspan, $start_day->format('%Y %m %d %H %M %s')); $loop_tmp = str_replace($search, $replace, $loop_dof); $weekday_loop .= $loop_tmp; } $rems['###DAYSOFWEEK###'] = $weekday_loop; // Build the body $border = 0; $thisdate = $start_week_time; $dTimeStart[2] -= $dTimeStart[2] % $gridLength; $dTimeEnd[2] -= $dTimeEnd[2] % $gridLength; preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $week_key, $dDate); $loops = ($dTimeEnd[1] * 60 + $dTimeEnd[2] - ($dTimeStart[1] * 60 + $dTimeStart[2])) / $gridLength; $weekdisplay = ''; $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60; $cal_time_obj = new \TYPO3\CMS\Cal\Model\CalDate(); $cal_time_obj->copy($week_start_day); $cal_time_obj->setHour(intval($dTimeStart[1])); $cal_time_obj->setMinute(intval($dTimeStart[2])); $start = 0; for ($i = $start; $i < $loops; $i++) { $time = $cal_time_obj->format('%H%M'); for ($j = 0; $j < 7; $j++) { $day = $cal_time_obj->format('%Y%m%d'); if ($j == 0) { $key = $cal_time_obj->format('%I:%M'); if (preg_match('/([0-9]{1,2}):00/', $key)) { $weekdisplay .= sprintf($this->conf['view.']['week.']['weekDisplayFullHour'], 60 / $gridLength, $cal_time_obj->format($this->conf['view.']['week.']['timeFormatWeek']), $gridLength); } else { $weekdisplay .= sprintf($this->conf['view.']['week.']['weekDisplayInbetween'], $gridLength); } } $something = $t_array[$day][$time]; $class = $this->conf['view.']['week.']['classWeekborder']; if ($day == $todayFormatted) { $class .= ' ' . $this->conf['view.']['week.']['classTodayWeekborder']; } if (is_array($something) && $something != "" && count($something) > 0) { for ($k = 0; $k < count($something); $k++) { if (!empty($something[$k])) { $keys = array_keys($something[$k]); switch ($keys[0]) { case 'begin': $event =& $eventArray[$something[$k][$keys[0]]]; $rest = $event->getEnd()->getMinute() % ($gridLength * 60); $plus = 0; if ($rest > 0) { $plus = 1; } $weekdisplay .= sprintf($this->conf['view.']['week.']['weekEventPre'], $rowspan_array[$day][$event->getType() . '_' . $event->getUid() . '_' . $event->getStart()->format('%Y%m%d%H%M')]); $weekdisplay .= $event->renderEventForWeek(); $weekdisplay .= $this->conf['view.']['week.']['weekEventPost']; // End event drawing break; } } } if (count($something) < ($nbrGridCols[$day] ? $nbrGridCols[$day] : 1)) { $remember = 0; for ($l = 0; $l < ($nbrGridCols[$day] ? $nbrGridCols[$day] : 1); $l++) { if (!$something[$l]) { $remember++; } else { if ($remember > 0) { $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $time); $remember = 0; } } } if ($remember > 0) { $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $time); $remember = 0; } } } else { $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $nbrGridCols[$day] ? $nbrGridCols[$day] : 1, $class, $time); } if ($j == 6) { $weekdisplay .= $this->conf['view.']['week.']['weekFinishRow']; } $cal_time_obj->addSeconds(86400); } $cal_time_obj->setYear($week_start_day->getYear()); $cal_time_obj->setMonth($week_start_day->getMonth()); $cal_time_obj->setDay($week_start_day->getDay()); $cal_time_obj->addSeconds($gridLength * 60); } $weekTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($weekTemplate, $sims, array(), array()); $rems['###LOOPEVENTS###'] = $weekdisplay; $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###WEEK_TEMPLATE###' => $weekTemplate), array()); return $this->finish($page, $rems); }
/** * Attempts to subscribe an email address to a particular event if the * subscription hash matches. * * @param * string Email address to subscribe. * @param * object Event that email should be subscribed to. * @param * string Unique Hash of email and event. * @return boolean whether subscribe was successful. * @todo Should we always try to subscribe as a frontend user first? */ function subscribe($email, $event, $subscriptionHash) { $md5 = md5($event->getUid() . $email . $event->getCreationDate()); $eventUID = $event->getUID(); $eventPID = $event->getPID(); $offset = $this->conf['view.']['event.']['remind.']['time']; /* If the subscription hash matches, subscribe */ if ($md5 == $subscriptionHash) { $user_uid = $this->getFrontendUserUid($email); $user_table = 'fe_users'; /* If we didn't find a matching frontend user, try unknown users */ if (!$user_uid) { $user_uid = $this->getUnknownUserUid($email); $user_table = 'tx_cal_unknown_users'; } /* Insert the user ID into the monitor table */ $this->insertMMRow('tx_cal_fe_user_event_monitor_mm', $eventUID, $user_uid, $user_table, 1, $offset, $eventPID); $pageTSConf = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($eventPID); $offset = is_numeric($pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time']) ? $pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time'] * 60 : 0; $date = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['start_date'] . '000000'); $date->setTZbyId('UTC'); $reminderTimestamp = $date->getTime() + $insertFields['start_time'] - $offset; $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); $reminderService->scheduleReminder($eventUID); return true; } return false; }
public function findAllWithin(&$start_date, &$end_date, $pidList, $eventType = '0,1,2,3', $additionalWhere = '') { // How to get the events // 1st get Calendar specified // 2nd get categories specified // 3rd get all related events // make an array out of the list, so we can handle it better $includeRecurring = true; if ($this->conf['view'] == 'ics' || $this->conf['view'] == 'single_ics') { $includeRecurring = false; } $this->setStartAndEndPoint($start_date, $end_date); $dontShowOldEvents = (int) $this->conf['view.'][$this->conf['view'] . '.']['dontShowOldEvents']; if ($dontShowOldEvents > 0) { $now = new \TYPO3\CMS\Cal\Model\CalDate(); if ($dontShowOldEvents == 2) { $now->setHour(0); $now->setMinute(0); $now->setSecond(0); } if ($start_date->getTime() <= $now->getTime()) { $start_date->copy($now); } if ($end_date->getTime() <= $now->getTime()) { $end_date->copy($now); $end_date->addSeconds(86400); } $this->starttime->copy($start_date); $this->endtime->copy($end_date); } $formattedStarttime = $this->starttime->format('%Y%m%d'); $formattedEndtime = $this->endtime->format('%Y%m%d'); $calendarService =& $this->modelObj->getServiceObjByKey('cal_calendar_model', 'calendar', 'tx_cal_calendar'); $categoryService =& $this->modelObj->getServiceObjByKey('cal_category_model', 'category', $this->extConf['categoryService']); $calendarSearchString = $this->getFreeAndBusyCalendarSearchString($pidList, true, $this->conf['calendar'] ? $this->conf['calendar'] : ''); $recurringClause = ''; // only include the recurring clause if we don't use the new recurring model or a view not needing recurring events. if ($includeRecurring) { // get the uids of recurring events from index $select = 'event_uid'; $table = 'tx_cal_index'; $where = 'start_datetime >= ' . $this->starttime->format('%Y%m%d%H%M%S') . ' AND start_datetime <= ' . $this->endtime->format('%Y%m%d%H%M%S'); $group = 'event_uid'; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $group); $tmpUids = array(); if ($result) { while ($tmp = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) { $tmpUids[] = $tmp[0]; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } if (count($tmpUids)) { $recurringClause = ' OR (tx_cal_event.uid IN (' . implode(',', $tmpUids) . ')) '; } } // putting everything together // Franz: added simple check/include for rdate events at the end of this where clause. // But we need to find a way to only include rdate events within the searched timerange // - otherwise we'll flood the results after some time. I think we need a mm-table for that! $additionalWhere = $calendarSearchString . ' AND tx_cal_event.pid IN (' . $pidList . ') ' . $this->cObj->enableFields('tx_cal_event') . ' AND ((tx_cal_event.start_date>=' . $formattedStarttime . ' AND tx_cal_event.start_date<=' . $formattedEndtime . ') OR (tx_cal_event.end_date<=' . $formattedEndtime . ' AND tx_cal_event.end_date>=' . $formattedStarttime . ') OR (tx_cal_event.end_date>=' . $formattedEndtime . ' AND tx_cal_event.start_date<=' . $formattedStarttime . ')' . $recurringClause . ')' . $additionalWhere; // $additionalWhere = $calendarSearchString.' AND tx_cal_event.pid IN ('.$pidList.') '.$this->cObj->enableFields('tx_cal_event').' AND ((tx_cal_event.start_date>='.$formattedEndtime.' OR tx_cal_event.end_date>='.$formattedStarttime.')' . $recurringClause . ')'.$additionalWhere; // creating the arrays the user is allowed to see $categories = array(); $categoryService->getCategoryArray($pidList, $categories); // creating events return $this->getEventsFromTable($categories[0][0], $includeRecurring, $additionalWhere, $this->getServiceKey(), true, false, $eventType); }