/**
  * @param Address $address
  * @return bool
  */
 protected function isValid($address)
 {
     $result = true;
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'H2dmailsub', 'Pidmailsubscribe');
     $validationSettings = $settings['validation'];
     foreach ($validationSettings as $field => $validations) {
         $value = $address->{'get' . ucfirst($field)}();
         foreach ($validations as $validation => $validationSetting) {
             switch ($validation) {
                 case 'required':
                     if ($validationSetting === '1' && empty($value)) {
                         $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('validation.required', 'h2dmailsub'), time());
                         $this->result->forProperty($field)->addError($error);
                         $result = false;
                     }
                     break;
                 case 'email':
                     if (!empty($value) && $validationSetting === '1' && !\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($value)) {
                         $error = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\Error', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('validation.email', 'h2dmailsub'), time());
                         $this->result->forProperty($field)->addError($error);
                         $result = false;
                     }
                     break;
             }
         }
     }
     return $result;
 }
Example #2
0
 /**
  *
  */
 public function __construct()
 {
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
     $this->configuration = $this->objectManager->get('Aijko\\SharepointConnector\\Configuration\\ConfigurationManager')->getConfiguration();
     $this->configurationManager->setConfiguration($this->configuration);
     $this->viewUtility = $this->objectManager->get('Aijko\\SharepointConnector\\Utility\\View');
 }
 public function setUp()
 {
     $GLOBALS['TYPO3_DB'] = $this->getMock(DatabaseConnection::class);
     $this->subject = new TemplateMailMessage();
     $this->configurationManager = $this->getMock(ConfigurationManager::class, array('getConfiguration'), array(), '', false);
     $this->configurationManager->expects($this->any())->method('getConfiguration')->with(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue($this->frameworkConfiguration));
     $this->inject($this->subject, 'configurationManager', $this->configurationManager);
     $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
     $this->inject($this->subject, 'objectManager', $objectManager);
 }
