A really nice snippet

Posted on 2010/07/21 by Randall.
Categories: Uncategorized.

Some PHP code to handily get at the things in an array:

print_r(compact(explode(' ', 'count acw cols coldepth')));
?>

I suppose var_dump() and print_r() can do something like this but maybe not…

Model::find() Returning Extra Results

Posted on 2010/07/04 by Randall.
Categories: Uncategorized.

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’.

CakePHP Acl + Auth Success

Posted on by Randall.
Categories: Uncategorized.

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.

Back to Joomla for a Bit

Posted on by Randall.
Categories: Uncategorized.

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.

Cake Caching, Sessions

Posted on 2010/07/03 by Randall.
Categories: Uncategorized.

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.

Caching in CakePHP

Posted on by Randall.
Categories: Uncategorized.

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.

Rebuild Project Notes #32

Posted on 2010/06/26 by Randall.
Categories: Uncategorized.

More fucking around with the autoSuggest scripts today…

I dropped autoSugget in favor of the built-in jQuery autocomplete. Works identically, and I have it working. There’s just one caveat. If you focus on a result using the keyboard it will put the value instead of the id into the textbox. This is just wrong. If you use the mouse, it puts the member’s name in the textbox. I don’t get it.

Rebuild Project Notes #31

Posted on 2010/06/16 by Randall.
Categories: Uncategorized.

I encountered this PHP error message for the first time today. I think this should have been something I’d uncovered much earlier. But here it is anyway: ” Illegal offset type in isset or empty”. This happened to me when I passed in an array argument where a string was expected.

This media plugin from david persson is pretty complicated. I finally have it setup so that it’s putting records in my attachments table. But I’m not seeing the tmp directory with UUID filenames. I need that. I’ve stopped wrestling with this for now, posted up a couple of messages to google groups and stackoverflow.com. Will see what kind of advice comes along.

Next up are a couple features I need: one-time password for “forgot my password” functionality, and auto-suggest for the member search form. This is sort-of working. I think that I need to take some lessons from the construction of this plugin and modify my signup process slightly.

Now I’m onto the Auto Suggest stuff for my search page. I first need to make an ajax service for the jQuery to work. My ajax url seems to work, I think that I just need to coerce my json_encode() output as well as maybe tweak my model (using virtual fields?) to fit the format of what autoSuggest jQuery expects.

Rebuild Project Notes #27

Posted on 2010/06/10 by Randall.
Categories: Uncategorized.

Well ain’t that a bitch…I’ve changed the Joomla site so that it now uses built-in fancy css-menus from the Quasar RocketTheme template…but the menus work like shit in IE 8. Works great if you enable “compatibility mode” in IE 8…basically making it act like it’s IE 7. So I guess the Rockettheme guys have developed to IE 7 instead of IE 8. I trust there will be a workaround to be found. The funny thing is…in IE 7 compatibility mode my transparent gradient background and background coloring works the way I want it to. Not in any of the other browsers though…

Rebuild Project Notes #26

Posted on 2010/06/07 by Randall.
Categories: Uncategorized.

Working on rebuilding the public-facing site today. It is a real PITA. Lots of SQL wrangling.

The SQL wrangling is going okay. Now I am trying to figure out how to pull in some of the gantry features. The documentation is god awful. I have even signed on to the the IRC channel to try and get the skinny from developers there. No luck yet…

I think the way to go is to take a look at one of the more full-featured free downloads from the rockettheme site. The one called Quasar might have the suckerfish menu in use. Or a better menu…

I might have solved this mystery. I installed the Quasar template to try out its menus. After fiddling with it for a longgggg time I finally found an option in the main menu module which says “always show submenu items.” Setting this to Yes made my sub items show up finally.