From 110ca2e7a7c95c61c35a529a7933be041ef0d1c0 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 16 Mar 2017 19:55:12 +0100 Subject: [PATCH] Added setting to allow access to a page during maintenance See #2204 --- com.woltlab.wcf/page.xml | 2 + .../install/files/acp/templates/pageAdd.tpl | 7 ++++ .../files/lib/acp/form/PageAddForm.class.php | 11 ++++- .../files/lib/acp/form/PageEditForm.class.php | 4 +- .../files/lib/data/page/Page.class.php | 41 ++++++++++--------- .../PagePackageInstallationPlugin.class.php | 3 +- .../lib/system/request/Request.class.php | 4 ++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + wcfsetup/setup/db/install.sql | 1 + 10 files changed, 52 insertions(+), 23 deletions(-) diff --git a/com.woltlab.wcf/page.xml b/com.woltlab.wcf/page.xml index b2ce9add68..003fb25f3e 100644 --- a/com.woltlab.wcf/page.xml +++ b/com.woltlab.wcf/page.xml @@ -531,6 +531,7 @@ text Dashboard Dashboard + 1 Dashboard @@ -543,6 +544,7 @@ text Cookie Policy Cookie-Richtlinie + 1 Cookie Policy diff --git a/wcfsetup/install/files/acp/templates/pageAdd.tpl b/wcfsetup/install/files/acp/templates/pageAdd.tpl index cb94e92fcb..dc453a460a 100644 --- a/wcfsetup/install/files/acp/templates/pageAdd.tpl +++ b/wcfsetup/install/files/acp/templates/pageAdd.tpl @@ -222,6 +222,13 @@ {/if} +
+
+
+ +
+
+ {event name='dataFields'} diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index 1557ae1a7c..480260aa6f 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -155,6 +155,12 @@ class PageAddForm extends AbstractForm { */ public $cssClassName = ''; + /** + * true if the page is available during offline mode + * @var boolean + */ + public $availableDuringOfflineMode = 0; + /** * @inheritDoc */ @@ -212,6 +218,7 @@ class PageAddForm extends AbstractForm { if (isset($_POST['cssClassName'])) $this->cssClassName = StringUtil::trim($_POST['cssClassName']); if (isset($_POST['isDisabled'])) $this->isDisabled = 1; if (isset($_POST['isLandingPage'])) $this->isLandingPage = 1; + if (isset($_POST['availableDuringOfflineMode'])) $this->availableDuringOfflineMode = 1; if (isset($_POST['applicationPackageID'])) $this->applicationPackageID = intval($_POST['applicationPackageID']); if (isset($_POST['customURL']) && is_array($_POST['customURL'])) $this->customURL = array_map('mb_strtolower', ArrayUtil::trim($_POST['customURL'])); @@ -446,6 +453,7 @@ class PageAddForm extends AbstractForm { 'cssClassName' => $this->cssClassName, 'isDisabled' => $this->isDisabled ? 1 : 0, 'isLandingPage' => 0, + 'availableDuringOfflineMode' => $this->availableDuringOfflineMode, 'applicationPackageID' => $this->applicationPackageID, 'lastUpdateTime' => TIME_NOW, 'isMultilingual' => $this->isMultilingual, @@ -476,7 +484,7 @@ class PageAddForm extends AbstractForm { WCF::getTPL()->assign('success', true); // reset variables - $this->parentPageID = $this->isDisabled = $this->isLandingPage = 0; + $this->parentPageID = $this->isDisabled = $this->isLandingPage = $this->availableDuringOfflineMode = 0; $this->applicationPackageID = 1; $this->cssClassName = $this->name = ''; $this->customURL = $this->title = $this->content = $this->metaDescription = $this->metaKeywords = $this->boxIDs = $this->aclValues = []; @@ -510,6 +518,7 @@ class PageAddForm extends AbstractForm { 'cssClassName' => $this->cssClassName, 'isDisabled' => $this->isDisabled, 'isLandingPage' => $this->isLandingPage, + 'availableDuringOfflineMode' => $this->availableDuringOfflineMode, 'isMultilingual' => $this->isMultilingual, 'applicationPackageID' => $this->applicationPackageID, 'customURL' => $this->customURL, diff --git a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php index 5a20dad4f7..1fe2f5bdc4 100644 --- a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php @@ -138,7 +138,8 @@ class PageEditForm extends PageAddForm { 'isDisabled' => $this->isDisabled ? 1 : 0, 'lastUpdateTime' => TIME_NOW, 'parentPageID' => $this->parentPageID ?: null, - 'applicationPackageID' => $this->applicationPackageID + 'applicationPackageID' => $this->applicationPackageID, + 'availableDuringOfflineMode' => $this->availableDuringOfflineMode ]; if ($this->pageType == 'system') { @@ -225,6 +226,7 @@ class PageEditForm extends PageAddForm { if ($this->page->controllerCustomURL) $this->customURL[0] = $this->page->controllerCustomURL; if ($this->page->isLandingPage) $this->isLandingPage = 1; if ($this->page->isDisabled) $this->isDisabled = 1; + if ($this->page->availableDuringOfflineMode) $this->availableDuringOfflineMode = 1; foreach ($this->page->getPageContents() as $languageID => $content) { $this->title[$languageID] = $content->title; diff --git a/wcfsetup/install/files/lib/data/page/Page.class.php b/wcfsetup/install/files/lib/data/page/Page.class.php index ac63caee9d..6551a00662 100644 --- a/wcfsetup/install/files/lib/data/page/Page.class.php +++ b/wcfsetup/install/files/lib/data/page/Page.class.php @@ -24,26 +24,27 @@ use wcf\system\WCF; * @package WoltLabSuite\Core\Data\Page * @since 3.0 * - * @property-read integer $pageID unique id of the page - * @property-read integer|null $parentPageID id of the page's parent page or `null` if it has no parent page - * @property-read string $identifier unique textual identifier of the page - * @property-read string $name monolingual name of the page shown in the ACP - * @property-read string $pageType type of the page, default types: `text`, `html`, `tpl` `system` - * @property-read integer $isDisabled is `1` if the page is disabled and thus cannot be accessed, otherwise `0` - * @property-read integer $isLandingPage is `1` if the page is the landing page, otherwise `0` - * @property-read integer $isMultilingual is `1` if the page is available in different languages, otherwise `0` - * @property-read integer $originIsSystem is `1` if the page has been delivered by a package, otherwise `0` (i.e. the page has been created in the ACP) - * @property-read integer $packageID id of the package the which delivers the page or `1` if it has been created in the ACP - * @property-read integer $applicationPackageID id of the package of the application the pages belongs to - * @property-read string $controller name of the page controller class - * @property-read string $handler name of the page handler class for `system` pages or empty - * @property-read string $controllerCustomURL custom url of the page - * @property-read integer $requireObjectID is `1` if the page requires an object id parameter, otherwise `0` - * @property-read integer $hasFixedParent is `1` if the page's parent page cannot be changed, otherwise `0` - * @property-read integer $lastUpdateTime timestamp at which the page has been updated the last time - * @property-read string $cssClassName css class name(s) of the page - * @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 + * @property-read integer $pageID unique id of the page + * @property-read integer|null $parentPageID id of the page's parent page or `null` if it has no parent page + * @property-read string $identifier unique textual identifier of the page + * @property-read string $name monolingual name of the page shown in the ACP + * @property-read string $pageType type of the page, default types: `text`, `html`, `tpl` `system` + * @property-read integer $isDisabled is `1` if the page is disabled and thus cannot be accessed, otherwise `0` + * @property-read integer $isLandingPage is `1` if the page is the landing page, otherwise `0` + * @property-read integer $isMultilingual is `1` if the page is available in different languages, otherwise `0` + * @property-read integer $originIsSystem is `1` if the page has been delivered by a package, otherwise `0` (i.e. the page has been created in the ACP) + * @property-read integer $packageID id of the package the which delivers the page or `1` if it has been created in the ACP + * @property-read integer $applicationPackageID id of the package of the application the pages belongs to + * @property-read string $controller name of the page controller class + * @property-read string $handler name of the page handler class for `system` pages or empty + * @property-read string $controllerCustomURL custom url of the page + * @property-read integer $requireObjectID is `1` if the page requires an object id parameter, otherwise `0` + * @property-read integer $hasFixedParent is `1` if the page's parent page cannot be changed, otherwise `0` + * @property-read integer $lastUpdateTime timestamp at which the page has been updated the last time + * @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 $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 */ class Page extends DatabaseObject implements ILinkableObject, ITitledObject { use TDatabaseObjectOptions; 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 029dd7ac70..cf5740d287 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -220,7 +220,8 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '', 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '', 'hasFixedParent' => ($pageType == 'system' && !empty($data['elements']['hasFixedParent'])) ? 1 : 0, - 'cssClassName' => isset($data['elements']['cssClassName']) ? $data['elements']['cssClassName'] : '' + 'cssClassName' => isset($data['elements']['cssClassName']) ? $data['elements']['cssClassName'] : '', + 'availableDuringOfflineMode' => (!empty($data['elements']['availableDuringOfflineMode'])) ? 1 : 0 ]; } diff --git a/wcfsetup/install/files/lib/system/request/Request.class.php b/wcfsetup/install/files/lib/system/request/Request.class.php index 7a5757239d..21cbbaf8ba 100644 --- a/wcfsetup/install/files/lib/system/request/Request.class.php +++ b/wcfsetup/install/files/lib/system/request/Request.class.php @@ -158,6 +158,10 @@ class Request { return true; } + if ($this->getPageID() && ($page = PageCache::getInstance()->getPage($this->getPageID()))) { + if ($page->availableDuringOfflineMode) return true; + } + return false; } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 90a2549586..d9bf7e1d16 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1422,6 +1422,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 3c509af8b4..7c805528dd 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2893,6 +2893,7 @@ Errors are: + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 1a13e01fcc..5e591e23ea 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -980,6 +980,7 @@ CREATE TABLE wcf1_page ( hasFixedParent TINYINT(1) NOT NULL DEFAULT 0, lastUpdateTime INT(10) NOT NULL DEFAULT 0, cssClassName VARCHAR(255) NOT NULL DEFAULT '', + availableDuringOfflineMode TINYINT(1) NOT NULL DEFAULT 0, permissions TEXT NULL, options TEXT NULL ); -- 2.20.1