/**
  * Export of mails as email attachment
  *
  *        This task can send a mail export with an attachment
  *        (XLS or CSV) to a receiver or a group of receivers
  *
  * @param string $receiverEmails comma separated email addresses for export
  * @param string $senderEmail sender email address
  * @param string $subject Mail subject
  * @param int $pageUid Page Id with existing mails
  * @param string $domain Domainname for linkgeneration
  * @param int $period Select mails that are not older than this seconds
  * @param boolean $attachment Add export file as attachment to mail
  * @param string $fieldList Define needed fields with a commasepareted uid list (empty = all default fields)
  * @param string $format Fileformat can be 'xls' or 'csv'
  * @param string $storageFolder path where to save export file
  * @param string $fileName Define a fix filename without extension (empty = random filename)
  * @param string $emailTemplate path and filename of email template
  * @return bool
  */
 public function exportCommand($receiverEmails, $senderEmail = '*****@*****.**', $subject = 'New mail export', $pageUid = 0, $domain = 'http://www.domain.org/', $period = 2592000, $attachment = true, $fieldList = '', $format = 'xls', $storageFolder = 'typo3temp/tx_powermail/', $fileName = null, $emailTemplate = 'EXT:powermail/Resources/Private/Templates/Module/ExportTaskMail.html')
 {
     /** @var ExportService $exportService */
     $exportService = $this->objectManager->get(ExportService::class, $this->mailRepository->findAllInPid($pageUid, [], $this->getFilterVariables($period)), $format, ['domain' => $domain]);
     $exportService->setReceiverEmails($receiverEmails)->setSenderEmails($senderEmail)->setSubject($subject)->setFieldList($fieldList)->setAddAttachment($attachment)->setStorageFolder($storageFolder)->setFileName($fileName)->setEmailTemplate($emailTemplate);
     return $exportService->send();
 }
 /**
  * Parses variables again
  *
  * @param \In2code\Powermail\Domain\Model\Mail $mail Variables and Labels array
  * @param string $type "web" or "mail"
  * @param string $function "createAction", "senderMail", "receiverMail"
  * @return string Changed string
  */
 public function render(Mail $mail, $type = 'web', $function = 'createAction')
 {
     /** @var \TYPO3\CMS\Fluid\View\StandaloneView $parseObject */
     $parseObject = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $parseObject->setTemplateSource($this->removePowermailAllParagraphTagWrap($this->renderChildren()));
     $parseObject->assignMultiple(ArrayUtility::htmlspecialcharsOnArray($this->mailRepository->getVariablesWithMarkersFromMail($mail)));
     $parseObject->assignMultiple(ArrayUtility::htmlspecialcharsOnArray($this->mailRepository->getLabelsWithMarkersFromMail($mail)));
     $parseObject->assign('powermail_all', TemplateUtility::powermailAll($mail, $type, $this->settings, $function));
     return html_entity_decode($parseObject->render(), ENT_QUOTES, 'UTF-8');
 }
 /**
  * Preperation function for every table
  *
  * @return void
  */
 public function savePreflightFinisher()
 {
     if ($this->isSaveToAnyTableActivated()) {
         $this->addArrayToDataArray($this->mailRepository->getVariablesWithMarkersFromMail($this->mail));
         foreach ((array) array_keys($this->configuration) as $tableKey) {
             $table = StringUtility::removeLastDot($tableKey);
             $this->contentObject->start($this->getDataArray());
             $tableConfiguration = $this->configuration[$tableKey];
             if ($this->isSaveToAnyTableActivatedForSpecifiedTable($tableConfiguration)) {
                 $this->saveSpecifiedTablePreflight($table, $tableConfiguration);
             }
         }
     }
 }
