Added setting to allow access to a page during maintenance
authorMarcel Werk <burntime@woltlab.com>
Thu, 16 Mar 2017 18:55:12 +0000 (19:55 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 16 Mar 2017 18:55:12 +0000 (19:55 +0100)
See #2204

com.woltlab.wcf/page.xml
wcfsetup/install/files/acp/templates/pageAdd.tpl
wcfsetup/install/files/lib/acp/form/PageAddForm.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/install/files/lib/system/request/Request.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index b2ce9add68fac366440341c634a86c696b440669..003fb25f3e3bdbf2f9526209764fc8d572a5989c 100644 (file)
                        <pageType>text</pageType>
                        <name language="de">Dashboard</name>
                        <name language="en">Dashboard</name>
+                       <availableDuringOfflineMode>1</availableDuringOfflineMode>
                        
                        <content>
                                <title>Dashboard</title>
                        <pageType>text</pageType>
                        <name language="en">Cookie Policy</name>
                        <name language="de">Cookie-Richtlinie</name>
+                       <availableDuringOfflineMode>1</availableDuringOfflineMode>
                        
                        <content language="en">
                                <title>Cookie Policy</title>
index cb94e92fcb7ea3f8dc6c96a0e637d173ab4730f3..dc453a460a6b9a4c0a3be0e24273252a4db69ce3 100644 (file)
                                        </dl>
                                {/if}
                                
+                               <dl>
+                                       <dt></dt>
+                                       <dd>
+                                               <label><input type="checkbox" id="availableDuringOfflineMode" name="availableDuringOfflineMode" value="1"{if $availableDuringOfflineMode} checked{/if}> {lang}wcf.acp.page.availableDuringOfflineMode{/lang}</label>
+                                       </dd>
+                               </dl>
+                               
                                {event name='dataFields'}
                        </div>
                </div>
index 1557ae1a7cd9be08db2e190e944f32a2ff6dc579..480260aa6fefcb4167d7d94909651cfce2439704 100644 (file)
@@ -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,
index 5a20dad4f704aa45997090a449bac37741dd9005..1fe2f5bdc4418f8f62eea1489dc92270818dd27b 100644 (file)
@@ -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;
index ac63caee9dc9e327bf92d81d438f947be52fb9cc..6551a00662ed922bfeb6208148c34447abae8766 100644 (file)
@@ -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;
index 029dd7ac702c1d0970e98e0be93e911b1c2b591d..cf5740d28789edd0fc6aebd90e125784bfdd4af5 100644 (file)
@@ -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
                ];
        }
        
index 7a5757239dc5db42ccaaf986490f5fb464093087..21cbbaf8ba517033b8869de9cd14104768dde7f7 100644 (file)
@@ -158,6 +158,10 @@ class Request {
                        return true;
                }
                
+               if ($this->getPageID() && ($page = PageCache::getInstance()->getPage($this->getPageID()))) {
+                       if ($page->availableDuringOfflineMode) return true;
+               }
+               
                return false;
        }
        
index 90a2549586d81ba65cb53fcd76e01275cd62a12c..d9bf7e1d16ea7ddb79b7c53f5d3e709e99314391 100644 (file)
@@ -1422,6 +1422,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.page.type.tpl.description"><![CDATA[Eingabemöglichkeit entspricht dem Typ „HTML“, zusätzlich wird Template-Scripting unterstützt.]]></item>
                <item name="wcf.acp.page.url"><![CDATA[URL]]></item>
                <item name="wcf.acp.page.cssClassName"><![CDATA[CSS-Klassen]]></item>
+               <item name="wcf.acp.page.availableDuringOfflineMode"><![CDATA[Seite ist im Wartungsmodus aufrufbar]]></item>
        </category>
        
        <category name="wcf.acp.paidSubscription">
index 3c509af8b421b42b96a331e9591a188805d46705..7c805528ddcc26602754c33610e518ffbc62bb29 100644 (file)
@@ -2893,6 +2893,7 @@ Errors are:
                <item name="wcf.acp.page.type.tpl.description"><![CDATA[Similar to the type “HTML”, but offers additional support for template scripting.]]></item>
                <item name="wcf.acp.page.url"><![CDATA[URL]]></item>
                <item name="wcf.acp.page.cssClassName"><![CDATA[CSS Class Name]]></item>
+               <item name="wcf.acp.page.availableDuringOfflineMode"><![CDATA[Page is available during maintenance mode]]></item>
        </category>
        
        <category name="wcf.paidSubscription">
index 1a13e01fccb58c764668c22bf2b2e2c7c234f6c7..5e591e23ea9b5674490e235a69fb2b1a48665071 100644 (file)
@@ -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
 );