public function execute() { $event = BackendUtility::getRecord('tx_cal_event', $this->uid); $select = '*'; $table = 'tx_cal_fe_user_event_monitor_mm'; $where = 'schedulerId = ' . $this->getTaskUid(); $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); $eventMonitor = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); if (!is_array($event)) { // the event could not be found, so we delete this reminder $this->remove(); return true; } // ****************** // Constants defined // ****************** define('PATH_thisScript', str_replace('//', '/', str_replace('\\', '/', (php_sapi_name() == 'cgi' || php_sapi_name() == 'isapi' || php_sapi_name() == 'cgi-fcgi') && ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ? $_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED'] : ($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])))); define('PATH_site', dirname(PATH_thisScript) . '/'); if (@is_dir(PATH_site . 'typo3/sysext/cms/tslib/')) { define('PATH_tslib', PATH_site . 'typo3/sysext/cms/tslib/'); } elseif (@is_dir(PATH_site . 'tslib/')) { define('PATH_tslib', PATH_site . 'tslib/'); } else { // define path to tslib/ here: $configured_tslib_path = ''; // example: // $configured_tslib_path = '/var/www/mysite/typo3/sysext/cms/tslib/'; define('PATH_tslib', $configured_tslib_path); } if (PATH_tslib == '') { die('Cannot find tslib/. Please set path by defining $configured_tslib_path in ' . basename(PATH_thisScript) . '.'); } chdir(PATH_site); /* Check Page TSConfig for a preview page that we should use */ $pageTSConf = BackendUtility::getPagesTSconfig($event['pid']); if ($pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']) { $pageIDForPlugin = $pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']; } else { $pageIDForPlugin = $event['pid']; } $page = BackendUtility::getRecord('pages', intval($pageIDForPlugin), "doktype"); if ($page['doktype'] != 254) { /** @var \TYPO3\CMS\Cal\Controller\Api $calAPI */ $calAPI = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\Api'); $calAPI =& $calAPI->tx_cal_api_without($pageIDForPlugin); $eventObject = $calAPI->modelObj->findEvent($event['uid'], 'tx_cal_phpicalendar', $calAPI->conf['pidList'], false, false, false, true); $calAPI->conf['view'] = 'event'; $reminderService =& Functions::getReminderService(); $reminderService->remind($eventObject, $eventMonitor); return true; } $message = 'Cal was not able to send a reminder notice. You have to point to a page containing the cal Plugin. Configure in pageTSConf of page ' . $event['pid'] . ': options.tx_cal_controller.pageIDForPlugin'; throw new FailedExecutionException($message, 1250596541); }
/** * * @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 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###'] = ''; } }
/** * 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; }
function processCmdmap_preProcess(&$command, &$table, &$id, &$value, &$tce) { switch ($table) { case 'tx_cal_event': if ($command == 'delete') { $select = '*'; $table = 'tx_cal_event'; $where = 'uid = ' . $id; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); if ($result) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { /* If we're in a workspace, don't notify anyone about the event */ if ($row['pid'] > 0 && !$GLOBALS['BE_USER']->workspace) { /* Check Page TSConfig for a preview page that we should use */ $pageTSConf = BackendUtility::getPagesTSconfig($row['pid']); if ($pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']) { $pageIDForPlugin = $pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']; } else { $pageIDForPlugin = $row['pid']; } $page = BackendUtility::getRecord('pages', intval($pageIDForPlugin), "doktype"); if ($page['doktype'] != 254) { $tx_cal_api = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\Api'); $tx_cal_api =& $tx_cal_api->tx_cal_api_without($pageIDForPlugin); $notificationService =& \TYPO3\CMS\Cal\Utility\Functions::getNotificationService(); // Need to enforce deletion mode $notificationService->notify($row, 1); } } } } // We have to delete the gabriel/scheduler events BEFORE the tx_cal_events and // its related tx_cal_fe_user_event_monitor_mm records are gone /* Clean up any pending reminders for this event */ $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); try { $reminderService->deleteReminderForEvent($id); } catch (OutOfBoundsException $e) { } } break; case 'tx_cal_fe_user_event_monitor_mm': if ($command == 'delete') { $relationRecord = BackendUtility::getRecord('tx_cal_fe_user_event_monitor_mm', $id); // We have to delete the gabriel events BEFORE the tx_cal_events and // its related tx_cal_fe_user_event_monitor_mm records are gone /* Clean up any pending reminders for this event */ $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); try { $reminderService->deleteReminder($relationRecord['uid_local']); } catch (OutOfBoundsException $e) { } } break; } }
protected static function stopReminder($uid) { $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); $reminderService->deleteReminderForEvent($uid); }
function processDatamap_afterDatabaseOperations($status, $table, $id, &$fieldArray, &$tcemain) { /* If we have a new calendar event */ if (($table == 'tx_cal_event' || $table == 'tx_cal_exception_event') && count($fieldArray) > 1) { $event = BackendUtility::getRecord($table, $status == 'new' ? $tcemain->substNEWwithIDs[$id] : $id); /* If we're in a workspace, don't notify anyone about the event */ if ($event['pid'] > 0 && !$GLOBALS['BE_USER']->workspace) { /* Check Page TSConfig for a preview page that we should use */ $pageTSConf = BackendUtility::getPagesTSconfig($event['pid']); if ($pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']) { $pageIDForPlugin = $pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']; } else { $pageIDForPlugin = $event['pid']; } $page = BackendUtility::getRecord('pages', intval($pageIDForPlugin), 'doktype'); if ($page['doktype'] != 254) { $tx_cal_api = new \TYPO3\CMS\Cal\Controller\Api(); $tx_cal_api =& $tx_cal_api->tx_cal_api_without($pageIDForPlugin); if ($event['event_type'] == 3 && !$event['ref_event_id']) { $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller'); $modelObj->updateEventAttendees($event['uid'], 'tx_cal_phpicalendar'); } if ($table == 'tx_cal_event' && ($status == 'new' || $fieldArray['send_invitation'])) { /* Notify of new event */ $notificationService =& \TYPO3\CMS\Cal\Utility\Functions::getNotificationService(); $oldPath =& $notificationService->conf['view.']['event.']['eventModelTemplate']; $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cal'); $oldPath = str_replace('EXT:cal/', $extPath, $oldPath); // $oldPath = str_replace(PATH_site, '', $oldPath); $tx_cal_api->conf['view.']['event.']['eventModelTemplate'] = $oldPath; $oldBackPath = $GLOBALS['TSFE']->tmpl->getFileName_backPath; $GLOBALS['TSFE']->tmpl->getFileName_backPath = ''; $fileInfo = GeneralUtility::split_fileref($oldPath); $GLOBALS['TSFE']->tmpl->allowedPaths[] = $fileInfo['path']; $notificationService->controller->getDateTimeObject = new \TYPO3\CMS\Cal\Model\CalDate($event['start_date'] . '000000'); if ($status == 'new') { $notificationService->notify($event); } if ($fieldArray['send_invitation']) { $notificationService->invite($fieldArray); $fieldArray['send_invitation'] = 0; } $GLOBALS['TSFE']->tmpl->getFileName_backPath = $oldBackPath; } /** @var \TYPO3\CMS\Cal\Utility\RecurrenceGenerator $rgc */ $rgc = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Utility\\RecurrenceGenerator', $pageIDForPlugin); $rgc->generateIndexForUid($event['uid'], $table); if ($table == 'tx_cal_event' && $tx_cal_api->conf['view.']['event.']['remind']) { /* Schedule reminders for new and changed events */ $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService(); $reminderService->scheduleReminder($event['uid']); } } } } if ($table == 'pages' && $status == 'new') { $GLOBALS['BE_USER']->setAndSaveSessionData('cal_itemsProcFunc', array()); } }