logo

Sensible Access Control in CakePHP without using ACL!

logo

Ok, so you are preparing your application to start coding, you are probably going to work on the users and the authentication system first of all and you want to limit different users to different parts of the site.

Sounds simple enough – cakePHP provides something called ACL as part of its core. However you find that when you try and implement it – you realise it is clunky, unreleting and basically far too complicated for every day use.

We used a different approach that we unashamedly rinsed from Studio Canaria, Peter Butler has knocked up a fantastic and a lot more logical approach to ACL. Basically you assign permissions based on groups rather than “objects” and “requesters”.

e.g. to grant access for a group to a specific controller / action you can add a row to the permissions table along the lines of controller:action or controller:* or even just * to override (for say a system developer).

Anyway, I digress. Check it out – his blog is a fantastic resource and has helped me out many times in the past:

http://www.studiocanaria.com/articles/cakephp_auth_component_users_groups_permissions_revisited

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Bit of an update

logo

Just wanted to update everyone as to what we are currently up to in the world of Nu Order Webs.

Dan (Me) is currently still working on a huge project for http://www.singtotheworld.com which is the redevelopment of a site called http://www.yoosing.com. It is being built from scratch in cakePHP. So far it has taken 4 months of development to get where I am, but in addition to other duties at Sing To The World I dont think its that bad considering it took a team of over 6 developers to code the original site 6 months. Matt is also doing SEO for them – however the current site is inflexible in it’s structure to allow for the necessary changes to be made as it is so for now the SEO consists of link building, article writing and other off site stuff.

We have been asked to quote on several other projects including a couple for a fun fair hire company, and a regular client of ours (http://www.recruitmentrevolution.com).

We are also currently developing a site for the owners of http://www.anythingequine.co.uk (another of our sites) which will be focused around equine dentistry blades, tools and accessories – aptly named http://www.equinedentistryblades.co.uk.

So all in all pretty busy at Nu Order towers but as always we love our work and in this time of recession love the extra money it brings in for not only us but for our clients aswell :)

Peace

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Extra Iterations in Data Array (hasMany Mistake)

logo

Just a quick one today, if you find you are having to use nested Set::Extracts or nested foreach loops in your code to extract data then it is possible you have some incorrect associations.

For instance if you array looks like this:

Array  (     [0] => Array         ( Array (    [0] => Array         ( 

It is possible that you have a hasMany where you should have an hasOne or belongsTo association.

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

REST with CakePHP

logo

I recently had a bit of a brain block how to do a certain thing in cakePHP – I basically wanted to update a model from a view but not using a GET method (as that would have allowed URL manipulation – and potentially created problems).

The simple answer (again thanks to Darren at zeen.co.uk) is to use a form to submit the data you need.

 
echo $form->create('SongList');
 
echo $form->input( 'sttw_track_id', array( 'value' => $track['SttwTrack']['id'], 'type' => 'hidden') );
 
echo $form->input( 'user_id', array( 'value' => $userID_Logged, 'type' => 'hidden') );
 
echo $form->submit($this->webroot . 'images/add_to_list.png', array('style' => 'width:31px; height:52px'));
 
echo $form->end();

This basically means that rather than creating a GET type URL (/controller/action/param1/param2) – I can now submit information pre-populated using POST. I know this seems obvious now you look at it, but to many newbies in CakePHP – doing something like this when there is so much automagical stuff going on can sometimes be overlooked.

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Passing data using Set() from Component to View

logo

I googled this for an hour trying to find the solution, in the end the very helpful people at irc.freenode.net (#cakePHP) helped me out.

I thought that when creating a custom component and extending the Object Class that certain methods were inherited – this isnt the case at all.

In order to use Set to pass stuff to the controller (and then onto the view) you must add the following method to your controller:

function initialize(&$controller, $settings = array()) {
  // saving the controller reference for later use
  $this->controller =& $controller;
}

Then when you want to use set() you simply call it as:

$this->controller->set('name', $name);

Hope this helps :)

You can also return data using the function return to the controller and then set it from there – but the above method is useful if you are returning multiple data to the view.

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

« Previous Entries

logo
Powered by Nu Order Webs