Split email options into a separate page during first time setup
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 7 Mar 2023 10:13:01 +0000 (11:13 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 17 Apr 2023 16:45:10 +0000 (18:45 +0200)
wcfsetup/install/files/acp/templates/firstTimeSetupOptions.tpl
wcfsetup/install/files/acp/templates/firstTimeSetupOptionsEmail.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/acp/action/FirstTimeSetupAction.class.php
wcfsetup/install/files/lib/acp/form/FirstTimeSetupOptionsEmailForm.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/FirstTimeSetupOptionsForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 7cd371d8dd41fca57f74140a1f01657d138010d1..f802cfe73e0218c265ea08f54548d9413916472a 100644 (file)
@@ -13,7 +13,6 @@
 <header class="contentHeader">
        <div class="contentHeaderTitle">
                <h1 class="contentTitle">{lang}wcf.acp.firstTimeSetup.options{/lang}</h1>
-               <p class="contentHeaderDescription">{lang}wcf.acp.firstTimeSetup.options.description{/lang}</p>
        </div>
 </header>
 
diff --git a/wcfsetup/install/files/acp/templates/firstTimeSetupOptionsEmail.tpl b/wcfsetup/install/files/acp/templates/firstTimeSetupOptionsEmail.tpl
new file mode 100644 (file)
index 0000000..5ff2bf7
--- /dev/null
@@ -0,0 +1,34 @@
+{include file='header' pageTitle='wcf.acp.firstTimeSetup.optionsEmail'}
+
+{event name='javascriptInclude'}
+
+<script data-relocate="true">
+       $(function() {
+               new WCF.Option.Handler();
+       });
+       
+       {event name='javascriptInit'}
+</script>
+
+<header class="contentHeader">
+       <div class="contentHeaderTitle">
+               <h1 class="contentTitle">{lang}wcf.acp.firstTimeSetup.optionsEmail{/lang}</h1>
+       </div>
+</header>
+
+{if $success|isset}
+       <p class="success">{lang}wcf.global.success.edit{/lang}</p>
+{/if}
+
+{include file='formError'}
+
+<form method="post" action="{link controller='FirstTimeSetupOptionsEmail'}{/link}" enctype="multipart/form-data">
+       {include file='optionFieldList' langPrefix='wcf.acp.option.'}
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" name="__submit" accesskey="s">
+               {csrfToken}
+       </div>
+</form>
+
+{include file='footer'}
index 6a4467dded0a7316b03d9d5b1ec4e3ebbe1967d0..a9cf2a50fd16267ee42509190513113363b8691b 100644 (file)
@@ -29,6 +29,7 @@ final class FirstTimeSetupAction implements RequestHandlerInterface
         $controller = match (\FIRST_TIME_SETUP_STATE) {
             0 => FirstTimeSetupLicenseForm::class,
             1 => FirstTimeSetupOptionsForm::class,
+            2 => FirstTimeSetupOptionsEmailForm::class,
             default => FirstTimeSetupCompletedPage::class
         };
 
diff --git a/wcfsetup/install/files/lib/acp/form/FirstTimeSetupOptionsEmailForm.class.php b/wcfsetup/install/files/lib/acp/form/FirstTimeSetupOptionsEmailForm.class.php
new file mode 100644 (file)
index 0000000..2bd3bb5
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+
+namespace wcf\acp\form;
+
+use wcf\data\option\Option;
+use wcf\data\option\OptionAction;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\option\OptionHandler;
+use wcf\system\request\LinkHandler;
+use wcf\system\WCF;
+use wcf\util\HeaderUtil;
+
+/**
+ * Shows email options during first time setup.
+ *
+ * @author      Tim Duesterhus, Alexander Ebert
+ * @copyright   2001-2023 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ *
+ * @property OptionHandler $optionHandler
+ */
+final class FirstTimeSetupOptionsEmailForm extends AbstractOptionListForm
+{
+    /**
+     * @inheritDoc
+     */
+    public $neededPermissions = ['admin.configuration.canEditOption'];
+
+    /**
+     * list of options
+     * @var array
+     */
+    public $options = [];
+
+    /**
+     * @var string[]
+     */
+    public $optionNames = [
+        'mail_from_name',
+        'mail_from_address',
+        'mail_admin_address',
+        'module_contact_form',
+    ];
+
+    /**
+     * @inheritDoc
+     */
+    public function readParameters()
+    {
+        parent::readParameters();
+
+        if (\FIRST_TIME_SETUP_STATE == -1) {
+            throw new PermissionDeniedException();
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected function initOptionHandler()
+    {
+        parent::initOptionHandler();
+
+        $this->optionHandler->filterOptions($this->optionNames);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function readData()
+    {
+        parent::readData();
+
+        foreach ($this->optionNames as $optionName) {
+            $this->options[] = $this->optionHandler->getSingleOption($optionName);
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function save()
+    {
+        parent::save();
+
+        $saveOptions = $this->optionHandler->save('wcf.acp.option', 'wcf.acp.option.option');
+        $saveOptions[Option::getOptionByName('first_time_setup_state')->optionID] = 3;
+        $this->objectAction = new OptionAction([], 'updateAll', ['data' => $saveOptions]);
+        $this->objectAction->executeAction();
+        $this->saved();
+
+        \http_response_code(303);
+        HeaderUtil::redirect(LinkHandler::getInstance()->getControllerLink(
+            FirstTimeSetupAction::class,
+        ));
+
+        exit;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function assignVariables()
+    {
+        parent::assignVariables();
+
+        WCF::getTPL()->assign([
+            'options' => $this->options,
+            'optionNames' => $this->optionNames,
+        ]);
+    }
+}
index 0d5231de97556f9694df82736624d380afe6b65a..18690dc905a7820a9534e1e3fb0cd185a2a8fe13 100644 (file)
@@ -11,9 +11,9 @@ use wcf\system\WCF;
 use wcf\util\HeaderUtil;
 
 /**
- * Shows the option edit form.
+ * Shows general options during first time setup.
  *
- * @author      Alexander Ebert
+ * @author      Tim Duesterhus, Alexander Ebert
  * @copyright   2001-2023 WoltLab GmbH
  * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  *
@@ -38,10 +38,6 @@ final class FirstTimeSetupOptionsForm extends AbstractOptionListForm
     public $optionNames = [
         'page_title',
         'timezone',
-        'mail_from_name',
-        'mail_from_address',
-        'mail_admin_address',
-        'module_contact_form',
     ];
 
     /**
index cec1d62836017da02f447e718f9b23c900f514dd..ae3e4763671e565c29f43e90d8cd56d59370c953 100644 (file)
@@ -694,8 +694,8 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE
                <item name="wcf.acp.firstTimeSetup.license.noCredentialsConfirm"><![CDATA[Ohne Eingabe der Lizenzdaten fortfahren]]></item>
                <item name="wcf.acp.firstTimeSetup.license.explanation"><![CDATA[<p>Die Eingabe von Lizenzdaten ist zur Installation und zur Aktualisierung der gekauften WoltLab Suite™-Apps erforderlich.</p>]]></item>
                <item name="wcf.acp.firstTimeSetup.license.noCredentialsConfirm.description"><![CDATA[Die Eingabe der Lizenzdaten wird empfohlen. Falls noch keine Internetverbindung zu unseren Paket-Servern zur Verfügung steht oder Sie noch keine Lizenzdaten besitzen, können Sie die Eingabe überspringen. Lizenzdaten können jederzeit hinterlegt werden, um die gekauften WoltLab Suite™-Apps zu installieren.]]></item>
-               <item name="wcf.acp.firstTimeSetup.options"><![CDATA[Erstmalige Einrichtung: Einstellungen]]></item>
-               <item name="wcf.acp.firstTimeSetup.options.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Konfiguriere{else}Konfigurieren Sie{/if} die wichtigsten Einstellungen, diese können auch später über die Optionen verändert werden.]]></item>
+               <item name="wcf.acp.firstTimeSetup.options"><![CDATA[Erstmalige Einrichtung: Allgemeine Einstellungen]]></item>
+               <item name="wcf.acp.firstTimeSetup.optionsEmail"><![CDATA[Erstmalige Einrichtung: E-Mail-Einstellungen]]></item>
                <item name="wcf.acp.firstTimeSetup.completed"><![CDATA[Erstmalige Einrichtung abgeschlossen]]></item>
        </category>
        <category name="wcf.acp.group">
index 6c0a91c2cd11b908c18bf47439cffd03cb200c53..6543f587dd68b6b90e2fb294d82f91c6eada042b 100644 (file)
@@ -672,8 +672,8 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru
                <item name="wcf.acp.firstTimeSetup.license.noCredentialsConfirm"><![CDATA[Continue without entering license information]]></item>
                <item name="wcf.acp.firstTimeSetup.license.explanation"><![CDATA[<p>Entering license credentials is required to install and update the purchased WoltLab Suite™ Apps.</p>]]></item>
                <item name="wcf.acp.firstTimeSetup.license.noCredentialsConfirm.description"><![CDATA[Entering license information is recommended. If no network connection to our package servers is available yet, or if you do not yet have license information, you can skip this step. License information can be entered at any time to install purchased WoltLab Suite™ Apps.]]></item>
-               <item name="wcf.acp.firstTimeSetup.options"><![CDATA[First Time Setup: Settings]]></item>
-               <item name="wcf.acp.firstTimeSetup.options.description"><![CDATA[Configure the most important settings now, you can change them later at any time.]]></item>
+               <item name="wcf.acp.firstTimeSetup.options"><![CDATA[First Time Setup: General Settings]]></item>
+               <item name="wcf.acp.firstTimeSetup.optionsEmail"><![CDATA[First Time Setup: Email Settings]]></item>
                <item name="wcf.acp.firstTimeSetup.completed"><![CDATA[First Time Setup Completed]]></item>
        </category>
        <category name="wcf.acp.group">