[TASK] Add preset for mail SMTP settings in install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Configuration / Mail / SendmailPreset.php
index 66e4e5a..9ffe540 100644 (file)
@@ -19,62 +19,73 @@ use TYPO3\CMS\Install\Configuration;
 /**
  * Sendmail path handling preset
  */
-class SendmailPreset extends Configuration\AbstractPreset {
+class SendmailPreset extends Configuration\AbstractPreset
+{
+    /**
+     * @var string Name of preset
+     */
+    protected $name = 'Sendmail';
 
-       /**
-        * @var string Name of preset
-        */
-       protected $name = 'Sendmail';
+    /**
+     * @var int Priority of preset
+     */
+    protected $priority = 50;
 
-       /**
-        * @var int Priority of preset
-        */
-       protected $priority = 50;
+    /**
+     * @var array Configuration values handled by this preset
+     */
+    protected $configurationValues = [
+        'MAIL/transport' => 'sendmail',
+        'MAIL/transport_sendmail_command' => '',
+        'MAIL/transport_smtp_server' => '',
+        'MAIL/transport_smtp_encrypt' => '',
+        'MAIL/transport_smtp_username' => '',
+        'MAIL/transport_smtp_password' => '',
+        ];
 
-       /**
-        * @var array Configuration values handled by this preset
-        */
-       protected $configurationValues = array(
-               'MAIL/transport_sendmail_command' => '',
-       );
+    /**
+     * Get configuration values to activate prefix
+     *
+     * @return array Configuration values needed to activate prefix
+     */
+    public function getConfigurationValues()
+    {
+        $configurationValues = $this->configurationValues;
+        $configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
+        if ($this->postValues['Mail']['enable'] === 'Sendmail') {
+            $configurationValues['MAIL/transport'] = 'sendmail';
+        }
+        return $configurationValues;
+    }
 
-       /**
-        * Get configuration values to activate prefix
-        *
-        * @return array Configuration values needed to activate prefix
-        */
-       public function getConfigurationValues() {
-               $configurationValues = $this->configurationValues;
-               $configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
-               return $configurationValues;
-       }
+    /**
+     * Check if sendmail path if set
+     *
+     * @return bool TRUE if sendmail path if set
+     */
+    public function isAvailable()
+    {
+        return !empty($this->getSendmailPath());
+    }
 
-       /**
-        * Check if sendmail path if set
-        *
-        * @return bool TRUE if sendmail path if set
-        */
-       public function isAvailable() {
-               return !empty($this->getSendmailPath());
-       }
-
-       /**
-        * Path where executable was found
-        *
-        * @return string|bool Sendmail path or FALSE if not set
-        */
-       public function getSendmailPath() {
-               return ini_get('sendmail_path');
-       }
-
-       /**
-        * Check is preset is currently active on the system
-        *
-        * @return bool TRUE if preset is active
-        */
-       public function isActive() {
-               $this->configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
-               return parent::isActive();
-       }
+    /**
+     * Path where executable was found
+     *
+     * @return string|bool Sendmail path or FALSE if not set
+     */
+    public function getSendmailPath()
+    {
+        return ini_get('sendmail_path');
+    }
 
+    /**
+     * Check is preset is currently active on the system
+     *
+     * @return bool TRUE if preset is active
+     */
+    public function isActive()
+    {
+        $this->configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
+        return parent::isActive();
+    }
 }