diff --git a/src/Resources/contao/dca/tl_article.php b/src/Resources/contao/dca/tl_article.php index 6e229d200e..7e053c89c5 100644 --- a/src/Resources/contao/dca/tl_article.php +++ b/src/Resources/contao/dca/tl_article.php @@ -376,7 +376,16 @@ public function checkPermission() $GLOBALS['TL_DCA']['tl_page']['fields']['cgroup']['default'] = (int) Config::get('defaultGroup') ?: (int) $this->User->groups[0]; // Restrict the page tree - $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $this->User->pagemounts; + if (empty($this->User->pagemounts) || !\is_array($this->User->pagemounts)) + { + $root = array(0); + } + else + { + $root = $this->User->pagemounts; + } + + $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $root; // Set allowed page IDs (edit multiple) if (\is_array($session['CURRENT']['IDS'])) diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 870f99192d..10ef20a5cd 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -888,11 +888,8 @@ public function checkPermission() // Check the current action switch (Input::get('act')) { - case 'paste': - // Allow - break; - case '': // empty + case 'paste': case 'create': case 'select': // Check access to the article diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index 36b2934598..a6e03d9082 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -462,11 +462,14 @@ public function checkPermission() switch (Input::get('act')) { case 'paste': - // Allow + case 'select': + if (!\in_array($id, $root)) + { + throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to access form ID ' . $id . '.'); + } break; case 'create': - case 'select': if (!\strlen(Input::get('id')) || !\in_array(Input::get('id'), $root)) { throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to access form ID ' . Input::get('id') . '.'); diff --git a/src/Resources/contao/dca/tl_page.php b/src/Resources/contao/dca/tl_page.php index 3f461cfea3..2a29595819 100644 --- a/src/Resources/contao/dca/tl_page.php +++ b/src/Resources/contao/dca/tl_page.php @@ -713,7 +713,16 @@ public function checkPermission() $GLOBALS['TL_DCA']['tl_page']['fields']['cgroup']['default'] = (int) Config::get('defaultGroup') ?: (int) $this->User->groups[0]; // Restrict the page tree - $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $this->User->pagemounts; + if (empty($this->User->pagemounts) || !\is_array($this->User->pagemounts)) + { + $root = array(0); + } + else + { + $root = $this->User->pagemounts; + } + + $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $root; // Set allowed page IDs (edit multiple) if (\is_array($session['CURRENT']['IDS'])) diff --git a/src/Resources/contao/drivers/DC_Table.php b/src/Resources/contao/drivers/DC_Table.php index 1dd6766e55..258f4076dc 100644 --- a/src/Resources/contao/drivers/DC_Table.php +++ b/src/Resources/contao/drivers/DC_Table.php @@ -229,7 +229,14 @@ public function __construct($strTable, $arrModule=array()) // Get root records from global configuration file elseif (\is_array($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'])) { - $this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table)); + if ($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] == array(0)) + { + $this->root = array(0); + } + else + { + $this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table)); + } } } @@ -5522,6 +5529,14 @@ protected function filterMenu($intFilterPanel) } } + $table = ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6) ? $this->ptable : $this->strTable; + + // Limit the options if there are root records + if (isset($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) && $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] !== false) + { + $arrProcedure[] = "id IN(" . implode(',', array_map('\intval', $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'])) . ")"; + } + $objFields = $this->Database->prepare("SELECT DISTINCT " . $what . " FROM " . $this->strTable . ((\is_array($arrProcedure) && \strlen($arrProcedure[0])) ? ' WHERE ' . implode(' AND ', $arrProcedure) : '')) ->execute($arrValues);