예제 #4
0
 /**
  * Parsing variables with fluid engine to allow viewhelpers in flexform
  *
  * @param array $email
  * @param Mail $mail
  * @return void
  */
 protected function parseVariables(array &$email, Mail &$mail)
 {
     $parse = array('receiverName', 'receiverEmail', 'senderName', 'senderEmail', 'subject');
     foreach ($parse as $value) {
         $email[$value] = TemplateUtility::fluidParseString($email[$value], $this->mailRepository->getVariablesWithMarkersFromMail($mail));
     }
 }
 /**
  * Initialize
  *
  * @return void
  */
 public function initializeFinisher()
 {
     $this->contentObject = $this->configurationManager->getContentObject();
     $this->contentObject->start($this->mailRepository->getVariablesWithMarkersFromMail($this->mail));
     $typoScript = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
     $this->configuration = $typoScript['plugin.']['tx_powermail.']['settings.']['setup.']['marketing.']['sendPost.'];
 }
 /**
  * Initialize
  */
 public function initializeFinisher()
 {
     $configuration = $this->typoScriptService->convertPlainArrayToTypoScriptArray($this->settings);
     if (!empty($configuration['dbEntry.'])) {
         $this->configuration = $configuration['dbEntry.'];
     }
     if ($this->isConfigurationAvailable()) {
         $this->addArrayToDataArray(['uid' => $this->mail->getUid()]);
         $this->addArrayToDataArray($this->mailRepository->getVariablesWithMarkersFromMail($this->mail));
     }
 }
 /**
  * Validation of given Params
  *
  * @param Mail $mail
  * @return bool
  */
 public function isValid($mail)
 {
     if (empty($this->settings['validation.']['unique.'])) {
         return $this->isValidState();
     }
     foreach ($this->settings['validation.']['unique.'] as $marker => $amount) {
         if ((int) $amount === 0) {
             continue;
         }
         foreach ($mail->getAnswers() as $answer) {
             /** @var Answer $answer */
             if ($answer->getField()->getMarker() === $marker) {
                 $numberOfMails = $this->mailRepository->findByMarkerValueForm($marker, $answer->getValue(), $mail->getForm(), FrontendUtility::getStoragePage($this->getStoragePid()))->count();
                 if ($amount <= $numberOfMails) {
                     $this->setErrorAndMessage($answer->getField(), 'unique');
                 }
             }
         }
     }
     return $this->isValidState();
 }
 /**
  * Powermail SendPost - Send values via curl to a third party software
  *
  * @param Mail $mail
  * @param array $configuration TypoScript Configuration
  * @return void
  */
 public function sendFromConfiguration(Mail $mail, $configuration)
 {
     $contentObject = $this->configurationManager->getContentObject();
     $spConfiguration = $configuration['marketing.']['sendPost.'];
     // switch of if disabled
     $enable = $contentObject->cObjGetSingle($spConfiguration['_enable'], $spConfiguration['_enable.']);
     if (!$enable) {
         return;
     }
     $contentObject->start($this->mailRepository->getVariablesWithMarkersFromMail($mail));
     $parameters = $contentObject->cObjGetSingle($spConfiguration['values'], $spConfiguration['values.']);
     $curlSettings = ['url' => $spConfiguration['targetUrl'], 'params' => $parameters];
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $curlSettings['url']);
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $curlSettings['params']);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_exec($curl);
     curl_close($curl);
     if ($spConfiguration['debug']) {
         GeneralUtility::devLog('SendPost Values', 'powermail', 0, $curlSettings);
     }
 }
 /**
  * Test for getSenderNameFromArguments()
  *
  * @param array $values
  * @param string $fallback
  * @param string $defaultMailFromAddress
  * @param string $expectedResult
  * @return void
  * @dataProvider getSenderNameFromArgumentsReturnsStringDataProvider
  * @test
  */
 public function getSenderNameFromArgumentsReturnsString($values, $fallback, $defaultMailFromAddress, $expectedResult)
 {
     $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'] = $defaultMailFromAddress;
     $mail = new Mail();
     if (is_array($values)) {
         foreach ($values as $value) {
             $answer = new Answer();
             $answer->_setProperty('translateFormat', 'Y-m-d');
             $answer->_setProperty('valueType', is_array($values) ? 2 : 0);
             $field = new Field();
             $field->setType('input');
             $field->setSenderName(true);
             $answer->_setProperty('value', $value);
             $answer->setValueType(is_array($value) ? 1 : 0);
             $answer->setField($field);
             $mail->addAnswer($answer);
         }
     }
     $result = $this->generalValidatorMock->_callRef('getSenderNameFromArguments', $mail, $fallback);
     $this->assertSame($expectedResult, $result);
 }
예제 #10
0
파일: Div.php 프로젝트: advOpk/pwm
 /**
  * Check if logged in user is allowed to make changes in Pi2
  *
  * @param array $settings $settings TypoScript and Flexform Settings
  * @param int|\In2code\Powermail\Domain\Model\Mail $mail
  * @return bool
  */
 public function isAllowedToEdit($settings, $mail)
 {
     if (!is_a($mail, '\\In2code\\Powermail\\Domain\\Model\\Mail')) {
         $mail = $this->mailRepository->findByUid(intval($mail));
     }
     if (!$GLOBALS['TSFE']->fe_user->user['uid']) {
         return FALSE;
     }
     // array with usergroups of current logged in user
     $usergroups = GeneralUtility::trimExplode(',', $GLOBALS['TSFE']->fe_user->user['usergroup'], TRUE);
     // array with all allowed users
     $usersSettings = GeneralUtility::trimExplode(',', $settings['edit']['feuser'], TRUE);
     // array with all allowed groups
     $usergroupsSettings = GeneralUtility::trimExplode(',', $settings['edit']['fegroup'], TRUE);
     // replace "_owner" with uid of owner in array with users
     if (method_exists($mail, 'getFeuser') && is_numeric(array_search('_owner', $usersSettings))) {
         $usersSettings[array_search('_owner', $usersSettings)] = $mail->getFeuser();
     }
     // add owner groups to allowed groups (if "_owner")
     // if one entry is "_ownergroup"
     if (method_exists($mail, 'getFeuser') && is_numeric(array_search('_owner', $usergroupsSettings))) {
         // get usergroups of owner user
         $usergroupsFromOwner = $this->getUserGroupsFromUser($mail->getFeuser());
         // add owner usergroups to allowed usergroups array
         $usergroupsSettings = array_merge((array) $usergroupsSettings, (array) $usergroupsFromOwner);
     }
     // 1. check user
     if (in_array($GLOBALS['TSFE']->fe_user->user['uid'], $usersSettings)) {
         return TRUE;
     }
     // 2. check usergroup
     // if there is one of the groups allowed
     if (count(array_intersect($usergroups, $usergroupsSettings))) {
         return TRUE;
     }
     return FALSE;
 }
 /**
  * Get emails from FlexForm and parse with fluid
  *
  * @return array
  */
 protected function getEmailsFromFlexForm()
 {
     $emailString = TemplateUtility::fluidParseString($this->settings['receiver']['email'], $this->mailRepository->getVariablesWithMarkersFromMail($this->mail));
     return $this->parseEmailsFromString($emailString);
 }