diff --git a/code/CMSMenu.php b/code/CMSMenu.php index 785e8d91..e13e7eff 100644 --- a/code/CMSMenu.php +++ b/code/CMSMenu.php @@ -206,7 +206,13 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider if($allMenuItems) foreach($allMenuItems as $code => $menuItem) { // exclude all items which have a controller to perform permission // checks on - if($menuItem->controller && !singleton($menuItem->controller)->canView($member)) continue; + if($menuItem->controller) { + $controllerObj = singleton($menuItem->controller); + // Necessary for canView() to have request data available, + // e.g. to check permissions against LeftAndMain->currentPage() + $controllerObj->setRequest(Controller::curr()->getRequest()); + if(!$controllerObj->canView($member)) continue; + } $viewableMenuItems[$code] = $menuItem; } diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index a1056630..7bde28d4 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -109,7 +109,8 @@ class LeftAndMain extends Controller { */ function init() { parent::init(); - +var_dump('init'); +var_dump($this->request); SSViewer::setOption('rewriteHashlinks', false); // set language @@ -1002,6 +1003,7 @@ class LeftAndMain extends Controller { * @return int */ public function currentPageID() { + if(!$this->request) SS_Backtrace::backtrace(); if($this->request->getVar('ID')) { return $this->request->getVar('ID'); } elseif ($this->request->param('ID') && is_numeric($this->request->param('ID'))) {