Example #4
0
 /**
  * Generate and send Email
  *
  * @param string $template Template file in Templates/Email/
  * @param array $receiver Combination of Email => Name
  * @param array $sender Combination of Email => Name
  * @param string $subject Mail subject
  * @param array $variables Variables for assignMultiple
  * @param array $typoScript Add TypoScript to overwrite values
  * @return bool mail was sent?
  */
 public function send($template, $receiver, $sender, $subject, $variables = array(), $typoScript = array())
 {
     // config
     $email = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $this->cObj = $this->configurationManager->getContentObject();
     if (!empty($variables['user']) && method_exists($variables['user'], '_getProperties')) {
         $this->cObj->start($variables['user']->_getProperties());
     }
     if (!$this->cObj->cObjGetSingle($typoScript['_enable'], $typoScript['_enable.']) || count($receiver) === 0) {
         return FALSE;
     }
     // add embed images to mail body
     if ($this->cObj->cObjGetSingle($typoScript['embedImage'], $typoScript['embedImage.'])) {
         $images = GeneralUtility::trimExplode(',', $this->cObj->cObjGetSingle($typoScript['embedImage'], $typoScript['embedImage.']), 1);
         $imageVariables = array();
         foreach ($images as $image) {
             $imageVariables[] = $email->embed(\Swift_Image::fromPath($image));
         }
         $variables = array_merge($variables, array('embedImages' => $imageVariables));
     }
     /**
      * Generate and send Email
      */
     $email->setTo($receiver)->setFrom($sender)->setSubject($subject)->setCharset($GLOBALS['TSFE']->metaCharset)->setBody($this->getMailBody($template, $variables), 'text/html');
     // overwrite email receiver
     if ($this->cObj->cObjGetSingle($typoScript['receiver.']['email'], $typoScript['receiver.']['email.']) && $this->cObj->cObjGetSingle($typoScript['receiver.']['name'], $typoScript['receiver.']['name.'])) {
         $email->setTo(array($this->cObj->cObjGetSingle($typoScript['receiver.']['email'], $typoScript['receiver.']['email.']) => $this->cObj->cObjGetSingle($typoScript['receiver.']['name'], $typoScript['receiver.']['name.'])));
     }
     // overwrite email sender
     if ($this->cObj->cObjGetSingle($typoScript['sender.']['email'], $typoScript['sender.']['email.']) && $this->cObj->cObjGetSingle($typoScript['sender.']['name'], $typoScript['sender.']['name.'])) {
         $email->setFrom(array($this->cObj->cObjGetSingle($typoScript['sender.']['email'], $typoScript['sender.']['email.']) => $this->cObj->cObjGetSingle($typoScript['sender.']['name'], $typoScript['sender.']['name.'])));
     }
     // overwrite email subject
     if ($this->cObj->cObjGetSingle($typoScript['subject'], $typoScript['subject.'])) {
         $email->setSubject($this->cObj->cObjGetSingle($typoScript['subject'], $typoScript['subject.']));
     }
     // overwrite email CC receivers
     if ($this->cObj->cObjGetSingle($typoScript['cc'], $typoScript['cc.'])) {
         $email->setCc($this->cObj->cObjGetSingle($typoScript['cc'], $typoScript['cc.']));
     }
     // overwrite email priority
     if ($this->cObj->cObjGetSingle($typoScript['priority'], $typoScript['priority.'])) {
         $email->setPriority($this->cObj->cObjGetSingle($typoScript['priority'], $typoScript['priority.']));
     }
     // add attachments from typoscript
     if ($this->cObj->cObjGetSingle($typoScript['attachments'], $typoScript['attachments.'])) {
         $files = GeneralUtility::trimExplode(',', $this->cObj->cObjGetSingle($typoScript['attachments'], $typoScript['attachments.']), 1);
         foreach ($files as $file) {
             $email->attach(\Swift_Attachment::fromPath($file));
         }
     }
     $email->send();
     return $email->isSent();
 }
 /**
  * Returns the settings read from the TypoScript
  * @return array
  */
 public function getSettings()
 {
     if ($this->settings === NULL) {
         $this->settings = array();
         $typoScript = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
         if (isset($typoScript['plugin.']) && isset($typoScript['plugin.']['tx_rest.']) && isset($typoScript['plugin.']['tx_rest.']['settings.'])) {
             $this->settings = $typoScript['plugin.']['tx_rest.']['settings.'];
         }
     }
     return $this->settings;
 }
 /**
  * @return mixed
  */
 public function render()
 {
     $extensionConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $this->arguments['extension'], $this->arguments['plugin']);
     $configuration = array('extensionName' => $this->arguments['extension'], 'pluginName' => $this->arguments['plugin'], 'controllerName' => $this->arguments['controller'], 'action' => $this->arguments['action']);
     if ($this->arguments['vendor']) {
         $configuration['vendorName'] = $this->arguments['vendor'];
     }
     if (is_array($this->arguments['arguments'])) {
         $configuration = \array_merge($this->arguments['arguments'], $configuration);
     }
     $configuration = array_merge($extensionConfiguration, $configuration);
     ksort($configuration);
     return $this->bootstrap->run('', $configuration);
 }
 /**
  * Initialize Validator Function
  *
  * @return void
  */
 protected function init()
 {
     $this->configuration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $this->cObj = $this->configurationManager->getContentObject();
     $this->piVars = GeneralUtility::_GP('tx_femanager_pi1');
     $this->actionName = $this->piVars['__referrer']['@action'];
 }
