Disallow some pages from landing page
authorAlexander Ebert <ebert@woltlab.com>
Fri, 21 Jul 2017 10:26:31 +0000 (12:26 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 21 Jul 2017 10:26:31 +0000 (12:26 +0200)
Closes #2344

XSD/page.xsd
com.woltlab.wcf/page.xml
wcfsetup/install/files/acp/templates/applicationEdit.tpl
wcfsetup/install/files/acp/templates/pageAdd.tpl
wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php
wcfsetup/install/files/lib/acp/form/PageEditForm.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php
wcfsetup/setup/db/install.sql

index 4f95efbc1206423cc37664cd20c9301959c586cd..bad6fc7a305287fb23e81edf381039b23267d736 100644 (file)
@@ -57,6 +57,7 @@
                                        <xs:element name="requireObjectID" type="woltlab_boolean" minOccurs="0" />
                                        <xs:element name="availableDuringOfflineMode" type="woltlab_boolean" minOccurs="0" />
                                        <xs:element name="allowSpidersToIndex" type="woltlab_boolean" minOccurs="0" />
+                                       <xs:element name="excludeFromLandingPage" type="woltlab_boolean" minOccurs="0" />
                                        <xs:element name="cssClassName" type="woltlab_varchar" minOccurs="0" />
                                </xs:choice>
                        </xs:extension>
index 53629e03e2cbca1a6b90ca3b961cdab56ddb4d2a..d1b2e44751075da32758d24d05f34668d599fe4c 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/vortex/page.xsd">
+<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/tornado/page.xsd">
        <import>
                <!-- dynamic -->
                <page identifier="com.woltlab.wcf.MembersList">
                        <name language="en">New Email Address Verification</name>
                        <hasFixedParent>1</hasFixedParent>
                        <parent>com.woltlab.wcf.AccountManagement</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>New Email Address Verification</title>
                        <name language="en">New Email Activation Code Request</name>
                        <hasFixedParent>1</hasFixedParent>
                        <parent>com.woltlab.wcf.AccountManagement</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>New Email Activation Code Request</title>
                        <name language="de">Anmeldung</name>
                        <name language="en">Login</name>
                        <parent>com.woltlab.wcf.AccountManagement</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>Login</title>
                        <name language="de">Kennwort vergessen</name>
                        <name language="en">Lost Password</name>
                        <parent>com.woltlab.wcf.AccountManagement</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>Lost Password</title>
                        <name language="de">Neues Kennwort</name>
                        <name language="en">New Password Request</name>
                        <parent>com.woltlab.wcf.AccountManagement</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>New Password Request</title>
                        <controller>wcf\form\RegisterForm</controller>
                        <name language="de">Registrierung</name>
                        <name language="en">Registration</name>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>Registration</title>
                        <name language="en">Complete Registration</name>
                        <hasFixedParent>1</hasFixedParent>
                        <parent>com.woltlab.wcf.Register</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>Complete Registration</title>
                        <name language="en">New Activation Code Request</name>
                        <hasFixedParent>1</hasFixedParent>
                        <parent>com.woltlab.wcf.Register</parent>
+                       <excludeFromLandingPage>1</excludeFromLandingPage>
                        
                        <content language="en">
                                <title>New Activation Code Request</title>
index 8b2efa1f759f5fa186aab7b4930c44db1d5bbe07..440a08c05734bc675012d859bdf227cd4c27fe40 100644 (file)
@@ -65,7 +65,7 @@
                                        <option value="0">{lang}wcf.global.noSelection{/lang}</option>
                                        
                                        {foreach from=$pageNodeList item=pageNode}
-                                               {if !$pageNode->requireObjectID}
+                                               {if !$pageNode->requireObjectID && !$pageNode->excludeFromLandingPage}
                                                        <option value="{@$pageNode->pageID}"{if $pageNode->pageID == $landingPageID} selected{/if} data-identifier="{@$pageNode->identifier}">{if $pageNode->getDepth() > 1}{@"&nbsp;&nbsp;&nbsp;&nbsp;"|str_repeat:($pageNode->getDepth() - 1)}{/if}{$pageNode->name}</option>
                                                {/if}
                                        {/foreach}
index 6b087aebcf762aaadf1a971b4e0f978e6b17380e..f28a395022a9e0f6bb96c5861fbfcf3eef03b4fa 100644 (file)
                                        </dd>
                                </dl>
                                
-                               {if $action != 'edit' || !$page->requireObjectID}
+                               {if $action != 'edit' || (!$page->requireObjectID && !$page->excludeFromLandingPage)}
                                        <dl>
                                                <dt></dt>
                                                <dd>
index 0295a4c4add7847d785a64c96505a505de6ee949..66842b64c82676fc8d66620022d49871422da8e3 100644 (file)
@@ -183,7 +183,7 @@ class ApplicationEditForm extends AbstractForm {
                        if (!$page->pageID) {
                                throw new UserInputException('landingPageID');
                        }
-                       else if ($page->requireObjectID) {
+                       else if ($page->requireObjectID || $page->excludeFromLandingPage) {
                                throw new UserInputException('landingPageID', 'invalid');
                        }
                }
index 84f730b53f90604fe6d790cb1a21cc5cdad3c292..6c283a35a9b0905f83caa46f0a01768a771dbd5c 100644 (file)
@@ -76,7 +76,7 @@ class PageEditForm extends PageAddForm {
                        }
                }
                
-               if ($this->page->requireObjectID) {
+               if ($this->page->requireObjectID || $this->page->excludeFromLandingPage) {
                        // pages that require an object id can never be set as landing page
                        $this->isLandingPage = 0;
                }
index 7715ce106223f485d9bd3784e734b9339c52f5d7..12286bb8cdbfd28b0b05d2f05bf5f6eaa01e9213 100644 (file)
@@ -44,6 +44,7 @@ use wcf\system\WCF;
  * @property-read      string          $cssClassName                   css class name(s) of the page
  * @property-read      string          $availableDuringOfflineMode     is `1` if the page is available during offline mode, otherwise `0`
  * @property-read      string          $allowSpidersToIndex            is `1` if the page is accessible for search spiders, otherwise `0`
+ * @property-read      string          $excludeFromLandingPage         is `1` if the page can never be set as landing page, otherwise `0`
  * @property-read      string          $permissions                    comma separated list of user group permissions of which the active user needs to have at least one to access the page
  * @property-read      string          $options                        comma separated list of options of which at least one needs to be enabled for the page to be accessible
  */
index b954e02352798755e8bb40e3664cc3fe7b485334..88ba4f4ec2b3d6dde5b11ceb5ea8b39a30751dc8 100644 (file)
@@ -231,7 +231,8 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        'hasFixedParent' => ($pageType == 'system' && !empty($data['elements']['hasFixedParent'])) ? 1 : 0,
                        'cssClassName' => isset($data['elements']['cssClassName']) ? $data['elements']['cssClassName'] : '',
                        'availableDuringOfflineMode' => (!empty($data['elements']['availableDuringOfflineMode'])) ? 1 : 0,
-                       'allowSpidersToIndex' => (!empty($data['elements']['allowSpidersToIndex'])) ? 1 : 0
+                       'allowSpidersToIndex' => (!empty($data['elements']['allowSpidersToIndex'])) ? 1 : 0,
+                       'excludeFromLandingPage' => (!empty($data['elements']['excludeFromLandingPage'])) ? 1 : 0
                ];
        }
        
@@ -264,11 +265,13 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                
                /** @var Page $page */
                if (!empty($row)) {
-                       // allow only updating of controller and handler, everything else would overwrite user modifications
+                       // allow update of `controller`, `handler` and `excludeFromLandingPage`
+                       // only, prevents user modifications form being overwritten
                        if (!empty($data['controller'])) {
                                $page = parent::import($row, [
                                        'controller' => $data['controller'],
-                                       'handler' => $data['handler']
+                                       'handler' => $data['handler'],
+                                       'excludeFromLandingPage' => $data['excludeFromLandingPage']
                                ]);
                        }
                        else {
index 4920d554ffaecea520b4d0e28dcd949aea714eff..74959298656b0484ab5fcbf40987fb07be724958 100644 (file)
@@ -1029,6 +1029,7 @@ CREATE TABLE wcf1_page (
        cssClassName VARCHAR(255) NOT NULL DEFAULT '',
        availableDuringOfflineMode TINYINT(1) NOT NULL DEFAULT 0,
        allowSpidersToIndex TINYINT(1) NOT NULL DEFAULT 0,
+       excludeFromLandingPage TINYINT(1) NOT NULL DEFAULT 0,
        permissions TEXT NULL,
        options TEXT NULL
 );