/** * @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; }
/** * 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); }
/** * 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; }
/** * 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']; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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]; }
/** * 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']); } } }
/** * 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; }
/** * 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; }
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.']; }
/** * @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); }
/** * 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 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); }