Example #8
0
 /**
  * Get absolute paths for templates with fallback
  * 		Returns paths from *RootPaths and *RootPath and "hardcoded"
  * 		paths pointing to the EXT:femanager-resources.
  *
  * @param string $part "template", "partial", "layout"
  * @param boolean $returnAllPaths Default: FALSE, If FALSE only paths
  * 		for the first configuration (Paths, Path, hardcoded)
  * 		will be returned. If TRUE all (possible) paths will be returned.
  * @return array
  */
 public function getTemplateFolders($part = 'template', $returnAllPaths = FALSE)
 {
     $templatePaths = array();
     $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (!empty($extbaseFrameworkConfiguration['view'][$part . 'RootPaths'])) {
         $templatePaths = $extbaseFrameworkConfiguration['view'][$part . 'RootPaths'];
         krsort($templatePaths);
         $templatePaths = array_values($templatePaths);
     }
     if ($returnAllPaths || empty($templatePaths)) {
         $path = $extbaseFrameworkConfiguration['view'][$part . 'RootPath'];
         if (!empty($path)) {
             $templatePaths[] = $path;
         }
     }
     if ($returnAllPaths || empty($templatePaths)) {
         $templatePaths[] = 'EXT:femanager/Resources/Private/' . ucfirst($part) . 's/';
     }
     $templatePaths = array_unique($templatePaths);
     $absoluteTemplatePaths = array();
     foreach ($templatePaths as $templatePath) {
         $absoluteTemplatePaths[] = GeneralUtility::getFileAbsFileName($templatePath);
     }
     return $absoluteTemplatePaths;
 }
 /**
  * Returns the rendered iCalendar entry for the given event
  * according to RFC 2445
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event The event
  *
  * @return string
  */
 public function getiCalendarContent(\DERHANSEN\SfEventMgt\Domain\Model\Event $event)
 {
     /** @var \TYPO3\CMS\Fluid\View\StandaloneView $icalView */
     $icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $icalView->setFormat('txt');
     $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $templateRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['templateRootPath']);
     $layoutRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['layoutRootPath']);
     $icalView->setLayoutRootPath($layoutRootPath);
     $icalView->setTemplatePathAndFilename($templateRootPath . 'Event/ICalendar.txt');
     $icalView->assignMultiple(array('event' => $event, 'typo3Host' => GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')));
     // Render view and remove empty lines
     $icalContent = preg_replace('/^\\h*\\v+/m', '', $icalView->render());
     // Finally replace new lines with CRLF
     $icalContent = str_replace(chr(10), chr(13) . chr(10), $icalContent);
     return $icalContent;
 }
Example #10
0
 /**
  * Get the namespace of the uploaded file
  *
  * @return string
  */
 protected function getNamespace()
 {
     if ($this->namespace === '') {
         $frameworkSettings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
         $this->namespace = strtolower('tx_' . $frameworkSettings['extensionName'] . '_' . $frameworkSettings['pluginName']);
     }
     return $this->namespace;
 }
 /**
  * Get the URI for an AJAX Request.
  *
  * @return string the AJAX URI
  */
 protected function getAjaxUri()
 {
     list($table, $uid) = explode(':', $this->configurationManager->getContentObject()->currentRecord);
     $pluginName = $this->arguments['pluginName'];
     $extensionName = $this->arguments['extensionName'];
     $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
     $arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : array();
     $ajaxContext = array('record' => $table . '_' . $uid, 'path' => 'tt_content.list.20.' . str_replace('tx_', '', $pluginNamespace));
     $additionalParams['tx_typoscriptrendering']['context'] = json_encode($ajaxContext);
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $argumentPrefix = $uriBuilder->getArgumentPrefix();
     $uriBuilder->reset()->setArguments(array_merge(array($argumentPrefix => $arguments), $additionalParams))->setSection($this->arguments['section'])->setAddQueryString(TRUE)->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))->setFormat($this->arguments['format'])->setUseCacheHash(TRUE);
     // TYPO3 6.0 compatibility check:
     if (method_exists($uriBuilder, 'setAddQueryStringMethod')) {
         $uriBuilder->setAddQueryStringMethod($this->arguments['addQueryStringMethod']);
     }
     return $uriBuilder->build();
 }
