diff --git a/README.textile b/README.textile index 4586cf7..30c880c 100644 --- a/README.textile +++ b/README.textile @@ -1,4 +1,4 @@ -h2. Acl Menu Plugin +h2. Acl Menu Plugin 0.2 This plugin provides a component for generating menus based off of the current user session and integrates well with the "AcoExtras Plugin":http://github.com/markstory/acl_extras/tree/master I also maintain. See "mark-story.com for additional info and usage":http://mark-story.com/posts/view/acl-menu-component @@ -7,3 +7,5 @@ To use the menu once in a @acl_menu@ dir on your pluginPaths. var $components = array('AclMenu.Menu'); When checking out this repo place it into an @acl_menu@ directory in one of your plugin paths. + +updated for cake 1.3 \ No newline at end of file diff --git a/controllers/components/menu.php b/controllers/components/menu.php index 0093498..97d4000 100755 --- a/controllers/components/menu.php +++ b/controllers/components/menu.php @@ -117,7 +117,7 @@ class MenuComponent extends Object { * * @return bool **/ - public function initialize(&$Controller, $settings) { + public function initialize($Controller, $settings) { if (!empty($settings)) { $this->_set($settings); } @@ -133,8 +133,8 @@ public function initialize(&$Controller, $settings) { * * @param Object $Controller */ - public function startup(&$Controller) { - $this->Controller =& $Controller; + public function startup($Controller) { + $this->Controller = $Controller; Cache::config($this->cacheConfig, array('engine' => 'File', 'duration' => $this->cacheTime, 'prefix' => $this->cacheKey)); @@ -208,7 +208,7 @@ public function constructMenu($aro) { $size = count($this->rawMenus); for ($i = 0; $i < $size; $i++) { $item = $this->rawMenus[$i]; - $aco = Inflector::underscore($item['url']['controller']); + $aco = Inflector::camelize($item['url']['controller']); if (isset($item['url']['action'])) { $aco = $this->aclPath . $aco . $this->aclSeparator . $item['url']['action']; } @@ -239,7 +239,7 @@ public function constructMenu($aro) { */ public function generateRawMenus() { $Controllers = $this->getControllers(); - $cakeAdmin = Configure::read('Routing.admin'); + $cakeAdmin = Configure::read('Routing.prefixes.0'); $this->createExclusions(); //go through the controllers folder and make an array of every menu that could be used. @@ -353,7 +353,7 @@ public function filterMethods($methods, $remove = array()) { * @return mixed. Array of options or false on total exclusion **/ public function setOptions($controllerVars) { - $cakeAdmin = Configure::read('Routing.admin'); + $cakeAdmin = Configure::read('Routing.prefixes.0'); $menuOptions = isset($controllerVars['menuOptions']) ? $controllerVars['menuOptions'] : array(); $exclude = array('view', 'edit', 'delete', $cakeAdmin . '_edit', diff --git a/tests/cases/components/menu.test.php b/tests/cases/components/menu.test.php index 7f14c43..b4a35ff 100755 --- a/tests/cases/components/menu.test.php +++ b/tests/cases/components/menu.test.php @@ -13,7 +13,7 @@ * @author Mark Story * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -App::import('Component', array('AclMenu.Menu', 'Acl', 'Auth')); +App::import('Component', array('AclMenu.Menu', 'Acl', 'Auth', 'Session')); App::import('Controller', 'AppController'); class TestMenuComponent extends MenuComponent { @@ -58,6 +58,19 @@ function admin_action(){} } Mock::generate('AclComponent', 'MenuTestMockAclComponent'); + + + + Cache::config('my_test_key', array( + 'engine' => 'File', + 'duration'=> '+1 day', + 'probability'=> 100, + 'path' => CACHE . 'menu', + 'prefix' => 'cake_', + 'lock' => false, + 'serialize' => true) + ); + /** * Menu Component Test Case * @@ -76,8 +89,10 @@ function startTest() { $this->Controller = new TestMenuController(); $this->Menu->Acl = new MenuTestMockAclComponent(); $this->Menu->Auth = new AuthComponent(); - $this->_admin = Configure::read('Routing.admin'); - Configure::write('Routing.admin', 'admin'); + $this->Menu->Auth->Session = new SessionComponent(); + $this->_admin = Configure::read('Routing.prefixes.0'); + Configure::write('Routing.prefixes.0', 'admin'); + $this->Menu->startup($this->Controller); } /** @@ -428,7 +443,7 @@ function testWeightSorting() { function endTest() { ClassRegistry::flush(); $this->Menu->clearCache(); - Configure::write('Routing.admin', $this->_admin); + Configure::write('Routing.prefixes.0', $this->_admin); unset($this->Menu, $this->Controller); } }