On Mon, Aug 10, 2009 at 1:24 PM, geste<[email protected]> wrote: > > Brian, > > Many thanks. I got over a bit of a hump on this on Friday with your > help. I do of course have another n00b follow up question :) > > I am using the authake plug-in for group-based authorization (this > nice plug-in has been taken over by Marco Sbragi and is on CakeForge: > http://cakeforge.org/projects/authake2/ > > I has a number of functions such as getLogin() and isPermitted() that > seem to work in views. For example, I can user getLogin() to display > user ID on the menu page with > > echo $authak3->getLogin() > > However, if I try to access the same function in my > menus_controller.php with: > > $testuser = $authak3->getLogin(); > > I then get a completely empty page/view. > > I am trying to determine if there is some sort of a general rule about > scope of functions between controller and view that makes the whole > thing bomb if I reference it from controller. > > One thing I am guessing is relevant is that Authake is referenced in > the app_controller.php in a BeforeFilter() like so: > > $this->Authake->beforeFilter($this);
That's because the View knows about $authak3, the Helper, but AppController has a handle on AuthakeComponent. I've never used the plugin but I had a look at it just now. You can access the same data in your controllers with $this->Authake->getLogin(), etc. Have a look through controllers/components/authake.php for the other stuff that it exposes. Compare that to plugins/views/helpers/authak3.php > and all links/controllers are checked against Authake right from the > start. The trick is that I want to check all possible menu links for > access right *before* I add the link to viewVars->Menu for the view to > render. I could access this authake3->isPermitted($menulink) in the > view, but then I would wind up adding a pretty fair amount of logic > like menu table queries to the view. I'm trying to make as much of > that work in the controller as I can. It looks like you can get that from the component with $this->Authake->isAllowed(...). > So any, broad clue about this appreciated. My question was starting to > get somewhat Authake-specific, but I think I am probably missing > something very general, very basic. Some of it's basic--keeping components and helpers straight (and I still get mixed up)--but having a concrete plugin (mini-app) as an example is actually pretty helpful. And the Authake-specific stuff is actually pretty important. I recently created a similar app using ACL, where the menu changes drastically between groups. Make sure to look into view caching so your controller can skip a lot of querying. You can name each view for the group_id, for instance. This makes it easy to delete when something Group-specific changes. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