Example #12
0
 /**
  * @param null $hashVars
  * @return string
  */
 private function getCacheID($hashVars = null)
 {
     $additionalHashVars = array('pid' => $GLOBALS['TSFE']->id, 'lang' => $GLOBALS['TSFE']->sys_language_uid, 'uid' => $this->_configurationManager->getContentObject()->data['uid']);
     if (!is_null($GLOBALS['TSFE']->fe_user->user)) {
         $additionalHashVars[] = $GLOBALS['TSFE']->fe_user->user['ses_id'];
     }
     $additionalHashVars = array_merge($additionalHashVars, $this->_request->getArguments());
     $hashVars = array_merge($additionalHashVars, $hashVars);
     $hashString = join('|', array_values($hashVars)) . join('|', array_keys($hashVars));
     return md5($hashString);
 }
 /**
  * @param string $action Target action
  * @param array $arguments Arguments
  * @param string $controller Target controller. If NULL current controllerName is used
  * @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
  * @param string $pluginName Target plugin. If empty, the current plugin name is used
  * @param integer $pageUid target page. See TypoLink destination
  * @param string $section the anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html
  * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
  * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
  * @param boolean $absolute If set, an absolute URI is rendered
  * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
  * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
  * @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
  * @param string $contextRecord The record that the rendering should depend upon. e.g. current (default: record is fetched from current Extbase plugin), tt_content:12 (tt_content record with uid 12), pages:15 (pages record with uid 15), 'currentPage' record of current page
  * @return string Rendered link
  */
 public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $section = '', $format = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array(), $addQueryStringMethod = NULL, $contextRecord = 'current')
 {
     if ($contextRecord === 'current') {
         $contextRecord = $this->configurationManager->getContentObject()->currentRecord;
     }
     if ($pluginName === NULL) {
         $pluginName = $this->controllerContext->getRequest()->getPluginName();
     }
     if ($extensionName === NULL) {
         $extensionName = $this->controllerContext->getRequest()->getControllerExtensionName();
     }
     $renderingConfiguration = $this->buildTypoScriptRenderingConfiguration($extensionName, $pluginName, $contextRecord);
     $additionalParams['tx_typoscriptrendering']['context'] = json_encode($renderingConfiguration);
     $uriBuilder = $this->controllerContext->getUriBuilder();
     $uriBuilder->reset()->setTargetPageUid($pageUid)->setUseCacheHash(TRUE)->setSection($section)->setFormat($format)->setLinkAccessRestrictedPages($linkAccessRestrictedPages)->setArguments($additionalParams)->setCreateAbsoluteUri($absolute)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
     // TYPO3 6.0 compatibility check:
     if (method_exists($uriBuilder, 'setAddQueryStringMethod')) {
         $uriBuilder->setAddQueryStringMethod($addQueryStringMethod);
     }
     return $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
 }
Example #14
0
 /**
  * This is the main method that is called when a task is executed
  * Note that there is no error handling, errors and failures are expected
  * to be handled and logged by the client implementations.
  * Should return TRUE on successful execution, FALSE on error.
  *
  * @return boolean Returns TRUE on successful execution, FALSE on error
  */
 public function execute()
 {
     $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['t3chimp']);
     /** @var ObjectManager $objectManager */
     $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
     $this->mailChimp = $this->objectManager->get('MatoIlic\\T3Chimp\\Service\\MailChimp');
     $this->userRepo = $this->objectManager->get('MatoIlic\\T3Chimp\\Domain\\Repository\\FrontendUserRepository');
     $this->configurationManager->setConfiguration(array('extensionName' => 'T3chimp'));
     $typoScriptSetup = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     if (isset($typoScriptSetup['config.']['tx_extbase.']['objects.'])) {
         $objectContainer = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container');
         foreach ($typoScriptSetup['config.']['tx_extbase.']['objects.'] as $classNameWithDot => $classConfiguration) {
             if (isset($classConfiguration['className'])) {
                 $originalClassName = rtrim($classNameWithDot, '.');
                 $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
             }
         }
     }
     /** @var ReflectionService $reflectionService */
     $reflectionService = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
     if (TYPO3_version < '7.1.0') {
         $reflectionService->setDataCache($GLOBALS['typo3CacheManager']->getCache('extbase_reflection'));
     } else {
         $cacheManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Cache\\CacheManager');
         $reflectionService->setDataCache($cacheManager->getCache('extbase_reflection'));
     }
     if (!$reflectionService->isInitialized()) {
         $reflectionService->initialize();
     }
     $this->mailChimp->initialize();
     $state = $this->executeTask();
     /** @var PersistenceManager $persistenceManager */
     $persistenceManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
     $persistenceManager->persistAll();
     $reflectionService->shutdown();
     return $state;
 }
