From c80a99d3652e07583665a670033cc84d40ff439f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 9 Jul 2016 20:06:28 +0200 Subject: [PATCH] Allow most system pages to receive a new parent --- com.woltlab.wcf/page.xml | 18 +++++++++++++++++ .../install/files/acp/templates/pageAdd.tpl | 4 ++-- .../files/lib/acp/form/PageAddForm.class.php | 4 ++++ .../files/lib/acp/form/PageEditForm.class.php | 20 ++++++++++++++++++- .../files/lib/data/page/Page.class.php | 1 + .../PagePackageInstallationPlugin.class.php | 3 ++- wcfsetup/setup/db/install.sql | 1 + 7 files changed, 47 insertions(+), 4 deletions(-) diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml index b727d692b8..66d99593ce 100644 --- a/com.woltlab.wcf/page.xml +++ b/com.woltlab.wcf/page.xml @@ -98,6 +98,7 @@ wcf\form\AvatarEditForm + 1 com.woltlab.wcf.AccountManagement @@ -112,6 +113,7 @@ wcf\form\EmailActivationForm + 1 com.woltlab.wcf.AccountManagement @@ -126,6 +128,7 @@ wcf\form\EmailNewActivationCodeForm + 1 com.woltlab.wcf.AccountManagement @@ -195,6 +198,7 @@ wcf\form\NotificationSettingsForm + 1 com.woltlab.wcf.AccountManagement @@ -236,6 +240,7 @@ wcf\form\RegisterActivationForm + 1 com.woltlab.wcf.Register @@ -250,6 +255,7 @@ wcf\form\RegisterNewActivationCodeForm + 1 com.woltlab.wcf.Register @@ -277,6 +283,7 @@ wcf\form\SettingsForm + 1 com.woltlab.wcf.AccountManagement @@ -292,6 +299,7 @@ module_user_signature + 1 com.woltlab.wcf.AccountManagement @@ -321,6 +329,7 @@ wcf\page\FollowingPage + 1 com.woltlab.wcf.AccountManagement @@ -335,6 +344,7 @@ wcf\page\IgnoredUsersPage + 1 com.woltlab.wcf.AccountManagement @@ -364,6 +374,7 @@ mod.general.canUseModeration + 1 com.woltlab.wcf.ModerationList @@ -380,6 +391,7 @@ com.woltlab.wcf.ModerationList mod.general.canUseModeration + 1 1 @@ -395,6 +407,7 @@ com.woltlab.wcf.ModerationList + 1 mod.general.canUseModeration 1 @@ -410,6 +423,7 @@ wcf\page\NotificationListPage + 1 com.woltlab.wcf.AccountManagement @@ -425,6 +439,7 @@ module_paid_subscription + 1 com.woltlab.wcf.AccountManagement @@ -440,6 +455,7 @@ com.woltlab.wcf.Search + 1 1 @@ -495,6 +511,7 @@ module_article com.woltlab.wcf.ArticleList + 1 1 @@ -505,6 +522,7 @@ module_article com.woltlab.wcf.CategoryArticleList + 1 1 diff --git a/wcfsetup/install/files/acp/templates/pageAdd.tpl b/wcfsetup/install/files/acp/templates/pageAdd.tpl index 7c8671b431..2ec202c90b 100644 --- a/wcfsetup/install/files/acp/templates/pageAdd.tpl +++ b/wcfsetup/install/files/acp/templates/pageAdd.tpl @@ -111,11 +111,11 @@
- hasFixedParent} disabled{/if}> {foreach from=$pageNodeList item=pageNode} - + {/foreach} {if $errorField == 'parentPageID'} diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index 98bd0bb6d5..627dfb8b52 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -289,6 +289,10 @@ class PageAddForm extends AbstractForm { if (!$page->pageID) { throw new UserInputException('parentPageID', 'invalid'); } + + if ($page->requireObjectID) { + throw new UserInputException('parentPageID', 'invalid'); + } } } diff --git a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php index 4ae43fd0e2..21ecc66dc0 100644 --- a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php @@ -5,6 +5,7 @@ use wcf\data\page\PageAction; use wcf\form\AbstractForm; use wcf\system\acl\simple\SimpleAclHandler; use wcf\system\exception\IllegalLinkException; +use wcf\system\exception\UserInputException; use wcf\system\language\LanguageFactory; use wcf\system\WCF; @@ -66,8 +67,11 @@ class PageEditForm extends PageAddForm { $this->pageType = $this->page->pageType; if ($this->page->originIsSystem) { - $this->parentPageID = $this->page->parentPageID; $this->applicationPackageID = $this->page->applicationPackageID; + + if ($this->page->hasFixedParent) { + $this->parentPageID = $this->page->parentPageID; + } } if ($this->page->requireObjectID) { @@ -92,6 +96,20 @@ class PageEditForm extends PageAddForm { // type is immutable } + /** + * @inheritDoc + */ + protected function validateParentPageID() { + if ($this->page->hasFixedParent) { + if ($this->parentPageID != $this->page->parentPageID) { + throw new UserInputException('parentPageID', 'invalid'); + } + } + else { + parent::validateParentPageID(); + } + } + /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/data/page/Page.class.php b/wcfsetup/install/files/lib/data/page/Page.class.php index 97e9586fcb..183d598f8d 100644 --- a/wcfsetup/install/files/lib/data/page/Page.class.php +++ b/wcfsetup/install/files/lib/data/page/Page.class.php @@ -37,6 +37,7 @@ use wcf\system\WCF; * @property-read string $handler * @property-read string $controllerCustomURL * @property-read integer $requireObjectID + * @property-read integer $hasFixedParent * @property-read integer $lastUpdateTime * @property-read string $permissions * @property-read string $options 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 42f7fd8071..66b74e087d 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -218,7 +218,8 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin 'applicationPackageID' => $applicationPackageID, 'requireObjectID' => (!empty($data['elements']['requireObjectID'])) ? 1 : 0, 'options' => (isset($data['elements']['options'])) ? $data['elements']['options'] : '', - 'permissions' => (isset($data['elements']['permissions'])) ? $data['elements']['permissions'] : '' + 'permissions' => (isset($data['elements']['permissions'])) ? $data['elements']['permissions'] : '', + 'hasFixedParent' => ($pageType == 'system' && !empty($data['elements']['hasFixedParent'])) ? 1 : 0 ]; } diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 25aa7447f5..cd5c0cebe9 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -963,6 +963,7 @@ CREATE TABLE wcf1_page ( handler VARCHAR(255) NOT NULL DEFAULT '', controllerCustomURL VARCHAR(255) NOT NULL DEFAULT '', requireObjectID TINYINT(1) NOT NULL DEFAULT 0, + hasFixedParent TINYINT(1) NOT NULL DEFAULT 0, lastUpdateTime INT(10) NOT NULL DEFAULT 0, permissions TEXT NULL, options TEXT NULL -- 2.20.1