From d9fa555f2ec6b4c1454ef1ef081df437ffe3f0b4 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 21 Jul 2017 12:26:31 +0200 Subject: [PATCH] Disallow some pages from landing page Closes #2344 --- XSD/page.xsd | 1 + com.woltlab.wcf/page.xml | 10 +++++++++- .../install/files/acp/templates/applicationEdit.tpl | 2 +- wcfsetup/install/files/acp/templates/pageAdd.tpl | 2 +- .../files/lib/acp/form/ApplicationEditForm.class.php | 2 +- .../install/files/lib/acp/form/PageEditForm.class.php | 2 +- wcfsetup/install/files/lib/data/page/Page.class.php | 1 + .../plugin/PagePackageInstallationPlugin.class.php | 9 ++++++--- wcfsetup/setup/db/install.sql | 1 + 9 files changed, 22 insertions(+), 8 deletions(-) diff --git a/XSD/page.xsd b/XSD/page.xsd index 4f95efbc12..bad6fc7a30 100644 --- a/XSD/page.xsd +++ b/XSD/page.xsd @@ -57,6 +57,7 @@ + diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml index 53629e03e2..d1b2e44751 100644 --- a/com.woltlab.wcf/page.xml +++ b/com.woltlab.wcf/page.xml @@ -1,5 +1,5 @@ - + @@ -119,6 +119,7 @@ New Email Address Verification 1 com.woltlab.wcf.AccountManagement + 1 New Email Address Verification @@ -134,6 +135,7 @@ New Email Activation Code Request 1 com.woltlab.wcf.AccountManagement + 1 New Email Activation Code Request @@ -148,6 +150,7 @@ Anmeldung Login com.woltlab.wcf.AccountManagement + 1 Login @@ -162,6 +165,7 @@ Kennwort vergessen Lost Password com.woltlab.wcf.AccountManagement + 1 Lost Password @@ -190,6 +194,7 @@ Neues Kennwort New Password Request com.woltlab.wcf.AccountManagement + 1 New Password Request @@ -218,6 +223,7 @@ wcf\form\RegisterForm Registrierung Registration + 1 Registration @@ -247,6 +253,7 @@ Complete Registration 1 com.woltlab.wcf.Register + 1 Complete Registration @@ -262,6 +269,7 @@ New Activation Code Request 1 com.woltlab.wcf.Register + 1 New Activation Code Request diff --git a/wcfsetup/install/files/acp/templates/applicationEdit.tpl b/wcfsetup/install/files/acp/templates/applicationEdit.tpl index 8b2efa1f75..440a08c057 100644 --- a/wcfsetup/install/files/acp/templates/applicationEdit.tpl +++ b/wcfsetup/install/files/acp/templates/applicationEdit.tpl @@ -65,7 +65,7 @@ {foreach from=$pageNodeList item=pageNode} - {if !$pageNode->requireObjectID} + {if !$pageNode->requireObjectID && !$pageNode->excludeFromLandingPage} {/if} {/foreach} diff --git a/wcfsetup/install/files/acp/templates/pageAdd.tpl b/wcfsetup/install/files/acp/templates/pageAdd.tpl index 6b087aebcf..f28a395022 100644 --- a/wcfsetup/install/files/acp/templates/pageAdd.tpl +++ b/wcfsetup/install/files/acp/templates/pageAdd.tpl @@ -212,7 +212,7 @@ - {if $action != 'edit' || !$page->requireObjectID} + {if $action != 'edit' || (!$page->requireObjectID && !$page->excludeFromLandingPage)}
diff --git a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php index 0295a4c4ad..66842b64c8 100644 --- a/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/ApplicationEditForm.class.php @@ -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'); } } diff --git a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php index 84f730b53f..6c283a35a9 100644 --- a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php @@ -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; } diff --git a/wcfsetup/install/files/lib/data/page/Page.class.php b/wcfsetup/install/files/lib/data/page/Page.class.php index 7715ce1062..12286bb8cd 100644 --- a/wcfsetup/install/files/lib/data/page/Page.class.php +++ b/wcfsetup/install/files/lib/data/page/Page.class.php @@ -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 */ diff --git a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php index b954e02352..88ba4f4ec2 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -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 { diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 4920d554ff..7495929865 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -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 ); -- 2.20.1