Example #15
0
 /**
  * Configures the object manager object configuration from
  * config.tx_extbase.objects and plugin.tx_foo.objects
  *
  * @return void
  * @see initialize()
  */
 public function configureObjectManager()
 {
     $frameworkSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (!is_array($frameworkSetup['objects'])) {
         return;
     }
     $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container');
     foreach ($frameworkSetup['objects'] as $classNameWithDot => $classConfiguration) {
         if (isset($classConfiguration['className'])) {
             $originalClassName = rtrim($classNameWithDot, '.');
             $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
         }
     }
 }
Example #16
0
 /**
  * Initialize Method
  *
  * @return void
  */
 protected function init()
 {
     $config = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $this->pluginVariables = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tx_femanager_pi1');
     $controllerName = 'new';
     $validationName = 'validation';
     if ($this->pluginVariables['__referrer']['@controller'] !== 'New') {
         $controllerName = strtolower($this->pluginVariables['__referrer']['@controller']);
         if ($controllerName === 'invitation' && $this->pluginVariables['__referrer']['@action'] === 'edit') {
             $validationName = 'validationEdit';
         }
     }
     $this->validationSettings = $config['settings'][$controllerName][$validationName];
 }
 /**
  * Returns the rendered HTML for the given template
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param string $template Template
  * @param array $settings Settings
  *
  * @return string
  */
 protected function getNotificationBody($event, $registration, $template, $settings)
 {
     /** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView */
     $emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $emailView->setFormat('html');
     $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $templateRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['templateRootPath']);
     $layoutRootPath = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['plugin.']['tx_sfeventmgt.']['view.']['layoutRootPath']);
     $emailView->setLayoutRootPath($layoutRootPath);
     $emailView->setTemplatePathAndFilename($templateRootPath . $template);
     $emailView->assignMultiple(array('event' => $event, 'registration' => $registration, 'settings' => $settings, 'hmac' => $this->hashService->generateHmac('reg-' . $registration->getUid()), 'reghmac' => $this->hashService->appendHmac((string) $registration->getUid())));
     $emailBody = $emailView->render();
     return $emailBody;
 }
 /**
  * Returns the template folders for the given part
  *
  * @param string $part
  * @return array
  * @throws \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException
  */
 public function getTemplateFolders($part = 'template')
 {
     $extbaseConfig = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (!empty($extbaseConfig['view'][$part . 'RootPaths'])) {
         $templatePaths = $extbaseConfig['view'][$part . 'RootPaths'];
         $templatePaths = array_values($templatePaths);
     }
     if (empty($templatePaths)) {
         $path = $extbaseConfig['view'][$part . 'RootPath'];
         if (!empty($path)) {
             $templatePaths = $path;
         }
     }
     if (empty($templatePaths)) {
         $templatePaths = [];
         $templatePaths[] = 'EXT:sf_event_mgt/Resources/Private/' . ucfirst($part) . 's/';
     }
     $absolutePaths = [];
     foreach ($templatePaths as $templatePath) {
         $absolutePaths[] = GeneralUtility::getFileAbsFileName($templatePath);
     }
     return $absolutePaths;
 }
 /**
  * Notifies participants for the next event
  *
  * @return void
  */
 public function notifyCommand()
 {
     $this->settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
     $eventStartTime = $this->settings['eventStartTime'];
     $participantGroupId = $this->settings['participantGroupId'];
     $eventPageUid = $this->settings['eventPageUid'];
     $offset = 0;
     $eventStartDate = $this->div->nextEventDate($offset);
     $events = $this->eventRepository->findByStart($eventStartDate->format("Y-m-d H:i:s"));
     if ($events->count() == 0) {
         $this->div->createEvent($eventStartDate);
         $events = $this->eventRepository->findByStart($eventStartDate->format("Y-m-d H:i:s"));
     }
     if ($events->getFirst()->getActive()) {
         $this->initFrontend();
         $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
         $link = $cObj->typolink_URL(array('parameter' => "{$eventPageUid}", 'forceAbsoluteUrl' => 1));
         $acceptUrl = $link . "?&tx_pceventscheduler_pceventscheduler%5Baction%5D=accept";
         $cancelUrl = $link . "?&tx_pceventscheduler_pceventscheduler%5Baction%5D=cancel";
         $participantsUnknown = $this->participantRepository->findParticipantsUnknown($events->getFirst()->getUid(), $participantGroupId);
         if (isset($participantsUnknown)) {
             foreach ($participantsUnknown as $participantUnknown) {
                 $receiverEmail = $participantUnknown['email'];
                 $receiverName = $participantUnknown['name'];
                 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
                 $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
                 $mail->setFrom($from);
                 $mail->setSubject($this->settings['notifyMailSubject']);
                 $mail->setTo($receiverEmail);
                 $mail->setBody(str_replace(array('###name###', '###eventdate###', '###eventtime###', '###eventlocation###', '###acceptlink###', '###cancellink###'), array($receiverName, $events->getFirst()->getStart()->format("d.m.Y"), $eventStartTime, $events->getFirst()->getLocation(), $acceptUrl, $cancelUrl), $this->settings['notifyMailBody']), 'text/html');
                 $mail->send();
             }
         }
     }
     return true;
 }
 /**
  * Validates the given registration according to required fields set in plugin
  * settings. For boolean fields, the booleanValidator is used and it is assumed,
  * that boolean fields must have the value "TRUE" (for checkboxes)
  *
  * @param Registration $value Registration
  *
  * @return bool
  */
 protected function isValid($value)
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'SfEventMgt', 'Pievent');
     // If no required fields are set, then the registration is valid
     if ($settings['registration']['requiredFields'] === '' || !isset($settings['registration']['requiredFields'])) {
         return TRUE;
     }
     $requiredFields = array_map('trim', explode(',', $settings['registration']['requiredFields']));
     $result = TRUE;
     foreach ($requiredFields as $requiredField) {
         if ($value->_hasProperty($requiredField)) {
             $validator = $this->getValidator(gettype($value->_getProperty($requiredField)));
             /** @var \TYPO3\CMS\Extbase\Error\Result $validationResult */
             $validationResult = $validator->validate($value->_getProperty($requiredField));
             if ($validationResult->hasErrors()) {
                 $result = FALSE;
                 foreach ($validationResult->getErrors() as $error) {
                     $this->result->forProperty($requiredField)->addError($error);
                 }
             }
         }
     }
     return $result;
 }
 /**
  * Returns the rendered HTML for the given template
  *
  * @param Address $address
  * @param string $template
  * @param array $settings
  * @param string $confirmationCode
  * @param string $format
  * @return string
  */
 public function getNotificationContent($address, $template, $settings, $confirmationCode = null, $format)
 {
     $standaloneView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $standaloneView->setFormat($format);
     $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $standaloneView->setLayoutRootPaths($frameworkConfiguration['view']['layoutRootPaths']);
     $standaloneView->setPartialRootPaths($frameworkConfiguration['view']['partialRootPaths']);
     $standaloneView->setTemplateRootPaths($frameworkConfiguration['view']['templateRootPaths']);
     $standaloneView->setTemplate($template);
     $standaloneView->assign('address', $address);
     $standaloneView->assign('senderSignature', $settings['notification']['senderSignature']);
     $standaloneView->assign('confirmationCode', $confirmationCode);
     $emailBody = $standaloneView->render();
     return $emailBody;
 }
