function renderEventFor($viewType, $subpartSuffix = '') { if ($this->parentEvent->conf['view.']['freeAndBusy.']['enable'] == 1) { $viewType .= '_FNB'; } if (substr($viewType, -6) != 'ALLDAY' && ($this->isAllday() || $this->getStart()->format('%Y%m%d') != $this->getEnd()->format('%Y%m%d'))) { $subpartSuffix .= 'ALLDAY'; } $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_phpicalendar_rec_model', 'eventModelClass', 'model'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preFillTemplate')) { $hookObj->preFillTemplate($this, $viewType, $subpartSuffix); } } return $this->fillTemplate('###TEMPLATE_PHPICALENDAR_EVENT_' . strtoupper($viewType) . ($subpartSuffix ? '_' : '') . $subpartSuffix . '###'); }
/** * Generates the sql query and builds organizer objects out of the result rows * * @param string $pidList * to search in * @param string $additionalWhere * where clause * @return array containing the organizer objects */ function getOrganizerFromTable($pidList = '', $additionalWhere = '') { $organizers = array(); $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy($this->tableId); if ($pidList != '') { $additionalWhere .= ' AND ' . $this->tableId . '.pid IN (' . $pidList . ')'; } $additionalWhere .= $this->getAdditionalWhereForLocalizationAndVersioning($this->tableId); $select = '*'; $table = $this->tableId; $where = 'tx_cal_controller_isorganizer = 1 AND l18n_parent = 0 ' . $additionalWhere . $this->cObj->enableFields($this->tableId); $groupBy = ''; $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy($this->tableId); $limit = ''; $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_organizer_address_service', 'organizerServiceClass', 'service'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preGetOrganizerFromTableExec')) { $hookObj->preGetLocationFromTableExec($this, $select, $table, $where, $groupBy, $orderBy, $limit); } } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $organizers[] = new \TYPO3\CMS\Cal\Model\OrganizerAddress($row, $pidList); } $GLOBALS['TYPO3_DB']->sql_free_result($result); } return $organizers; }
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); }
/** * * @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; }
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); if (FALSE === $result) { throw new \RuntimeException('Could not delete event record from database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458133); } $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_event_service', 'eventServiceClass'); \TYPO3\CMS\Cal\Utility\Functions::executeHookObjectsFunction($hookObjectsArr, 'removeEvent', $this, $event); \TYPO3\CMS\Cal\Utility\Functions::clearCache(); $this->unsetPiVars(); } }
function getPageBrowser($template) { $pb = ''; // render PageBrowser if ($this->conf['view.']['list.']['pageBrowser.']['usePageBrowser']) { $this->controller->pointerName = $this->pointerName; // Hook: getPageBrowser $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_listview', 'getPageBrowser', 'view'); if (count($hookObjectsArr)) { foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'renderPageBrowser')) { $hookObj->renderPageBrowser($this, $pb, $this->count, $this->recordsPerPage, $template); } } if ($pb != '') { return $pb; } } // use the piPageBrowser if ($this->conf['view.']['list.']['pageBrowser.']['useType'] == 'piPageBrowser') { $browserConfig =& $this->conf['view.']['list.']['pageBrowser.']['piPageBrowser.']; $this->controller->internal['res_count'] = $this->count; $this->controller->internal['results_at_a_time'] = $this->recordsPerPage; if ($maxPages = intval($this->conf['view.']['list.']['pageBrowser.']['pagesCount'])) { $this->controller->internal['maxPages'] = $maxPages; } $this->controller->internal['pagefloat'] = $browserConfig['pagefloat']; $this->controller->internal['showFirstLast'] = $browserConfig['showFirstLast']; $this->controller->internal['showRange'] = $browserConfig['showRange']; $this->controller->internal['dontLinkActivePage'] = $browserConfig['dontLinkActivePage']; $wrapArrFields = explode(',', 'disabledLinkWrap,inactiveLinkWrap,activeLinkWrap,browseLinksWrap,showResultsWrap,showResultsNumbersWrap,browseBoxWrap'); $wrapArr = array(); foreach ($wrapArrFields as $key) { if ($browserConfig[$key]) { $wrapArr[$key] = $browserConfig[$key]; } } if ($wrapArr['showResultsNumbersWrap'] && strpos($this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_displays'], '%s')) { // if the advanced pagebrowser is enabled and the "pi_list_browseresults_displays" label contains %s it will be replaced with the content of the label "pi_list_browseresults_displays_advanced" $this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_displays'] = $this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_displays_advanced']; } if (!$browserConfig['showPBrowserText']) { $this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_page'] = ''; } $this->controller->pi_alwaysPrev = $browserConfig['alwaysPrev']; // if there is a GETvar in the URL that is not in this list, caching will be disabled for the pagebrowser links $this->controller->pi_isOnlyFields = $this->pointerName . ',view,model,category,type,getdate,uid'; // pi_lowerThan limits the amount of cached pageversions for the list view. Caching will be disabled if one of the vars in $this->pi_isOnlyFields has a value greater than $this->pi_lowerThan // $this->pi_lowerThan = ceil($this->internal['res_count']/$this->internal['results_at_a_time']); $pi_isOnlyFieldsArr = explode(',', $this->controller->pi_isOnlyFields); $highestVal = 0; foreach ($pi_isOnlyFieldsArr as $k => $v) { $val = $this->controller->piVars[$v]; if (is_array($this->controller->piVars[$v])) { $val = $this->controller->piVars[$v][0]; } if ($val > $highestVal) { $highestVal = $val; } } $this->controller->pi_lowerThan = $highestVal + 1; $pb = $this->controller->pi_list_browseresults($browserConfig['showResultCount'], $browserConfig['tableParams'], $wrapArr, $this->pointerName, $browserConfig['hscText']); } else { // use default page browser of cal $browserConfig = $this->conf['view.']['list.']['pageBrowser.']['default.']; $this->offset = intval($this->controller->piVars[$this->pointerName]); $pagesTotal = intval($this->recordsPerPage) == 0 ? 1 : ceil($this->count / $this->recordsPerPage); $nextPage = $this->offset + 1; $previousPage = $this->offset - 1; $pagesCount = $this->conf['view.']['list.']['pageBrowser.']['pagesCount'] - 1; $min = 1; $max = $pagesTotal; if ($pagesTotal > $pagesCount + 1 && $pagesCount > 0) { $pstart = $this->offset - ceil(($pagesCount - 2) / 2); if ($pstart < 1) { $pstart = 1; } $pend = $pstart + $pagesCount; if ($pend > $pagesTotal - 1) { $pend = $pagesTotal - 1; } $spacer = $this->local_cObj->cObjGetSingle($browserConfig['spacer'], $browserConfig['spacer.']); } else { $pstart = $min; $pend = $pagesTotal; } $pbMarker['###PAGEOF###'] = sprintf($this->controller->pi_getLL('l_page_of'), $this->offset + 1, $pagesTotal); // Extra Single Marker $pbMarker['###PAGE###'] = $this->offset + 1; $pbMarker['###PAGETOTAL###'] = $pagesTotal; // next+previous $this->initLocalCObject(); $pbMarker['###NEXT###'] = ''; if ($nextPage + 1 <= $pagesTotal) { $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array($this->pointerName => $nextPage), $this->conf['cache']); $pbMarker['###NEXT###'] = $this->local_cObj->cObjGetSingle($browserConfig['nextLink'], $browserConfig['nextLink.']); } $pbMarker['###PREVIOUS###'] = ''; if ($previousPage >= 0) { $previousPage = $previousPage == 0 ? NULL : $previousPage; $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array($this->pointerName => $previousPage), $this->conf['cache']); $pbMarker['###PREVIOUS###'] = $this->local_cObj->cObjGetSingle($browserConfig['prevLink'], $browserConfig['prevLink.']); } for ($i = $min; $i <= $max; $i++) { if ($this->offset + 1 == $i) { $pbMarker['###PAGES###'] .= $this->cObj->stdWrap($i, $browserConfig['actPage_stdWrap.']); } else { if ($i == 1 || $i == $max || $i > 1 && $i >= $pstart && $i <= $pend && $i < $max) { $this->local_cObj->setCurrentVal($i); $pageNum = $i - 1; $pageNum = $pageNum == 0 ? NULL : $pageNum; $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array($this->pointerName => $pageNum), $this->conf['cache']); $pbMarker['###PAGES###'] .= $this->local_cObj->cObjGetSingle($browserConfig['pageLink'], $browserConfig['pageLink.']); } elseif ($i == 2 && $i < $pstart || $i == $pend + 1 && $i < $max) { unset($this->local_cObj->data['link_parameter']); $pbMarker['###PAGES###'] .= $spacer; } } } $pb = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($template, $pbMarker, array(), array()); } } return $pb; }
/** * Generates the sql query and builds location objects out of the result rows * * @param string $pidList * to search in * @param string $additionalWhere * where clause * @return array containing the location objects */ function getLocationFromTable($pidList = '', $additionalWhere = '') { $locations = array(); $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy('tx_cal_location'); if ($pidList != '') { $additionalWhere .= ' AND tx_cal_location.pid IN (' . $pidList . ')'; } $additionalWhere .= $this->getAdditionalWhereForLocalizationAndVersioning('tx_cal_location'); $table = 'tx_cal_location'; $select = '*'; $where = ' l18n_parent = 0 ' . $additionalWhere . $this->cObj->enableFields('tx_cal_location'); $groupBy = ''; $limit = ''; $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller'); $feUserUid = $rightsObj->getUserId(); $feGroupsArray = $rightsObj->getUserGroups(); $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_location_service', 'locationServiceClass', 'service'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preGetLocationFromTableExec')) { $hookObj->preGetLocationFromTableExec($this, $select, $table, $where, $groupBy, $orderBy, $limit); } } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if ($GLOBALS['TSFE']->sys_language_content) { $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_cal_location', $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL, ''); } if ($GLOBALS['TSFE']->sys_page->versioningPreview == TRUE) { // get workspaces Overlay $GLOBALS['TSFE']->sys_page->versionOL('tx_cal_location', $row); } $lastLocation = new \TYPO3\CMS\Cal\Model\Location($row, $pidList); $select = 'uid_foreign,tablenames'; $table = 'tx_cal_location_shared_user_mm'; $where = 'uid_local = ' . $row['uid']; $sharedUserResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); if ($sharedUserResult) { while ($sharedUserRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sharedUserResult)) { if ($sharedUserRow['tablenames'] == 'fe_users') { $lastLocation->addSharedUser($sharedUserRow['uid_foreign']); } else { if ($sharedUserRow['tablenames'] == 'fe_groups') { $lastLocation->addSharedGroup($sharedUserRow['uid_foreign']); } } } $GLOBALS['TYPO3_DB']->sql_free_result($sharedUserResult); } $locations[] = $lastLocation; } $GLOBALS['TYPO3_DB']->sql_free_result($result); } return $locations; }
/** * Method for post processing the rendered event * * @return string $content content/output */ protected function finish(&$content) { $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_base_model', 'finishModelRendering', 'model'); // Hook: preFinishModelRendering foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'preFinishModelRendering')) { $hookObj->preFinishModelRendering($this, $content); } } // translate output $this->translateLanguageMarker($content); // Hook: postFinishModelRendering foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'postFinishModelRendering')) { $hookObj->postFinishModelRendering($this, $content); } } return $content; }
public function processObjects(&$master_array, &$sims, &$rems) { if ($this->objectType == 'event') { return parent::processObjects($master_array, $sims, $rems); } // clear the register $GLOBALS['TSFE']->register['cal_list_firstevent'] = 0; $GLOBALS['TSFE']->register['cal_list_lastevent'] = 0; $GLOBALS['TSFE']->register['cal_list_events_total'] = 0; $GLOBALS['TSFE']->register['cal_list_eventcounter'] = 0; $GLOBALS['TSFE']->register['cal_list_days_total'] = 0; $sectionMenu = ''; $middle = ''; // only proceed if the master_array is not empty if (count($master_array)) { $this->count = 0; $this->eventCounter = array(); $this->listStartOffsetCounter = 0; $this->listStartOffset = intval($this->conf['view.'][$this->conf['view'] . '.']['listStartOffset']); if ($this->conf['view.'][$this->conf['view'] . '.']['pageBrowser.']['usePageBrowser']) { $this->offset = intval($this->controller->piVars[$this->pointerName]); $this->recordsPerPage = intval($this->conf['view.'][$this->conf['view'] . '.']['pageBrowser.']['recordsPerPage']); } $this->walkThroughMasterArray($master_array, $reverse, $firstEventDate); if ($this->count) { $GLOBALS['TSFE']->register['cal_list_events_total'] = $this->count; // reference the array with all event counts in the TYPO3 register for usage from within hooks or whatever $GLOBALS['TSFE']->register['cal_list_eventcounter'] =& $this->eventCounter; } if ($days = count($this->objectsInList)) { $GLOBALS['TSFE']->register['cal_list_days_total'] = $days; } // start rendering the organizer if (count($this->objectsInList) && $this->count > 0) { $times = array_keys($this->objectsInList); if ($times) { // preset vars $firstTime = true; } $listItemCount = 0; $alternationCount = 0; $pageItemCount = $this->recordsPerPage * $this->offset; // don't assign these dates in one line like "$date1 = $date2 = $date3 = new CalDate()", as this will make all dates references to each other!!! $lastEventDay = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000'); $lastEventWeek = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000'); $lastEventMonth = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000'); $lastEventYear = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000'); // prepare alternating layouts $alternatingLayoutConfig = $this->conf['view.'][$this->conf['view'] . '.']['alternatingLayoutMarkers.']; if (is_array($alternatingLayoutConfig) && count($alternatingLayoutConfig)) { $alternatingLayouts = array(); $layout_keys = array_keys($alternatingLayoutConfig); foreach ($layout_keys as $key) { if (substr($key, strlen($key) - 1) != '.') { $suffix = $this->cObj->stdWrap($alternatingLayoutConfig[$key], $alternatingLayoutConfig[$key . '.']); if ($suffix) { $alternatingLayouts[] = $suffix; } } } } else { $alternatingLayouts = array('ODD', 'EVEN'); } // Hook: get hook objects for drawList $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_searchview', 'drawList', 'view'); if ($reverse) { arsort($times); } else { asort($times); } foreach ($times as $cal_time) { $object =& $this->objectsInList[$cal_time]; // Hook: innerObjectWrapper if (count($hookObjectsArr)) { // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers $hookObjectKeys = array_keys($hookObjectsArr); foreach ($hookObjectKeys as $hookObjKey) { $hookObj =& $hookObjectsArr[$hookObjKey]; if (method_exists($hookObj, 'innerObjectWrapper')) { $hookObj->innerObjectWrapper($this, $middle, $object); } } } $listItemCount++; $totalListCount = $listItemCount + $pageItemCount; $GLOBALS['TSFE']->register['cal_event_list_num'] = $listItemCount; $GLOBALS['TSFE']->register['cal_event_list_num_total'] = $totalListCount; $layoutNum = $alternationCount % count($alternatingLayouts); $layoutSuffix = $alternatingLayouts[$layoutNum]; $objectText = ''; $tempSims = array(); $tempRems = array(); $wrapped = array(); $functionName = 'render' . ucwords($this->objectType) . 'For'; $objectText = $object->{$functionName}(strtoupper($this->conf['view']), $layoutSuffix); $allowFurtherGrouping = true; // Hook: prepareOuterObjectWrapper if (count($hookObjectsArr)) { // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers $hookObjectKeys = array_keys($hookObjectsArr); foreach ($hookObjectKeys as $hookObjKey) { $hookObj =& $hookObjectsArr[$hookObjKey]; if (method_exists($hookObj, 'prepareOuterObjectWrapper')) { $hookObj->prepareOuterObjectWrapper($this, $middle, $object, $allowFurtherGrouping); } } } $alternationCount++; $firstTime = false; $middle .= $objectText; } $allowFurtherGrouping = true; // Hook: applyOuterObjectWrapper if (count($hookObjectsArr)) { // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers $hookObjectKeys = array_keys($hookObjectsArr); foreach ($hookObjectKeys as $hookObjKey) { $hookObj =& $hookObjectsArr[$hookObjKey]; if (method_exists($hookObj, 'applyOuterObjectWrapper')) { $hookObj->applyOuterObjectWrapper($this, $middle, $object, $allowFurtherGrouping); } } } } } return $middle; }
/** * Sets up a hook in the controller's PHP file with the specified name. * @param string The name of the hook. * @return array The array of objects implementing this hoook. */ public function getHookObjectsArray($hookName) { return \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray($this->prefixId, $hookName); }
private function getDayClasses($weekdayIndex) { $conf =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'conf'); if ($this->initialized === false) { $this->getAlldaysMarker($template, $sims, $rems, $wrapped, $conf['view']); $this->initialized = true; } $classes = ''; if ($this->dayHasEvent[$weekdayIndex] == 1) { $classes .= ' ' . $conf['view.']['month.']['eventDayStyle']; } $localDayIndex = $this->currentDayIndex + DATE_CALC_BEGIN_WEEKDAY; if ($localDayIndex == 7) { $localDayIndex = 0; } if ($localDayIndex == $weekdayIndex) { $classes .= ' ' . $conf['view.']['month.']['monthTodayStyle']; } $localDayIndex = $weekdayIndex - DATE_CALC_BEGIN_WEEKDAY; if ($localDayIndex == -1) { $localDayIndex = 6; } $daysKeys = array_keys($this->days); if (intval($this->getParentMonth()) != intval($this->days[$daysKeys[$localDayIndex]]->month)) { $classes .= ' ' . $conf['view.']['month.']['monthOffStyle']; } $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('NewWeekView', 'postDayClassesViewMarker', 'view'); // Hook: postDayClassesViewMarker foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'postDayClassesViewMarker')) { $hookObj->postDayClassesViewMarker($this, $weekdayIndex, $classes); } } return $classes; }