This one was tricky…if you pass in array('condition'=>array('id'=>1)), instead of array('conditions'=>array('id'=>1))…the engine will not complain, it will just return a whole lot of extra results from your Model::find() query. Remember to always use ‘conditions’.
A really nice snippet »« CakePHP Acl + Auth Success
I think that I finally cracked the problem, and have found my own best way of dealing with Cake’s authorization and access-control features. It’s about time! Still, it feels a bit yucky…I have had to resort to sub-classing the AuthComponent and adding in a few lines of code to create my own AuthComponent::isAuthorized(). The change I made just tries the user-based check first, and if that fails it tries the group-based check. This feels likes something that must be baked-in to the framework, but I’m just blind to the fact.
I really should come back at a later date and do a little better write-up of my findings. For now I will just say that I went with checking actions, not crud. I sub-classed the AuthComponent to override isAuthorized(). In my app_controller.php I implemented the constructClasses() function and added this line of code $this->Auth = $this->MyAuth; to replace the built-in version of Auth. My tree of aros is 3 deep with 2 levels of groups, a top-level to enclose the three lower-level groups…with individual users descending from these lower-level groups.
Model::find() Returning Extra Results »« Back to Joomla for a Bit
Hopping back to the Joomla side of things after getting much work done on the Cake side.
Just some simple stuff for now…using a plugin for Joomla to create some forms. I want to use these for a couple of things that I build first, that way when I hand over the site to the clients, I can provide them with instructions.
I’ve had it with JForms. I built up a pretty big form only to have it somehow corrupted after I tried to go in and update the layout of elements on the form. I can’t stand losing any work like that. So I will try out ChronoForms for now.
CakePHP Acl + Auth Success »« Cake Caching, Sessions
Far too much trouble to get the caching stuff working properly. Don’t get me wrong, I like Cake quite a bit, but it does have some rough patches. I find that I need to go looking into its source code quite a bit. That’s fine, the source is very nice and easy to read. They’ve done a fine job.
I eventually disabled caching across the board. The tags weren’t really working for me. I also saw questionable results when using the array('cache'=>false) argument for my $this->element() calls.
With Cake you often have many different ways to do the same thing. For instance, you can use $this->Model->recursive = -1 to limit the depth of results returned from a find() query. Or you can use the Containable behavior.
The lesson of the day thus far, without a doubt…do not ever forget this lesson. Call $this->Session->destroy() in your logout() routine.
Back to Joomla for a Bit »« Caching in CakePHP
I had to become educated in some of the finer points of caching in Cake. There are special tags you can use in your view templates to suppress caching of certain elements. The big breakthrough for me today was when I learned to call $this->disableCache() in my controllers. This fixed a problem I had in all browsers except for Chrome. My baked admin index views would not update when you deleted an item from the list. One more thing of note with regards to caching is that you can pass an array argument to $this->element() which passes in some configuration, one part of this config is a caching parameter. I’m trying to use this for my dynamic nav but so far it’s not working for me.
Ran through the various views to put in $this->set(‘title_for_layout’,'title value’) for each of those views. It’s one of those things which changed with the new 1.3 version of Cake.
I’ve decided to try and go with a controllers based authentication scheme for my app. I’m having way too much trouble setting up the action or crud version of auth+acl. It might add some code bloat, but then again there’s a lot that Cake takes care of for you so a little bit more code on the developer’s part is not such a worry. Perhaps some of the problems observed so far are artifacts of a crummy auth+acl setup on my part.
Another top priority is to get the media plugin from David Persson working. It seems extremely complicated so far so I might start from scratch on that effort.
Cake Caching, Sessions »« Rebuild Project Notes #32