Example #22
0
 /**
  * Return path and filename for a file
  * 		respect *RootPaths and *RootPath
  *
  * @param string $relativePathAndFilename e.g. Email/Name.html
  * @param string $part "template", "partial", "layout"
  * @return string
  */
 public function getTemplatePath($relativePathAndFilename, $part = 'template')
 {
     $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     if (!empty($extbaseFrameworkConfiguration['view'][$part . 'RootPaths'])) {
         foreach ($extbaseFrameworkConfiguration['view'][$part . 'RootPaths'] as $path) {
             $absolutePath = GeneralUtility::getFileAbsFileName($path);
             if (file_exists($absolutePath . $relativePathAndFilename)) {
                 $absolutePathAndFilename = $absolutePath . $relativePathAndFilename;
             }
         }
     } else {
         $absolutePathAndFilename = GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view'][$part . 'RootPath'] . $relativePathAndFilename);
     }
     if (empty($absolutePathAndFilename)) {
         $absolutePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:femanager/Resources/Private/' . ucfirst($part) . 's/' . $relativePathAndFilename);
     }
     return $absolutePathAndFilename;
 }
Example #23
0
 public function createFile(array $sourceData, $propertyPath, $allowedTypes, $maxSize)
 {
     $this->messages = new \TYPO3\CMS\Extbase\Error\Result();
     $this->propertyPath = $propertyPath;
     $key = $propertyPath ? $propertyPath : '';
     $this->settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS);
     $uploadedFileData = $this->getUploadedFileData();
     $this->handleUploadErrors($uploadedFileData);
     if ($this->messages->hasErrors()) {
         $this->fileRepository->clearHeld($key);
         return $this->messages->getFirstError();
     } else {
         if (!$this->settings['file']['dontValidateType']) {
             $this->validateType($uploadedFileData, $allowedTypes);
         }
         if (!$this->settings['file']['dontValidateName']) {
             $this->validateName($uploadedFileData);
         }
         if (!$this->settings['file']['dontValidateSize']) {
             $this->validateSize($uploadedFileData, $maxSize);
         }
     }
     if ($this->messages->hasErrors()) {
         $this->fileRepository->clearHeld($key);
         return $this->messages->getFirstError();
     } else {
         // ok to make a file object
         $pathInfo = pathinfo($uploadedFileData['tmp_name']);
         $fileObject = $this->objectManager->create('CIC\\Cicbase\\Domain\\Model\\File');
         $fileObject->setTitle($sourceData['title']);
         // TODO: Set a default title if it's not provided.
         $fileObject->setDescription($sourceData['description']);
         $fileObject->setIsSaved(false);
         $fileObject->setOwner($GLOBALS['TSFE']->fe_user->user['uid']);
         $fileObject->setSize($uploadedFileData['size']);
         $fileObject->setMimeType($uploadedFileData['type']);
         $fileObject->setOriginalFilename($uploadedFileData['name']);
         $fileObject->setPath($uploadedFileData['tmp_name']);
         $fileObject->setFilename($pathInfo['filename']);
         $fileObject->setCrdate(time());
         $results = $this->fileRepository->hold($fileObject, $key);
         return $results;
     }
 }
 /**
  * @return array
  */
 protected function getSettings()
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     return $settings['plugin.']['tx_supermailerreg.']['settings.'];
 }
