CakePHP 1.2 with ACL Auth, A quest complete
Recently, I have been working on a project that evolved from a freelance job gone sour. I had developed a very nice frontend and backend for a client to use with thier PSD Slices. I had a few things to work out for the Auth section of it.
They however were to intimidated by the complex/simplified approach of CakePHP.
But I digress. I decided to convert this over to a system I could use with http://4thofjulyfireworks.info , a site that I own. Having the need to still contend with the AUTH component of Cakephp 1.2 I started a quest to find more information.
First stop on the Google trail, http://dieter.plaetinck.be/figuring_out_cakephp_new_authcomponent where after some reading, and good base of understanding brought me to, here which helped alot. This btw did make into the bakery and after reading this, I felt even further from a solution.
As an after thought, I reread the text and was able to Grok it's fullness and was able to understand it alot better after visiting this post. There are many times that I find myself looking in the same loops for information, and coming completely full circle without finding a direct solution to my problem at hand.
Today was not one of those times. After reading this, and following all of the carefully described steps as it applied to my app, I had a working Auth system, with ACL, and even Groups Based. My site doesn't need groups nessacarilly, however I do like to reuse core code for alot of my projects, and this was a great opportunity to implement it into my workflow.
There was one detail though that I still had an issue with from this post. There was no view code for the acl function that I had implemented into the Users controller. So without further ado, here is my contribution to the post that I made reference to.
if(isset($groups))
{
foreach ($groups as $group)
{
echo "<div class=\"block\">";
echo "<span>" . $group['Group']['name'] . "</span>";
echo $group['Group']['description'] . "<br />";
echo "<h3>" . $html->link('View', '/users/acl/'. $group['Group']['id']). "</h3>";
echo "</div>";
}
}
if(isset($controllerList))
{
ksort($controllerPerms);
echo '<div class="block">';
echo "<span>" . $group['Group']['name'] . " Access Control</span>";
foreach ( $controllerPerms as $controller => $actions )
{
echo '<div class="aclBlock">' .$controller . "<br /><ul>";
foreach ( $actions as $key => $action )
{
if ($action == 1)
{
echo "<li>" . $key . " is allowed " . $html->link(' Deny', '/users/acl/'. $group['Group']['id'] . "/" . $controller . "/" . $key . "/deny") . "</li>\n";
}
else
{
echo "<li>" . $key . " is denied " . $html->link(' Allow', '/users/acl/'. $group['Group']['id'] . "/" . $controller . "/" . $key . "/allow") . "</li>\n";
}
}
echo "</ul></div>";
}
echo "</div>";
}
?>
So after tweaking this a bit, I hope that you are able to use this in your app and beable to have a simplified GUI for ACL control, something I have been looking for and found, thanks to Brian Thanks Brian! Till next time, Ron Chaplin

