Skip to content

Commit

Permalink
[BUGFIX] e-mail object is not reset between admin and user mail (fixe…
Browse files Browse the repository at this point in the history
…s #59516)

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/formhandler/trunk@85760 735d13b6-9817-0410-8766-e36946ffe9aa
  • Loading branch information
reinhardfuehricht committed Jun 27, 2014
1 parent 7e3c518 commit b773adc
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions Classes/Finisher/Tx_Formhandler_Finisher_Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,37 @@ class Tx_Formhandler_Finisher_Mail extends Tx_Formhandler_AbstractFinisher {
public function process() {

//send emails
$this->initMailer('admin');
$this->sendMail('admin');
$this->initMailer('user');
$this->sendMail('user');

return $this->gp;
}

protected function initMailer($type) {
//init mailer object
$emailClass = $this->utilityFuncs->getPreparedClassName($this->settings['mailer.'], 'Mailer_HtmlMail');
$this->emailObj = $this->componentManager->getComponent($emailClass);
$this->emailObj->init($this->gp, $this->settings['mailer.']['config.']);

$this->settings = $this->parseEmailSettings($this->settings, $type);

// Defines default values
$defaultOptions = array(
'templateFile' => 'template_file',
'langFile' => 'lang_file',
);
foreach ($defaultOptions as $key => $option) {
$fileName = $this->utilityFuncs->pi_getFFvalue($this->cObj->data['pi_flexform'], $option);
if ($fileName) {
$this->settings[$key] = $fileName;
}
}

// Unset unnecessary variables.
unset($this->settings[$type . '.']);
}
/**
* Returns the final template code for given mode and suffix with substituted markers.
*
Expand Down Expand Up @@ -492,29 +517,6 @@ public function init($gp, $tsConfig) {
$this->gp = $gp;
$this->settings = $tsConfig;

//init mailer object
$emailClass = $this->utilityFuncs->getPreparedClassName($this->settings['mailer.'], 'Mailer_HtmlMail');
$this->emailObj = $this->componentManager->getComponent($emailClass);
$this->emailObj->init($this->gp, $this->settings['mailer.']['config.']);

$this->settings = $this->parseEmailSettings($tsConfig);

// Defines default values
$defaultOptions = array(
'templateFile' => 'template_file',
'langFile' => 'lang_file',
);
foreach ($defaultOptions as $key => $option) {
$fileName = $this->utilityFuncs->pi_getFFvalue($this->cObj->data['pi_flexform'], $option);
if ($fileName) {
$this->settings[$key] = $fileName;
}
}

// Unset unnecessary variables.
unset($this->settings['admin.']);
unset($this->settings['user.']);

}

/**
Expand All @@ -523,7 +525,7 @@ public function init($gp, $tsConfig) {
* @param array The TypoScript configuration
* @return array The parsed email settings
*/
protected function parseEmailSettings($tsConfig) {
protected function parseEmailSettings($tsConfig, $type) {
$emailSettings = $tsConfig;
$options = array (
'filePrefix',
Expand All @@ -548,8 +550,7 @@ protected function parseEmailSettings($tsConfig) {
'html.'
);

$emailSettings['admin'] = $this->parseEmailSettingsByType($emailSettings['admin.'], 'admin', $options);
$emailSettings['user'] = $this->parseEmailSettingsByType($emailSettings['user.'], 'user', $options);
$emailSettings[$type] = $this->parseEmailSettingsByType($emailSettings[$type . '.'], $type, $options);

return $emailSettings;
}
Expand Down

0 comments on commit b773adc

Please sign in to comment.