Пример #1
0
 /**
  * Parses variables again
  *
  * @param array $variablesMarkers Variables and Markers array
  * @param \In2code\Powermail\Domain\Model\Mail $mail Variables and Labels array
  * @param string $type "web" or "mail"
  * @return string Changed string
  */
 public function render($variablesMarkers = array(), \In2code\Powermail\Domain\Model\Mail $mail, $type = 'web')
 {
     $parseObject = $this->objectManager->get('\\TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $parseObject->setTemplateSource($this->renderChildren());
     $parseObject->assignMultiple($this->div->htmlspecialcharsOnArray($variablesMarkers));
     $powermailAll = $this->div->powermailAll($mail, $type, $this->settings);
     $parseObject->assign('powermail_all', $powermailAll);
     return html_entity_decode($parseObject->render());
 }
Пример #2
0
 /**
  * Create Email Body
  *
  * @param array $email Array with all needed mail information
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @param array $settings TypoScript Settings
  * @return bool
  */
 protected function createEmailBody($email, \In2code\Powermail\Domain\Model\Mail &$mail, $settings)
 {
     $emailBodyObject = $this->objectManager->get('\\TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $emailBodyObject->getRequest()->setControllerExtensionName('Powermail');
     $emailBodyObject->getRequest()->setPluginName('Pi1');
     $emailBodyObject->getRequest()->setControllerName('Form');
     $emailBodyObject->setFormat('html');
     $templatePathAndFilename = $this->div->getTemplatePath() . $email['template'] . '.html';
     $emailBodyObject->setTemplatePathAndFilename($templatePathAndFilename);
     $emailBodyObject->setLayoutRootPath($this->div->getTemplatePath('layout'));
     $emailBodyObject->setPartialRootPath($this->div->getTemplatePath('partial'));
     // get variables
     // additional variables
     if (isset($email['variables']) && is_array($email['variables'])) {
         $emailBodyObject->assignMultiple($email['variables']);
     }
     // markers in HTML Template
     $variablesWithMarkers = $this->div->getVariablesWithMarkers($mail);
     $emailBodyObject->assign('variablesWithMarkers', $this->div->htmlspecialcharsOnArray($variablesWithMarkers));
     $emailBodyObject->assignMultiple($variablesWithMarkers);
     $emailBodyObject->assignMultiple($this->div->getLabelsAttachedToMarkers($mail));
     $emailBodyObject->assign('powermail_all', $this->div->powermailAll($mail, 'mail', $settings));
     // from rte
     $emailBodyObject->assign('powermail_rte', $email['rteBody']);
     $emailBodyObject->assign('marketingInfos', Div::getMarketingInfos());
     $emailBodyObject->assign('mail', $mail);
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeRender', array($emailBodyObject, $email, $mail, $settings));
     $body = $emailBodyObject->render();
     $mail->setBody($body);
     return $body;
 }
Пример #3
0
 /**
  * Main Function
  *
  * @param array $params
  * @param object $pObj
  * @return string
  */
 public function getInfo($params = array(), $pObj)
 {
     // settings
     $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['powermail']);
     if ($confArr['disablePluginInformation']) {
         return '';
     }
     $this->params = $params;
     //		$returnUrl = 'alt_doc.php?edit[tt_content][' . $pa['row']['uid'] . ']=edit&returnUrl=' . GeneralUtility::_GET('returnUrl');
     //		$returnUrl = rawurlencode($returnUrl);
     $returnUrl = rawurlencode(Div::getSubFolderOfCurrentUrl() . GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT'));
     $editFormLink = Div::getSubFolderOfCurrentUrl() . 'typo3/alt_doc.php?edit[tx_powermail_domain_model_forms][' . $this->getFormProperty($this->getFieldFromFlexform('main', 'settings.flexform.main.form'), 'uid') . ']=edit';
     $editFormLink .= '&returnUrl=' . $returnUrl;
     // let's go
     $array = array($GLOBALS['LANG']->sL($this->locallangPath . 'receiverEmail') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.email'), $GLOBALS['LANG']->sL($this->locallangPath . 'receiverName') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.name'), $GLOBALS['LANG']->sL($this->locallangPath . 'subject') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.subject'), $GLOBALS['LANG']->sL($this->locallangPath . 'form') => '<a href="' . $editFormLink . '" style="text-decoration:underline;">' . $this->getFormProperty($this->getFieldFromFlexform('main', 'settings.flexform.main.form')) . '</a>', $GLOBALS['LANG']->sL($this->locallangPath . 'confirmationPage') => '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-check.png" alt="1" />', $GLOBALS['LANG']->sL($this->locallangPath . 'optin') => '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-check.png" alt="1" />');
     if (!$this->getFieldFromFlexform('main', 'settings.flexform.main.confirmation')) {
         $array[$GLOBALS['LANG']->sL($this->locallangPath . 'confirmationPage')] = '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-notchecked.png" alt="0" />';
     }
     if (!$this->getFieldFromFlexform('main', 'settings.flexform.main.optin')) {
         $array[$GLOBALS['LANG']->sL($this->locallangPath . 'optin')] = '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-notchecked.png" alt="0" />';
     }
     if ($this->showTable) {
         return $this->createOutput($array);
     }
     return '';
 }
Пример #4
0
 /**
  * Cretae Array for Field Selector
  *
  * @param array $params
  * @param object $pObj Parent Object
  * @return void
  */
 public function getFieldSelection(&$params, $pObj)
 {
     $formUid = $this->getFormFromFlexform($params);
     if (!$formUid) {
         $params['items'] = array(array('Please select a form (Main Settings)', ''));
         return;
     }
     foreach ((array) Div::getFieldsFromFormWithSelectQuery($formUid) as $field) {
         $params['items'][] = array($field['title'] . ' {' . $field['marker'] . '}', $field['uid']);
     }
 }
Пример #5
0
 /**
  * Initially fill the marker field from title
  *
  * @param \string $status mode of change
  * @param \string $table the table which gets changed
  * @param \string $uid uid of the record
  * @param \array $fieldArray the updateArray
  * @param \array $pObj
  * @return void
  */
 public function processDatamap_postProcessFieldArray($status, $table, $uid, &$fieldArray, $pObj)
 {
     if ($table != 'tx_powermail_domain_model_fields') {
         return;
     }
     $markers = array_merge((array) $this->existingMarkers, (array) $this->marker);
     $this->makeUniqueValueInArray($markers);
     // set marker for new field
     if (isset($this->data['tx_powermail_domain_model_fields'][$uid]['marker']) || stristr($uid, 'NEW')) {
         $fieldArray['marker'] = 'marker_' . Div::createRandomString(8, FALSE);
         if (!empty($markers['_' . $uid])) {
             $fieldArray['marker'] = $markers['_' . $uid];
         }
     }
     // revise marker if related to a new page and not allowed
     if (!empty($markers['_' . $uid]) && $markers['_' . $uid] !== $this->marker['_' . $uid]) {
         $fieldArray['marker'] = $markers['_' . $uid];
     }
 }
Пример #6
0
 /**
  * Modify settings for select, radio and checkboxes
  * 		option1 =>
  * 			label => Red Shoes
  * 			value => red
  * 			selected => 1
  *
  * @return string
  */
 public function getModifiedSettings()
 {
     return Div::optionArray($this->getSettings(), $this->getCreateFromTyposcript());
 }
Пример #7
0
 /**
  * @return array
  */
 public function getMarketingPageFunnel()
 {
     if (\In2code\Powermail\Utility\Div::isJsonArray($this->marketingPageFunnel)) {
         return json_decode($this->marketingPageFunnel);
     }
     return (array) $this->marketingPageFunnel;
 }
Пример #8
0
 /**
  * Modify settings for select, radio and checkboxes
  * 		option1 =>
  * 			label => Red Shoes
  * 			value => red
  * 			selected => 1
  *
  * @return string
  */
 public function getModifiedSettings()
 {
     return \In2code\Powermail\Utility\Div::optionArray($this->getSettings(), $this->getCreateFromTyposcript());
 }
 /**
  * Check if sender_email or sender_name was set
  *
  * @param $formUid
  * @return bool
  */
 protected function senderEmailOrSenderNameSet($formUid)
 {
     $fields = Div::getFieldsFromFormWithSelectQuery($formUid);
     foreach ($fields as $property) {
         foreach ($property as $column => $value) {
             if ($column === 'sender_email' && $value === '1') {
                 return TRUE;
             }
             if ($column === 'sender_name' && $value === '1') {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
Пример #10
0
 /**
  * Sets the value
  *
  * @param mixed $value
  * @dontvalidate $value
  * @return void
  */
 public function setValue($value)
 {
     // if array, encode to string
     if (is_array($value)) {
         $value = json_encode($value);
     }
     // if date, get timestamp (datepicker)
     if (method_exists($this->getField(), 'getType') && Div::getDataTypeFromFieldType($this->getField()->getType()) === 2 && !is_numeric($value)) {
         $format = LocalizationUtility::translate('datepicker_format_' . $this->getField()->getDatepickerSettings(), 'powermail');
         $date = \DateTime::createFromFormat($format, $value);
         if ($date) {
             $value = $date->getTimestamp();
         } else {
             // fallback html5 date field - always Y-m-d H:i
             $date = new \DateTime($value);
             if ($date) {
                 $value = $date->getTimestamp();
             }
         }
     }
     $this->value = $value;
 }
Пример #11
0
 /**
  * Reporting Marketing
  *
  * @return void
  */
 public function reportingMarketingBeAction()
 {
     $mails = $this->mailRepository->findAllInPid(GeneralUtility::_GP('id'), $this->settings, $this->piVars);
     $firstMail = $this->mailRepository->findFirstInPid(GeneralUtility::_GP('id'));
     $groupedMarketingStuff = Div::getGroupedMarketingStuff($mails);
     $this->view->assign('groupedMarketingStuff', $groupedMarketingStuff);
     $this->view->assign('mails', $mails);
     $this->view->assign('firstMail', $firstMail);
     $this->view->assign('piVars', $this->piVars);
     $this->view->assign('pid', GeneralUtility::_GP('id'));
     $this->view->assign('token', \TYPO3\CMS\Backend\Utility\BackendUtility::getUrlToken('tceAction'));
     $this->view->assign('perPage', $this->settings['perPage'] ? $this->settings['perPage'] : 10);
 }
Пример #12
0
 /**
  * Reformat array for createAction
  *
  * @return void
  */
 protected function reformatParamsForAction()
 {
     $arguments = $this->request->getArguments();
     if (!isset($arguments['field'])) {
         return;
     }
     $newArguments = array('mail' => $arguments['mail']);
     // allow subvalues in new property mapper
     $mailMvcArgument = $this->arguments->getArgument('mail');
     $propertyMappingConfiguration = $mailMvcArgument->getPropertyMappingConfiguration();
     $propertyMappingConfiguration->allowProperties('answers');
     $propertyMappingConfiguration->allowCreationForSubProperty('answers');
     $propertyMappingConfiguration->allowModificationForSubProperty('answers');
     $propertyMappingConfiguration->allowProperties('form');
     $propertyMappingConfiguration->allowCreationForSubProperty('form');
     $propertyMappingConfiguration->allowModificationForSubProperty('form');
     // allow creation of new objects (for validation)
     $propertyMappingConfiguration->setTypeConverterOptions('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', array(PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => TRUE, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED => TRUE));
     $i = 0;
     foreach ((array) $arguments['field'] as $marker => $value) {
         // ignore internal fields (honeypod)
         if (substr($marker, 0, 2) === '__') {
             continue;
         }
         $fieldUid = $this->div->getFieldUidFromMarker($marker, $arguments['mail']['form']);
         // Skip fields without Uid (secondary password, upload)
         if ($fieldUid === 0) {
             continue;
         }
         // allow subvalues in new property mapper
         $propertyMappingConfiguration->forProperty('answers')->allowProperties($i);
         $propertyMappingConfiguration->forProperty('answers.' . $i)->allowAllProperties();
         $propertyMappingConfiguration->allowCreationForSubProperty('answers.' . $i);
         $propertyMappingConfiguration->allowModificationForSubProperty('answers.' . $i);
         $valueType = Div::getDataTypeFromFieldType($this->div->getFieldTypeFromMarker($marker, $arguments['mail']['form']));
         if ($valueType === 3 && is_array($value)) {
             $value = BasicFileFunctions::getUniqueNamesForFileUploads($value, $this->settings, FALSE);
         }
         if (is_array($value)) {
             if (empty($value)) {
                 $value = '';
             } else {
                 $value = json_encode($value);
             }
         }
         $newArguments['mail']['answers'][$i] = array('field' => strval($fieldUid), 'value' => $value, 'valueType' => $valueType);
         // edit form: add answer id
         if (!empty($arguments['field']['__identity'])) {
             $newArguments['mail']['answers'][$i]['__identity'] = $this->answerRepository->findByFieldAndMail($fieldUid, $arguments['field']['__identity'])->getUid();
         }
         $i++;
     }
     // edit form: add mail id
     if (!empty($arguments['field']['__identity'])) {
         $newArguments['mail']['__identity'] = $arguments['field']['__identity'];
     }
     $this->request->setArguments($newArguments);
     $this->request->setArgument('field', NULL);
 }
Пример #13
0
 /**
  * Create Image File
  *
  * @param $content
  * @return string	Image HTML Code
  */
 protected function createImage($content)
 {
     $startimage = GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . Div::getSubFolderOfCurrentUrl();
     $startimage .= $GLOBALS['TSFE']->tmpl->getFileName($this->configuration['captcha.']['default.']['image']);
     // if startfile does not exist
     if (!is_file($startimage)) {
         return 'Error: No Image found on ' . $startimage;
     }
     // Backgroundimage
     $img = ImageCreateFromPNG($startimage);
     $config = array();
     $config['color_rgb'] = sscanf($this->configuration['captcha.']['default.']['textColor'], '#%2x%2x%2x');
     $config['color'] = ImageColorAllocate($img, $config['color_rgb'][0], $config['color_rgb'][1], $config['color_rgb'][2]);
     $config['font'] = GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . Div::getSubFolderOfCurrentUrl();
     $config['font'] .= $GLOBALS['TSFE']->tmpl->getFileName($this->configuration['captcha.']['default.']['font']);
     $config['fontsize'] = $this->configuration['captcha.']['default.']['textSize'];
     $config['angle'] = GeneralUtility::trimExplode(',', $this->configuration['captcha.']['default.']['textAngle'], TRUE);
     $config['fontangle'] = mt_rand($config['angle'][0], $config['angle'][1]);
     $config['distance_hor'] = GeneralUtility::trimExplode(',', $this->configuration['captcha.']['default.']['distanceHor'], TRUE);
     $config['fontdistance_hor'] = mt_rand($config['distance_hor'][0], $config['distance_hor'][1]);
     $config['distance_vert'] = GeneralUtility::trimExplode(',', $this->configuration['captcha.']['default.']['distanceVer'], TRUE);
     $config['fontdistance_vert'] = mt_rand($config['distance_vert'][0], $config['distance_vert'][1]);
     imagettftext($img, $config['fontsize'], $config['fontangle'], $config['fontdistance_hor'], $config['fontdistance_vert'], $config['color'], $config['font'], $content);
     imagepng($img, GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT') . '/' . Div::getSubFolderOfCurrentUrl() . $GLOBALS['TSFE']->tmpl->getFileName($this->captchaImage));
     imagedestroy($img);
     return $GLOBALS['TSFE']->tmpl->getFileName($this->getCaptchaImage()) . '?hash=' . time();
 }
Пример #14
0
 /**
  * Get commaseparated list of PID under a starting Page
  *
  * @param int|string $startPid Integer or "current"
  * @return string
  */
 protected function getPidListFromStartingPoint($startPid = 0)
 {
     /** @var \TYPO3\CMS\Core\Database\QueryGenerator $queryGenerator */
     $queryGenerator = GeneralUtility::makeInstance('\\TYPO3\\CMS\\Core\\Database\\QueryGenerator');
     if ($startPid === 'current') {
         $startPid = Div::getPidFromBackendPage();
     }
     $list = $queryGenerator->getTreeList($startPid, 10, 0, 1);
     return $list;
 }
Пример #15
0
 /**
  * Get Randomized Filename and overwrite $_FILES array
  *
  * @param string &$filename
  * @param bool $randomized
  * @return void
  */
 public function getAndSetRandomizedFileName(&$filename, $randomized)
 {
     if (!$randomized) {
         return;
     }
     $newFilename = Div::createRandomString(32, FALSE) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
     if (isset($_FILES['tx_powermail_pi1']['name']['field'])) {
         foreach (array_keys($_FILES['tx_powermail_pi1']['name']['field']) as $marker) {
             foreach ($_FILES['tx_powermail_pi1']['name']['field'][$marker] as $key => $originalFileName) {
                 self::cleanFileName($originalFileName);
                 if ($originalFileName === $filename) {
                     $_FILES['tx_powermail_pi1']['name']['field'][$marker][$key] = $newFilename;
                 }
             }
         }
     }
     $filename = $newFilename;
 }
Пример #16
0
 /**
  * Is Backend Admin?
  *
  * @return bool
  */
 public function render()
 {
     return Div::isBackendAdmin();
 }
Пример #17
0
 /**
  * Check if logged in User is allowed to edit
  *
  * @param array $settings TypoScript and FlexForm Settings
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @return bool
  */
 public function render($settings = array(), $mail)
 {
     return $this->div->isAllowedToEdit($settings, $mail);
 }
Пример #18
0
 /**
  * Object initialization
  *
  * @return void
  */
 public function initializeObject()
 {
     // merge typoscript to flexform
     Div::mergeTypoScript2FlexForm($this->settings, 'Pi2');
 }
Пример #19
0
 /**
  * Session Check: Checks if session was started correct on form delivery
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail
  * @param float $indication Indication if check fails
  * @return void
  */
 protected function sessionCheck(\In2code\Powermail\Domain\Model\Mail $mail, $indication = 1.0)
 {
     // Stop if indicator was turned to 0 OR if last action was optinConfirm
     if (!$indication || $this->referrer == 'optinConfirm') {
         return;
     }
     $time = Div::getFormStartFromSession($mail->getForm()->getUid());
     // if check failes
     if (!isset($time) || !$time) {
         $this->increaseSpamIndicator($indication);
         $this->addMessage(__FUNCTION__ . ' failed');
     }
 }
Пример #20
0
 /**
  * Initializes this object
  *
  * @return void
  */
 public function initializeObject()
 {
     $this->cObj = $this->configurationManager->getContentObject();
     $typoScriptSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $this->conf = $typoScriptSetup['plugin.']['tx_powermail.']['settings.']['setup.'];
     // merge extension manager settings and typoscript and flexform
     Div::mergeTypoScript2FlexForm($this->settings);
     $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'Settings', array($this));
     if ($this->settings['debug']['settings']) {
         GeneralUtility::devLog('Settings', $this->extensionName, 0, $this->settings);
     }
 }
Пример #21
0
 /**
  * createRandomStringAlwaysReturnsStringsOfGivenLength Test
  *
  * @param int $length
  * @param bool $uppercase
  * @dataProvider createRandomStringAlwaysReturnsStringsOfGivenLengthDateProvider
  * @return void
  * @test
  */
 public function createRandomStringAlwaysReturnsStringsOfGivenLength($length, $uppercase)
 {
     for ($i = 0; $i < 10; $i++) {
         $string = \In2code\Powermail\Utility\Div::createRandomString($length, $uppercase);
         if ($uppercase) {
             $regex = '~[a-zA-Z0-9]{' . $length . '}~';
         } else {
             $regex = '~[a-z0-9]{' . $length . '}~';
         }
         $this->assertSame(1, preg_match($regex, $string));
     }
 }