Example #25
0
 /**
  * Sets Plugin Settings
  *
  * @return void
  */
 public function setPluginSettings()
 {
     $this->pluginSettings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $this->extensionName, $this->pluginName);
 }
 /**
  * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManager $configurationManager
  * @return void
  */
 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager $configurationManager)
 {
     $this->configurationManager = $configurationManager;
     $this->settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
 }
Example #27
0
 /**
  * Initialize Validator Function
  *
  * @return void
  */
 protected function init()
 {
     $this->cObj = $this->configurationManager->getContentObject();
     $piVars = GeneralUtility::_GP('tx_femanager_pi1');
     $this->actionName = $piVars['__referrer']['@action'];
 }
Example #28
0
 /**
  * @param ConfigurationManager $manager
  */
 public function injectConfigurationManager(ConfigurationManager $manager)
 {
     $this->configurationManager = $manager;
     $settings = GeneralUtility::removeDotsFromTS($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
     $this->settings = $settings['plugin']['tx_supermailerreg'];
 }
 /**
  * Injection of configuration manager
  *
  * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
  *
  * @return void
  */
 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
 {
     $this->configurationManager = $configurationManager;
     $this->settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS);
     $this->frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
 }
 /**
  * Returns TRUE if what we are outputting may be cached
  *
  * @return boolean
  */
 protected function isCached()
 {
     $userObjType = $this->configurationManager->getContentObject()->getUserObjectType();
     return $userObjType !== ContentObjectRenderer::OBJECTTYPE_USER_INT;
 }