From 99fb7faa326445f061cac84fb5897adb2534180d Mon Sep 17 00:00:00 2001 From: Jens Giessmann Date: Thu, 12 Mar 2020 15:10:21 +0100 Subject: [PATCH] add pageCheckAccessDomain option to dis/enable missing access_domain checks in default/page query add pageUseFallbackPage option to dis/enable using resolveFallbackPage for redirecting to fallbackPage which can lead to redirectloops default values for both options are backwards compatible --- Module.php | 17 ++++++++++++++++- controllers/DefaultController.php | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Module.php b/Module.php index 0207696..0fa8dc5 100644 --- a/Module.php +++ b/Module.php @@ -52,7 +52,22 @@ class Module extends \yii\base\Module * @var array */ public $availableViews = []; - + + /** + * Whether access_domain should be used as constraint in default/page action select + * + * @var bool + */ + public $pageCheckAccessDomain = false; + + /** + * Whether to search fallbackPage according to domain_id + * + * see: \dmstr\modules\pages\controllers\DefaultController::resolveFallbackPage + * @var bool + */ + public $pageUseFallbackPage = true; + /** * @inheritdoc */ diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php index 704b133..9bed9ba 100644 --- a/controllers/DefaultController.php +++ b/controllers/DefaultController.php @@ -10,6 +10,7 @@ namespace dmstr\modules\pages\controllers; +use dmstr\db\traits\ActiveRecordAccessTrait; use dmstr\modules\backend\interfaces\ContextMenuItemsInterface; use dmstr\modules\pages\assets\PagesBackendAsset; use dmstr\modules\pages\helpers\PageHelper; @@ -140,6 +141,10 @@ public function actionPage($pageId) ] ); + if ($this->module->pageCheckAccessDomain) { + $pageQuery->andWhere(['access_domain' => [\Yii::$app->language, ActiveRecordAccessTrait::$_all]]); + } + // get page /** @var $page Tree */ $page = $pageQuery->one(); @@ -202,6 +207,11 @@ public function actionPage($pageId) */ private function resolveFallbackPage($pageId) { + + if (!$this->module->pageUseFallbackPage) { + return false; + } + $original = Tree::find()->where(['id' => $pageId])->one(); if (empty($original)) {