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 sendEmail($email, $htmlTemplate, $plainTemplate) { $this->controller->finish($htmlTemplate); $this->controller->finish($plainTemplate); $plainTemplate = str_replace(' ', ' ', strip_tags($plainTemplate)); if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 4005010) { $this->mailer->theParts['html']['content'] = $htmlTemplate; $this->mailer->theParts['html']['path'] = ''; $this->mailer->extractMediaLinks(); $this->mailer->extractHyperLinks(); $this->mailer->fetchHTMLMedia(); $this->mailer->substMediaNamesInHTML(0); // 0 = relative $this->mailer->substHREFsInHTML(); $this->mailer->setHTML($this->mailer->encodeMsg($this->mailer->theParts['html']['content'])); $this->mailer->substHREFsInHTML(); $this->mailer->setPlain(strip_tags($plainTemplate)); $this->mailer->setHeaders(); $this->mailer->setContent(); $this->mailer->setRecipient($email); $this->mailer->sendtheMail(); } else { $this->mailer->setTo(array($email)); $this->mailer->setBody(strip_tags($plainTemplate), 'text/plain'); $this->mailer->addPart(\TYPO3\CMS\Cal\Utility\Functions::fixURI($htmlTemplate), 'text/html'); $this->mailer->send(); } }